Skip to content

wliao008/gaze

Repository files navigation

Gaze

Maze generating library in GoLang

Circle CI

Quickstart

$ cd cmd/gaze
$ go run main.go
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
| |  _  |   |_ _ _ _     _ _  |_ _    | |  _   _ _ _ _ _|   |
| | | |_ _|_ _ _ _  | |_  |  _ _ _ _| |_  | |_ _  |   |  _| |
| | | |  _   _ _ _| |_  | |_|  _  |_ _  |_ _ _  | | | | |  _|
| | | | | |_ _ _ _ _|_ _|_ _ _  |_  | | |   |_  |_ _| | |_  |
|_ _| | |_   _  |_   _ _ _  | | | | |  _| |_  |  _ _|  _| | |
|  _  |_  |_  |_ _ _| |   | |_ _ _| |_  |   | |_|   |_ _ _| |
| | |  _| |  _|  _ _ _ _| |_ _ _ _ _|  _| | |_ _ _|_ _ _ _  |
|_  |_  |_ _| |_ _  |    _ _ _  |   |_  |_| | |    _ _ _|  _|
|  _| | |  _   _ _| | |_|  _  |_| |_ _ _|  _|  _|_ _ _  | | |
|_ _ _|_ _ _|_ _ _ _|_ _ _ _|_ _ _ _ _ _ _|_ _ _ _ _ _|_ _  |

Options

Use params to improve your experience.

  • To set Heigth: -h <SIZE_IN_INTEGER>
  • To set Weigth: -w <SIZE_IN_INTEGER>

Example:

$ go run main.go -h 12 -w 12

   _ _ _ _ _ _ _ _ _ _ _
| |   |  _ _ _ _    |   |
| | | |_ _|  _ _ _|_ _| |
|_ _|_ _ _ _| |  _ _ _ _|
|     |  _ _  |_ _  |_  |
|_| | | |   |_  | |_  | |
|  _|_ _| |  _| |  _| | |
|_  | |  _| |  _ _|  _| |
|   |_ _|  _| | |  _|  _|
| |_|   |_ _ _  | |  _  |
|  _ _|_ _ _  | | | |  _|
| |   |_ _  | |_| |_|_  |
|_ _|_ _ _ _|_ _ _ _ _  |

Benchmarks

Benchmarks ran on the following hardware:

MacBook Pro 2014, OS X 10.9, 2.6 GHz Intel Core i5, 16 GB 1600 MHz DDR3.

Algorithm Size Iterations ns/ops ms/op allocs/op
Backtracking 1000x500 1 5309771223 5309.77 1002
Prim 1000x500 10 118249945 118.24 1055533
DeadEndFiller 1000x500 10 192385091 192.38 2004517

While Prim is an order of magnitude faster, the memory allocations is still room for much improvement.

Development

Terminologies

  1. board: imagine a width by height 2D array, this represents the graphical layout of the maze.
  2. cell: each item in the 2D array is a cell. Imagine a cell in the middle of a board, this cell could open passage(s) to the neighboring cells in any or all 4 of the directions, this is what essentially creates the maze when all the cells are processed.
  3. direction: the 4 directions that a cell could open a passage into.

Algorithms

There are many ways to generate a maze, the algos package will contains all the different implementation. All of them implements the Mazer interface that contains the Generate() method that new algorithm would need to implement.

Solvers

There are also many ways to solve a maze, these are collected in solvers.

Contributing

Pull requests are welcome! You could also open a Github issue to discuss and get feedback first.

License

MIT

Releases

No releases published

Packages

No packages published

Languages