Random wandering toward goal destination

tron_thomas 101 Feb 07, 2011 at 04:23

I have a situation where there are numerous objects that need to wander about on a 2D plane. The objects should avoid certain areas in the plane and should also eventually make their way toward a desired goal destination.

Where can I find resources that would help with implementing this type of behavior?

7 Replies

Please log in or register to post a reply.

Reedbeta 167 Feb 07, 2011 at 04:37

First of all, google for “pathfinding” and in particular “A* search”, which is very handy anytime you need things to move around and avoid obstacles.

If you want things to wander randomly, you could try an approach like: pick a random point within a certain radius (excluding points in obstacles) and path to it. When you get there, pick another random point and repeat.

To make them gradually head toward a goal, every few iterations you could substitute the randomly chosen destination with the goal itself, but then only let them travel a short distance before re-randomizing the goal point. Depending on the obstacle geometry there’s no guarantee they wouldn’t get stuck in a steady state far from the goal, though.

tron_thomas 101 Feb 07, 2011 at 04:45

I have the basic wandering around in a random way figured out.

I have tried using Google to find something that would be useful, and have not run across anything. That is why I’m now posting to this forum.

I don’t think I need to resort to something as complicated as A* to solve this problem. I’m not interested in finding an optimal path from a source to destination.

I’m hoping to find something dealing with areas that can attract or repel as object move close to those areas.

rouncer 104 Feb 07, 2011 at 05:30

a* isnt complicated.

if you still dont want it, why not just weight their random movements towards the goal, and theyll get there eventually? is that what you want?

alphadog 101 Feb 07, 2011 at 13:20

What kind of wandering?

Independent, directed human-like “wandering” (say, people in a city each with their own objective), crowded path (like filing into a stadium), or like a flock of birds (chaotic “follow the leader”)?

This may help:


tron_thomas 101 Feb 08, 2011 at 03:50

They are supposed to be zombies wandering around in a court yard and slowly making their way into building.

fireside 141 Feb 08, 2011 at 05:18

You could pick random directions that have to more or less point toward the door and shift them in random amounts of time. You would need an avoidance system, though.