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 Format10 min read
Answers
I was originally using the Cinnamon version of Linux Mint 21.3. I heard good things about MATE, so I did a new installation to try out MATE. After several months, I decided that I would like to go back to Cinnamon. I am not sure how to switch back wi
Linux Format2 min read
Suitability For Beginners
These distros are focused on a technical area of computer use, penetration testing, but that doesn’t mean they’re T not suitable for beginners in this discipline. It’s not much of a surprise that a Gentoo-based distro like Pentoo is more complicated
Linux Format11 min read
Enhance Email With A Better Thunderbird
Think email client and the obvious example is Mozilla’s Thunderbird. But whether you’re a T long-time Thunderbird user or looking for a new email client, you may find that Betterbird is – if you’ll excuse the pun – a better fit. That’s particularly t

Related Books & Audiobooks