Maze Generator, Solver, and Exporter
A simple command-line tool written in Rust to generate, solve, and export mazes. It can produce a PNG image of the maze (with solution path overlay) and an optional JSON file describing the maze walls for use in other applications.
Features
- Maze Generation: Uses a depth‑first backtracking algorithm to carve a random maze of customizable size.
- Maze Solving: Generates a solution path in the exported image.
- Image Export: Renders the maze into a PNG image with adjustable cell size and wall thickness.
- JSON Map Export: Outputs a
map.jsonin the format for krunker.io (tested version 7.5.0). - Flexible CLI: Configure width, height, cell size, wall thickness, output paths, or skip JSON generation via flags.
Installation
-
Ensure you have Rust and Cargo installed.
-
Clone this repository:
-
Build the project in release mode:
-
The executable will be in
target/release/krunker-maze-generator.
Usage
Examples
-
Generate a default
100×100maze and export both PNG and JSON: -
Generate a
50×30maze, small cells, thick walls: -
Generate only the PNG (skip JSON):
Using as a Library
-
Add the dependency in your
Cargo.toml:[] = "0.2.1" -
In your code, import and use the
MazeAPI:use Maze; use Path;
JSON Map Format
Contributing
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m "Add feature"). - Push to your branch (
git push origin feature/YourFeature). - Open a pull request.
Please ensure your code is formatted with cargo fmt and linted with cargo clippy.
License
This project is licensed under the MIT License.