Loading video player…

Mazes in Python: Build and Visualize

If you’re up for a little challenge and would like to take your programming skills to the next level, then you’ve come to the right place! In this hands-on video course, you’ll practice object-oriented programming, among several other good practices, while building a cool maze solver project in Python.

You’ll go step by step through the guided process of building a complete and working project. This will include reading a maze from a binary file, visualizing it using scalable vector graphics (SVG), and finding the shortest path from the entrance to the exit.

In this video course, you’ll learn how to:

  • Use an object-oriented approach to represent the maze in memory
  • Visualize the maze and its solution using scalable vector graphics (SVG)
  • Define a specialized binary file format to store the maze on disk
  • Transform the maze into a traversable weighted graph
  • Use a graph search algorithm in the NetworkX library to find the solution

This is an involved project that will really boost your skills as a Python programmer, and in the end, you won’t have to worry about getting lost in a maze.

You’ll need to use Python 3.10 or later. Also, it might be worth brushing up on the following topics before you dive in:

You don’t need to be an expert in any of these areas to follow along with the video course, as it’ll guide you through the steps involved. In fact, a key aspect of your learning experience will be seeing these features in a practical context.

Note that all the code you’ll see running in the REPL will be using the bpython interpreter, but the code will also work in the standard REPL.

Download

Sample Code (.zip)

37.4 KB
Download

Course Slides (.pdf)

14.7 MB

00:00 Mazes in Python Part 1: Building and Visualizing.

00:07 If you are up for a challenge and would like to take your programming skills to the next level, then you’ve come to the right place. In this two-part video course, you’ll practice object-oriented programming amongst several other good practices while building a maze solver project in Python.

00:23 From reading a maze from a binary file, to visualizing it using scalable vector graphics, to finding the shortest path from the entrance to the exit, you’ll go step by step through the guided process of building a complete and working project. In this part of the course, you’ll learn how to use an object-oriented approach to represent a maze in memory and visualize the maze and its solution using scalable vector graphics.

00:50 In the second part, you’ll define a specialized binary file format to store the maze on disk, transform the maze into a traversable weighted graph, and use graph search algorithms in the NetworkX library to find the solution.

01:05 This course will best suit intermediate Python developers who’d like to practice object-oriented programming while building a cool project. Throughout this tutorial, you’ll be using several features of modern Python, so make sure you’re on Python 3.10 or later.

01:21 In addition, it may be worth brushing up on the topics on-screen before you dive in. Real Python has you covered with all of these, and you’ll find links in the accompanying materials to all of them.

01:31 Or you can use the search tool on the site to find the course you are looking for. But note that you don’t need to be an expert in any of these areas to follow along with the course, as it will guide you through the steps involved. In fact, a key aspect of your learning experience will be seeing these features in a practical context.

01:50 You may then want to take a deeper dive into areas of interest when you’ve seen them in action.

01:56 Any code that you see running in the REPL will be using the bpython interpreter. This is a replacement Python interpreter that offers a number of enhancements, including code highlighting and suggestions.

02:06 But any code you see running on-screen will work in the standard Python REPL, which is typically accessed by typing python or python3 at your terminal or command-line prompt. At the end of this two-part course, you’ll have a command-line maze solver that can load your maze from a binary file and show the solution in a web browser.

02:35 You’ll also learn how to build your own mazes from scratch and save them on disk. So now you know what’s going to be covered, let’s get started.

Become a Member to join the conversation.