liveBook · Manning

Maze

As explained in Learn Go with Pocket-Sized Projects

A maze is a spatial puzzle consisting of connected and obstructed routes arranged so that a path must be found between designated locations.

A maze is a grid of walls and paths with an entrance and a treasure. Solving it means finding adjacent positions that connect those two locations without teleportation. section 9.1

A practical maze representation can encode:

  • Walls, paths, the entrance, and the treasure as pixel colors. section 9.1
  • The entrance at one coordinate and the treasure either at an edge or inside the maze. section 9.1
  • Four possible neighbors for each position: above, below, right, and left. section 9.3.1
  • A loop-free structure with exactly one path from the entrance to each reachable point. section 9.1.2

Concurrent maze solving

A solver opens a PNG maze, locates the entrance by scanning for its palette color, explores branches concurrently with goroutines, and writes an image highlighting the path to the treasure. It can also generate a GIF of the exploration. section 9.0 section 9.3.1

Figure 9.1 Example of a small maze with a treasure (exit) on the edge
A black and white maze

    Description automatically generated

Use the small-maze figure to compare a treasure on the edge with the grid structure and route-finding goal. section 9.1

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains grid encoding, constraints, neighbor discovery, entrance scanning, concurrent exploration, and focused tests.
Examples
Demonstrates edge and internal treasures, colored PNG grids, dead ends, branches, crosses, and small exploration test images.
What it assumes
Assumes enough Go knowledge to implement a generator and introduces maze structure, image encoding, coordinates, and path adjacency.
What you can do after
Build a Go command-line solver that reads a PNG maze, finds its solution, highlights the route, and optionally creates an exploration GIF.
How it connects
Connects maze solving with graph theory, goroutines, channels, PNG images, RGBA colors, and linked lists.

Also explained in

Compare how 2 books explain maze →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.