RPG - Floodfill pathfinding for groups of agents

Monkey Forums/Monkey Code/RPG - Floodfill pathfinding for groups of agents

Pakz(Posted 2015) [#1]
Here a video of the code :


I coded floodfill pathfinding before but I thought it was difficult then. Now I understood what was happening a lot better.
In the code I create a tilemap. A player is on the map that can be moved. Every move of the player a map is flooded. The flood code at every step creates a larger number. This way you will be able to count back towards the start from every reachable position on the map.
The ai does this. They are randomly added on the map and start moving towards the lowest number around them and so will eventually reach the player.

In Rpg's and such you have the ai moving towards the player when he enters the map. This code shows one way of doing this.

Here the code :



I have the code also on my blog with a flash applet there.


tiresius(Posted 2015) [#2]
That is interesting all I've ever heard of is A* path finding but it sounds like flood fill is fine for many cases. Thanks for sharing !


Xaron(Posted 2015) [#3]
Thanks for sharing, looks great indeed!