Your browser doesn't support HTML5 canvas.

While I still think this code is still pretty cool it’s really old now and it’s a bit embarrassing, however I was really proud of it at the time. I have a far more current and useful article here: Pathfinding on different grids where terrain effects the travel time

Dave’s Pathfinding

This demo will spawn blobs that will try and find a path to a random point navigating around the obstacles and avoiding the other blobs. This is all done without each blob communicating between each other.

  • The blue lines are the most efficient way of getting around the walls.
  • The green lines are the furthest point along the blue line the blob can see so move towards this point
Controls:

This is non interactive. Just sit back and watch.

How it works:

First we turn the whole map into a grid and work out the least number of grid cells a blob has to go through to get to its destination. This is mathematically the optimum route to take! (this doesn’t take into account any other things moving around or the most efficient way of pathing)

Then looks to see what point furthest away is can see, this is the next place it should aspire to get to.

After this it takes each step one at a time and tries its best to move as best it can towards this point. - This way it only needs to work about moving in a very local area and is very efficient.

What is different about this system.
  • Works out collisions with other objects moving around (this is normally hard and intensive because it is a constantly changing environment with many intricacies).
  • Blobs don’t get trapped trying to find their way out of caves (they are smart enough to know to get to the destination they may have to move further away first).
  • Light weight
  • Massive number of objects moving
  • Hybrid
Get an E-mail when I post something new: Signup