OpenPerpetuum / PerpetuumServer

The Open Perpetuum Project's fork of the Perpetuum Standalone Server
https://openperpetuum.com
Other
44 stars 21 forks source link

Investigate and create more adaptable AStar OpenList sizing #425

Closed MikeJeffers closed 2 years ago

MikeJeffers commented 2 years ago

https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/PathFinders/AStarFinder.cs#L103 I grow increasingly suspicious our bigger home-ranged npcs will fail to resolve a path because of the max size of this list. Ideally it is sized to something proportional to its radius (at a minimum it must check the full length of the diagonal and all neighboring tiles).

At the most worst case it has to explore all tiles within the circular area it is allow to traverse from its home xy to a radius of homerange (2pihomerange^2) Its highly unlikely it can only travel a path that is every tile in the circle, more likely it is 1/4 or less of this area. Figuring out a heuristic for a decent % area to explore before giving up would be desired, allowing this ceiling to be set lower and allocate less memory.

This ticket is to investigate if raising this value would resolve path failure issues (where they default to walking straight home) and if fixing would be a major impact on the NPC AI stack performance, solving bounded, but increasingly large, paths.

If the choice is to change it, make it adaptable to accept a parameter to allocate this list based on what the caller can provide

MikeJeffers commented 2 years ago

Sorry false alarm, PQ does dynamically resize https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Collections/PriorityQueue.cs#L22-L25 Something else is causing pathing to fail in some edge cases