The pathfinding issues aren't directly addressable through Lua without the heavy cost of doing pathfinding in a scripting language. Please discuss how it affect you in your playthroughs and whether you observe the same problems.
There are wall layouts having a high degree of confusing biter pathfinding using either labyrinths or dragon's teeth. The primary issue is that biters attempt to cross the overlong path at all (unless their collision boxes are too big) rather than razing it. The secondary issue is that multiple biters confuse each other when they're blocking each other's paths. You can see the same effect in e.g. Baldur's Gate 2 when traversing a tight corridor with the party.
The secondary issue is most evident with dragon's teeth. The path isn't overly long then but they confuse themselves through pathfinding. There's a solution used in the game industry - change the pathfinding to a formula where units blocking the path are neighbors but with higher weight:
Let the biter having its path computed have stationary time "a" in suitable units.
Let the blocking biter have its stationary time be "b".
Compute the path ignoring same faction's collision, but having the distance's weight for faction-blocked tiles multiplied by "(C)max(a, b) + M" with fine-tuning.
If the blocked path has the lowest cost (or there's no actually-passable path), wait there, attacking the nearest enemy object in the pollutant's direction in melee/ranged. Recompute cost soon, especially if other units move.
The primary issue is most evident with labyrinth wall design. It's ok to assign an impassable wall tile a cost as well, rather than treating it as a non-neighbor in A*/Dijkstra. Assign a cost that's lower than now, encouraging biters to kill walls. Maybe compare Bresenham distance to full pathfinding. Assume anything longer than, say, 1.5, is a labyrinth and kill the walls. Progressively destroying the labyrinth's walls is more severe than traversing it and dying.
Another solution for the primary issue is to pathfind with an enlarged collision box. If sufficiently enlarged when moving toward target (say even 4x), will treat terrain as impassable and smash a simple path.
So here are wall designs:
Code: Select all
Legend:
T - turret
U - turret "targeted" by biters (who die before reaching it)
| - wall
* - wall targeted by biters
=== NAIVE WALL ===
T |||*
T |||*
||||
TASTY ||||
FACTORY ||||
||||
T |||*
T |||*
=== LABYRINTH ===
| | |
U | |
U | | | |
| | | |
TASTY | | |
FACTORY | | |
| | | |
U | | |
U | |
| | |
=== DRAGON'S TEETH ===
U | | | | |
U | | | |
| | | |
TASTY | | | |
FACTORY | | | |
| | | |
U | | | |
U | | | | | |