A simple maze solver written in go
Go to file
2023-08-27 19:21:48 +02:00
.github/workflows github action should be working now 2023-08-27 12:42:03 +02:00
assets updated assets 2023-08-27 19:20:14 +02:00
io feat: Implemented visualizer 2023-08-17 13:37:54 +02:00
maze refactor: removed map for visited and added field to node 2023-08-15 15:41:24 +02:00
solver feat: Implemented visualizer 2023-08-17 13:37:54 +02:00
utils Added a logging system to show home much time it 2023-08-10 19:38:43 +02:00
visualizer refactor & feat: moved window visualization to 2023-08-27 11:21:26 +02:00
.gitignore Added files to gitignore 2023-08-14 15:07:10 +02:00
go.mod refactor & feat: moved window visualization to 2023-08-27 11:21:26 +02:00
go.sum refactor & feat: moved window visualization to 2023-08-27 11:21:26 +02:00
main.go fix: readme and arg help messages 2023-08-27 13:23:34 +02:00
README.md updated readme 2023-08-27 19:21:48 +02:00

maze-solver-go

Introduction

This is a simple little maze solver made for fun and practise writing code in golang. This project is a complete re-write of another maze solver I've written in Java back in 2018 after the first semester of uni at EPFL. Needless to say, this version is way better as I have written it now that I have my Bachelor's degree in Computer Science.

Goal of the project

The goal of this side project was to deepen my understanding of path-finding algorithms, together with trying to create a good design, focusing on dependency injection and unit testing. It was very instructive.

Not to brag or anything, but the design was quite good, because after completing the following steps of the project:

  • reading a maze;
  • solving it;
  • writing the solution to the file-system;

an idea came to my mind: add the feature of visualizing the progress of the solving algorithm by opening a window that displays the progress of the solver. Well, each module (readers, writers and solvers) were design to be as decoupled as possible, and it allowed me to implement the visualizer feature in only a couple of hours (which I was honestly not expecting).

Dependencies

Usage

After downloading maze-solver from the assets of the latest release, you can use it with the following arguments

Short Long Default Description
-h --help Print help information
-v --verbose 0 Verbose level of the solver, see verbose levels
-i --input maze.png Input file, can be a .txt or .png file
-o --output sol.png Output file, can be a .txt or .png file
--path-char-in ' ' Character to represent the path in an input text file.
--wall-char-in '#' Character to represent the wall in an input text file.
--path-char-out ' ' Character to represent the path in an output text file.
--wall-char-out '#' Character to represent the wall in an output text file.
--cell-size-in 3 Size of a cell (in pixels) for input file of image type.
--cell-size-out 3 Size of a cell (in pixels) for output file of image type.
-a --algo a-star Algorithm to solve the maze, see solving algorithms
--visualize Visualizer the progress of the solver, see visualization methods
--video-name sol.mp4 Name of the output file if --visualize is set to 'video'.
--video-framerate 60 Framerate of the video if --visualize is set to 'video'.

Verbose levels

Level Description
0 nothing printed to stdout
1 print the total time taken by the solver (time of the main() function)
2 prints the time the solving algorithm took to run
3 prints the time taken by each section (reader, solving algorithm, writer)

Visualization methods

Option Description
window will give a live feed of the solver
video creates a video where each frame is a step the solving algorithm takes

Solving algorithms

Option Description
dfs Depth-first search
bfs Breadth-first search
dijkstra Dijkstra's algorithm
a-star A*

Examples

BFS DFS
bfs dfs
disjkstra a-star
Dijkstra A*