Game development and more

Motion planning #1: random path following

I've started to design a waypoint system for my game. Ideally, I would like to build a city traffic network on top of it, but now it is a long way to go.

Currently the system consists of two main concepts: waypoints and agents.

Waypoint is a point in 2d space that has x and y coordinates and a list of waypoints that can be reached from it. If a waypoint can be thought of as a graph node, a connection between two waypoints is a graph edge.

Agents are entities that move between waypoints. When spawned, an agents seeks the nearest waypoint. When the waypoint is reached, agent randomly chooses the next waypoint from the list of the next waypoints. Here's the video to illustrate this:

Random path following with Python and Pygame

As you may have noticed, agents don't know about each other, so they often cross their ways and overlap. This issue is going to be fixed.


Share Back to main