+ README.md
This commit is contained in:
76
README.md
Normal file
76
README.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# go-maze
|
||||
|
||||
Tiny Go maze library I built for fun.
|
||||
|
||||
It generates random mazes, can solve them, and can render PNGs.
|
||||
|
||||
## What it does
|
||||
|
||||
- Generate a maze grid (`0 = wall`, `1 = walkable`)
|
||||
- Solve a maze (top entrance -> bottom exit)
|
||||
- Render mazes as images
|
||||
- Optionally highlight the solution path
|
||||
|
||||
## Upcoming Features
|
||||
|
||||
- [ ] Add the posibiltiy for entrance/exit to be on the left/right walls
|
||||
- [ ] Add the posiblity of choice when it comes to which position to put the entrance or the exit
|
||||
- [ ] Add complex maze shapes, such as L, U, etc...
|
||||
|
||||
## Example images
|
||||
|
||||
Normal maze:
|
||||
|
||||

|
||||
|
||||
Maze with solution path:
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
go get tea.chunkbyte.com/kato/go-maze@latest
|
||||
```
|
||||
|
||||
If this is private on your Gitea, set:
|
||||
|
||||
```bash
|
||||
go env -w GOPRIVATE=tea.chunkbyte.com # You need to do this
|
||||
git config --global url."ssh://git@tea.chunkbyte.com:2422/".insteadOf "https://tea.chunkbyte.com/" # Optional
|
||||
```
|
||||
|
||||
## Use in code
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
maze "tea.chunkbyte.com/kato/go-maze/maze"
|
||||
)
|
||||
|
||||
func main() {
|
||||
grid, err := maze.GenerateWithSeed(41, 41, 42)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
opts := maze.DefaultRenderOptions()
|
||||
opts.Scale = 8
|
||||
opts.HighlightPath = true
|
||||
|
||||
if err := maze.SavePNG(grid, "maze.png", opts); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Run the web example
|
||||
|
||||
```bash
|
||||
go run ./examples/web
|
||||
```
|
||||
|
||||
Then open `http://localhost:8080`.
|
||||
Reference in New Issue
Block a user