Skip to content
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

Improved pathfinding #14

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Improved pathfinding #14

merged 1 commit into from
Nov 12, 2024

Conversation

kelindar
Copy link
Owner

This pull request includes significant changes to the pathfinding logic in the tile package, focusing on improving performance and simplifying the codebase. The most important changes include replacing the heap-based priority queue with a bucket-based frontier, optimizing the pathfinding state management, and updating the benchmarks and tests to reflect these changes. Most of the changes are thanks to quasilyte/pathing (see deck zero-alloc-pathfinding). Replacing the heap with his priority queue and replacing the visited map with my int-int map simplified implementation and achieved general speedup of 5-40x, making me wonder what I was thinking when implementing this pathfinding a few years ago.

Pathfinding Optimization:

  • Replaced the heap-based priority queue with a bucket-based frontier for more efficient pathfinding (path.go, point.go). [1] [2] [3]
  • Introduced a pathfinder struct to manage pathfinding state and optimized state acquisition and release using a sync pool (path.go). [1] [2]
  • Replaced map-based edge storage with intmap for better performance and reduced memory usage (path.go). [1] [2]

Benchmark and Test Updates:

  • Updated benchmarks to reflect the performance improvements and added new benchmark results (path_test.go). [1] [2] [3]
  • Modified test cases to accommodate changes in pathfinding logic and added debug output for path visualization (path_test.go). [1] [2]

Dependency Update:

  • Added github.com/kelindar/intmap dependency to the go.mod file.

@kelindar kelindar merged commit 7a879cf into master Nov 12, 2024
2 of 4 checks passed
@kelindar kelindar deleted the pathfinding-v2 branch November 12, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant