A* pathfinding implementation in JavaScript