-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance: Optimize map::route and map::get_path_avoid. #69198
Conversation
…hfinding, and allow incremental updates to the pathfinding cache.
…hopeless, and clean up/clarify some details.
There's currently a problem with this, in that some changes I made to monster's |
…and will be added separately.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered. |
Superseded by #70274 |
Summary
Performance "Increase speed of pathfinding substantially."
Purpose of change
These two functions are a giant hotspot when waiting in high traffic areas.
Describe the solution
This PR makes
threetwo broad changes, somewhat interlinked:get_path_avoid()
to evaluate locations to avoid before running A*, however this defeats the entire point of A*. Replaced the function with lazy evaluation alternativesshould_path_avoid()
andget_should_path_avoid_functor()
so the pathfinder can evaluate these locations as they are visited. This however means the pathfinder must evaluate more tiles, which brings us to change 2.Use a flood fill to detect areas where monsters are trapped, but otherwise want to leave. This is a common occurrence in underground locations with reinforced windows or bars, and results in the monster running A* on the whole room every tick. This marks such zones with a minimum bash strength needed to escape, and if the target is outside of this zone, pathfinding is skipped entirely.Flood fill is being moved to a separate PR.Testing
Tests pass, game appears to work. Needs more playtesting from my end, so PR is still in progress.
Additional context
Flame graph before: