diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 95e60b8..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -maze.png \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff26ee9 --- /dev/null +++ b/README.md @@ -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: + +![Normal maze](docs/images/maze.png) + +Maze with solution path: + +![Solved maze](docs/images/maze_solved.png) + +## 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`. \ No newline at end of file diff --git a/docs/images/maze.png b/docs/images/maze.png new file mode 100644 index 0000000..a364681 Binary files /dev/null and b/docs/images/maze.png differ diff --git a/docs/images/maze_solved.png b/docs/images/maze_solved.png new file mode 100644 index 0000000..f2b1bcc Binary files /dev/null and b/docs/images/maze_solved.png differ