gomaze

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: Apache-2.0

README

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:

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL