Solving Mazes in Python: Depth-First Search, Breadth-First Search, & A*

Опубликовано: 06 Август 2026
на канале: David Kopec
31,088
715

We will develop code to generate simple mazes in Python and find paths in them to navigate from a starting node to a goal node. Along the way, we will learn the fundamental search algorithms depth-first search, breadth-first search, and A*. To support these algorithms, we will also learn the stack, queue, and priority queue data structures.

The examples are from chapter 2 of Classic Computer Science Problems in Python.
https://amzn.to/3i9Olf8

All of the code is available in the chapter 2 folder of the Classic Computer Science Problems in Python GitHub repository.
https://github.com/davecom/ClassicCom...

The Maze Solving GUI is also available on GitHub.
https://github.com/davecom/MazeSolvin...

I made a small mistake in the explanation of A*, I meant to say the explored dictionary is storing the g(n) so far, not the f(n). Sorry!

Follow me on Twitter
  / davekopec  

Find out more about the Classic Computer Science Problems series, including the books in Java and Swift
https://classicproblems.com