Deep dive into how each pathfinding and maze generation algorithm works. Expand any card to see pseudocode, step-by-step walkthroughs, and key insights.
Explores level by level like ripples in water. Guarantees the shortest path on unweighted graphs.
BFS guarantees the shortest path on unweighted graphs because it processes ALL nodes at distance d before any at distance d+1.
๐ฎ 3D Visual: Expands outward as a concentric wave โ nodes rise in circular rings from the start node.
Try itDives as deep as possible before backtracking. Fast but does NOT guarantee the shortest path.
DFS explores one branch completely before trying another. This makes it fast for checking reachability but unreliable for finding shortest paths.
๐ฎ 3D Visual: Snakes through the grid as a long winding path โ nodes rise in a single-file chain.
Try itFinds the shortest path in weighted graphs. The generalization of BFS for edges with different costs.
Dijkstra always processes the globally closest unvisited node. This greedy choice is provably optimal because edge weights are non-negative.
๐ฎ 3D Visual: Similar to BFS on unweighted grids. On weighted grids, the wave avoids heavy nodes โ you see it flowing around weighted areas.
Try itThe gold standard for pathfinding. Combines Dijkstra with a heuristic to visit dramatically fewer nodes.
A* is optimal because its heuristic (Manhattan distance) is admissible โ it never overestimates. This means A* will never skip over the true shortest path.
๐ฎ 3D Visual: A directed beam shoots toward the target, expanding only in the direction of the goal. Far fewer nodes visited than BFS or Dijkstra.
Try itOnly considers the heuristic โ extremely fast but does NOT guarantee the shortest path.
Greedy BFS shows the tradeoff between speed and optimality. It's the fastest heuristic search but can be "tricked" by walls into long detours.
๐ฎ 3D Visual: A laser beam โ even more directional than A*, but the resulting path may not be shortest.
Try itSearches from both start AND end simultaneously. Two waves collide in the middle.
Two small search circles cover less area than one large circle. Bidirectional BFS roughly halves the number of nodes explored.
๐ฎ 3D Visual: Two expanding waves โ one cyan from start, one red from end โ colliding in the middle. The most visually spectacular animation.
Try itDivides space into chambers by placing walls with single passages. Creates structured, room-like mazes.
Orientation choice based on aspect ratio prevents long, narrow corridors and creates balanced mazes.
๐ฎ 3D Visual: Walls appear as horizontal and vertical lines that progressively subdivide the grid into smaller chambers.
DFS-based corridor carving. Creates long, winding passages with few dead ends.
Moving 2 cells at a time ensures walls remain between passages, creating the classic "perfect maze" pattern.
๐ฎ 3D Visual: A single path snakes through the grid, carving corridors and backtracking from dead ends.
Grows the maze outward from a seed. Creates mazes with many short dead ends.
Random frontier selection creates organic-looking mazes. The more walls in the frontier, the more branching occurs.
๐ฎ 3D Visual: Passages radiate outward from a seed point, branching in all directions like a growing tree.
Joins random disjoint sets using Union-Find. Creates uniform, unbiased mazes.
Union-Find ensures no cycles: walls are only removed between disconnected regions. The result is a spanning tree of the grid graph.
๐ฎ 3D Visual: Walls disappear at random positions across the grid simultaneously, gradually connecting all regions.