Inspired by Clement Mihailescu's Pathfinding Algorithm Visualizer.