Advertisement

Wandering (deliberately sub-optimal pathfinding?)

Started by April 10, 2003 06:06 PM
12 comments, last by Kylotan 21 years, 7 months ago
quote: Original post by fup
"I would suggest implementing a version of the Steering Behaviors and just alter the influence of the attraction force to the goal, as needed. It would be a dynamic, and computationally low impact solution, that would as a side benefit, really look like wandering. I know, I''ve done it before to produce a wandering NPC"

Depending on the environment that will not guarantee that the agent finds the goal Geta. Kylotan stated that the goal must be found.


You are right of course, if one implemented pure steering in its classic form. Likewise, with the right (or is it wrong?) environment, varying the edge weights improperly could produce some really bizzare paths by an A* that would look extremely unnatural. This is why I suggested a "version" of steering behaviors. One can get the benefits of steering and yet still always find the goal. Anyway, it worked for me, in a highly complex environment in FSC so I thought I would share that experience. Sorry I can''t post any sample code. Maybe after a while I can write about its details.

Eric
Following Geta''s line of thought... a Steering Behaviour is related to a Potential Field implementation for search. Here are two ideas related to using such an idea for wandering.

1) Generate a potential field for the domain. This provides a forcing term for each cell or locale on the map that drives the agent toward the goal (and away from obstacles). Then perturb the field potentials by a user defined level. Make sure the perturbations are smooth over a chosen scale. Set the agent free and watch it head toward the goal. If the perturbations are sufficient, it should deviate from the optimal path (because the lowest cost path through the new potential field does not equate to the lowest cost path of the unperturbed field.

Alternatively,

2) Generate the optimal potential field. At each step the agent wishes to take you need to compute a new velocity vector, given it''s old velocity, momentum and forcing from the potential field. Perturb the computed value with an additive, zero mean random variate. The variance of this random variable should be proportional to the user preference for wandering. Because the noise is zero mean and additive, the agent will eventually get to the goal. although how long this takes will depend on the variance.

Cheers,

Timkin
Advertisement
you might also weight this random variable based on the distance (or agent''s perceived distance) from the goal. you could implement a variety of behaviors this way including the appearance that the agent is searching for the goal, or milling around the goal on arrival as if guarding it.
What do you guys think about this idea:

Ofte, when trying to solve complex problems, real people behave as they are using the "greedy algorithm".

In this case, start off by finding the optimal route.

Then, move as directly to the goal as possible - sometimes it will be the fastest way (open terrain) sometimes it will be very "sub-optimal" (maze-like terrain), but in every case it would make the NPC look pretty human in it''s behaviour.

my two cents...

Ulf Livoff

This topic is closed to new replies.

Advertisement