Advertisement

On entering proximity

Started by October 20, 2009 04:05 AM
5 comments, last by TheUnnamable 15 years, 1 month ago
Hi all! My first post here :) I'm working on a simulation of a crowd of people in a busy urban environment. They are represented by dots in a 2D top down environment. Each one has a radious of proximity, in which it detects others and then decides if it wants to take any action. I have currently set it up in a way, that each individual decides what to do with each other person that is in its proximity (so each frame that person is in proximity, the individual will roll decisions). I want the procedure to be activated only when the other person enters the area, but not anymore after it still is in that area. How would i go about doing that? Using a dynamic array to track the ID's of all the characters in proximity for each person there is seems quite...unoptimal. Tnx for all your help P.S. Working in C#
First, remember that you only have to check the distance once for each pair of folks (that is assuming they all have the same proximity radius). That helps the number of comparisons.

Second, you can parse your world into grids and quickly check to see which grid section a person is in. That way, when you search for proximity, you only need to search your own grid cell and those immediately around it (to allow for straddling edges). Depending on the size of your city and how many people are in it, this is a massive optimization.

Also, remember to not check for an interaction every frame.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement
Generally they will have the same proximity radious, but since each one can have a distinctive personolity, this is not set in stone. So i will keep the number of comparisons.

I do thank you for your reply as it was quite useful. The project moves on... :)
An idea, but I'm not sure about it: make a grid from your world and store the ID's of folks in the cell where they are. And then check all folks in range in the neighboring cells. Then decide to do anything with them.
Quote: Original post by TheUnnamable
An idea, but I'm not sure about it: make a grid from your world and store the ID's of folks in the cell where they are. And then check all folks in range in the neighboring cells. Then decide to do anything with them.


Uh... isn't that what I said above?

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

just make a grid and...

haha jk (sorry InnocuousFox couldn't resist) :P
Advertisement
Quote: Original post by InnocuousFoxUh... isn't that what I said above?


Damn, it looked like it wasn't said :? Sorry for my post

This topic is closed to new replies.

Advertisement