Game development and more

Motion planning #2: waiting behaviour

Fixed a motion planning problem from my previous post. Now moving agents do not bump into each other. Instead, they wait. If a waypoint is marked as a goal for an agent, a flag is set on the waypoint, telling that it is "reserved". It makes other agents wait until the waypoint is released again.

FYI: Anything that acts is an agent, here "agents" are just moving entities. Applied to a game, they can be cars, pedestrians, monsters, etc.

Waiting behaviour with Python and Pygame

This works better with evenly-spaced waypoints and agents moving with equal speed. But even with these conditions, this behaviour creates unnatural pauses as seen on 1:08 of the video. This happens because agents don't know anything about distance to the next waypoint, distances to the other agents or their own speed. The only thing they know if the next waypont is targeted by any of the other agents or not.

The system can be improved if agents would calculate the distance to the next waypoint and to the other agents, and try to speed up/slow down. Implenementing more complex behaviours, like steering, can improve it even further.


Share Back to main