Coding the A* pathfinding algorithm