Implemented a-star pathfinding algorithm.