clintbellanger/flare — Issue #252: Enemy can get stuck between A* and LOM
Author: clintbellanger
Created: 2011-12-28 01:32:45+00:00
State: open
Labels: Bug

Here's a corner case with the current pathfinding. I think we can solve it in a practical way.

A note on how movement currently works:

* LOM (line of movement) steering is very primitive: the enemy turns to face the hero and walks forward. Enemies face in one of 8 directions, and the best direction is chosen.
* A* was just added (yay). When enemies lose LOM, they use A* to move around obstacles.

Here's a scenario that comes up with some testing:

.###..ab.
.#####...
.........
H######..

* Hero is at position H
* Goblin is at position b, has Line of Movement
* The best direction to face is left, so the Goblin walks into position a
* No longer has line of movement, so switches to A*
* A* causes the goblin to move back to b
* Repeats

Perhaps a practical fix: Once creatures re-establish Line of Movement, they still use A* for a few frames (maybe a full second, 30 frames?). This might help creatures navigate these corner cases where A* and LOM cause them to move back and forth.