Key features:
- Guide your settlement from the stone age until the late ages.
- Hunt, craft useful tools, breed animals, plant crops
- Arrange the production of the necessary spare parts for the construction of a new time machine
- Trade with caravans
In this devlog, I want to share how a simple and familiar algorithm Flood fill helped me massively speed up pathfinding in my game.
Why Bother?
Imagine you have a big map filled with obstacles: houses, walls, trees, etc. When a creature wants to move from point A to point B, the game needs to figure out if its even possible to get there.
Running a full pathfinding algorithm every time even when there's clearly no path wastes time and resources. So I decided to precalculate which areas are actually connected and only allow pathfinding when it makes sense.
The Idea: Divide the Map into isolated zones
Every time the player places an unwalkable structure (like a wall) on a tile, the game runs a Flood fill algorithm from each walkable side of that tile.
The algorithm explores all reachable walkable tiles connected to that side and tries to form a new isolated zone.
You can think of it like pouring paint from each side of the blocked tile each "puddle" becomes its own zone.
As a result, instead of running expensive pathfinding calculations, creatures in the game now simply check whether their destination tile is in the same zone theyre currently in.
If it is go ahead and search for a path.
If its not no need to try: there's clearly no way to get there!
Support me on Boosty: https://boosty.to/ricktechnolithic
Minimum Setup
- OS: Ubuntu 12.04 LTS
- Processor: 2 GhzMemory: 2 MB RAM
- Memory: 2 MB RAM
- Graphics: 256 mb video memory. OpenGL 2
- Storage: 500 MB available space
[ 6520 ]
[ 2504 ]
[ 4798 ]