PathFinding.js is a grid-based pathfinding library that implements multiple search algorithms for computing optimal routes on 2D maps. It provides implementations of A*, Dijkstra, Breadth-First Search, and Jump Point Search, each designed to find the shortest path between two points on a grid while avoiding obstacles.
The library is built around a pluggable architecture where each pathfinding strategy shares a common interface, allowing algorithms to be selected at runtime without modifying core logic. It includes a configurable diagonal movement rule engine that controls diagonal traversal based on adjacent obstacle counts, and supports heuristic-driven search to balance optimality and performance. Jump Point Search optimization is available for uniform-cost grids, pruning symmetric paths to reduce node expansions in open areas.
The system represents the search space as a 2D grid of walkable and blocked cells, with support for defining obstacles at individual coordinates or across entire matrices. It offers algorithm selection from multiple strategies, diagonal movement control with configurable rules, movement restriction to cardinal directions only, and grid cloning to preserve original maps after pathfinding operations. Node pooling is used to reuse objects across searches, reducing memory allocation overhead in repeated calls.