Skip to content

GoMaze is a simple maze generator and solver written in Go.

License

Notifications You must be signed in to change notification settings

cheina97/GoMaze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoMaze

GoMaze is a simple maze generator and solver written in Go. It randomly generate the maze and uses Dijkstra algorithm to find the minimum path between 2 points.

The library used to render the maze and manage inputs is ebitengine, a simple 2D game engine written in Go. The minimum path is calculated using the graph library.

How to use

How to run

go run cmd/main.go 
Flags:
-h int
    height of the maze (cells number) (default 20)
-w int
    width of the maze (cells number) (default 20) 

How to play

  • Click on the maze with the left mouse button to set the start and the ending point.
  • Press R on the keyboard to generate a new maze.

How it works

To find the minimum path between 2 points, the program uses the Dijkstra algorithm. Every walkable cell of the matrix (representing the maze), have been added to a graph. The weight of the edges is the distance between 2 cells, which is always 1. The algorithm will find the shortest path between the 2 points by exploring the graph.

This is an example of the generated graph: