We all know that pathing is one of the biggest performance sinks in DF. But what if we wouldn't do path finding, but instead
obstacle avoidance and steering (warning, sciency stuff, brain may hurt)?
From my (quite limited but good enough) understanding of it this would cause these things to happen:
- AI entities would behave in more natural way (i.e. could get lost or not necessarily take the most optimal path to the target) which would make them feel more like real people rather than robots.- It has much less performance requirements as the algorithms are simpler than popular pathfinding algorithms (such as A*), which would do wonders for big forts.
- Unless specifically programmed, the AI entities won't know the location of things which would allow invader forces to (literally) get lost if you mask entrance to your fort well enough and leave after a while of not finding it.Of course there are potential problems with that, but I think I have solutions for most of those.
Problem: Urist McChildinthefog lost himself in the fortress and can't get to the building site
Solution: Allow for building a "mental map" of the places the AI agent in question visit most often, then steer towards the closest tile of that map, then replay it (very limited pathfinding that wouldn't be recalculated every tick, only if something unexpected would be in the way, and then it would just navigate around it using obstacle avoidance and record the "new" way for future reference).
Problem: Invaders can't get to the fortress, no matter how many scouts they send and no matter if they successfully find the fortress and return.
Solution: Allow for sharing of "mental maps" of places between creatures. This would also help the migrants learn the layout of the fort from dwarves that were already there. Another interesting thing this would allow would be to follow the scout out of the map and then place traps on the route he took to kill most of the invading forces before they even get to the fortress.Also the algorithms involved are much simpler than any "fullblown" pathfinding and would make units move in more natural manner.