Linux Format

How to solve mazes using Go and maths

This month, we’re going delve into solving maze and dungeon puzzles with the help of graph theory (well, we are all in isolation–Ed). The purpose of such puzzles is to determine whether there’s a path that connects two places and find that path, keeping in mind that not all maze puzzles are solvable!

A maze is a path or a collection of paths. When we say that we want to solve a maze, we mean that we should find a way of going from the start cell (entrance), which is predefined, to the end cell (goal), which is also predefined. A similar way of thinking about solving a maze is routing through obstacles of various types from your current place to a given location. A maze might have multiple solutions, too.

To solve a maze, you just have to find a trail between the start and end points of the maze. Note that mazes can be implemented using undirected graphs and that if a maze contains isolated nodes or too many wall cells then it might not be solvable.

The way you represent a maze has nothing to do with the maze itself – it’s just a practical way of

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format1 min read
Wine For Wayland
2023 was a great year for the Wayland driver for Wine. The goal was to move forward from the experimental phase and make the driver a proper upstream component. A year later, after several merge requests, many people are now already able to use the l
Linux Format5 min read
Run The Microsoft Distro
Despite its easy integration with WSL, in October 2021 Visual Studio Code became the site of a battleground between Microsoft and the open source community. The controversy centred around the release of .NET 6. The tech giant had originally hinted it
Linux Format1 min read
Kaki Pi
Another Pi-like SBPC appears! From Yuridenk-Shokai in Japan, this packs a Renesas RZ/V2H Coretex-A55/R8/M33 MPU with 80 TOPS of AI. It’s aimed at robotics and has four CSI video inputs along with a PCIe 3 connection. Find out more in Japanese: www.ka

Related