Knossos is a Rust library for generating mazes with some basic routines for rendering and saving mazes to files.
In Greek mythology, King Minos dwelt in a palace at Knossos. He hired the Athenian architect, mathematician, and inventor Daedalus to design his palace and so cleverly was it constructed that no one who entered could find their way back out without a guide. In other versions of this same story it was not the palace itself which was designed in this way but the labyrinth within the palace which was built to house the half-man/half-bull the Minotaur. In order to keep Daedalus from telling the secrets of the palace, Minos locked him and his son Icarus in a high tower at Knossos and kept them prisoner. Daedalus fashioned wings made of wax and bird's feathers for himself and his son, however, and escaped their prison but Icarus, flying too close to the sun, melted his wings and fell to his death.
Source: https://www.worldhistory.org/knossos
Knossos currently supports only one type of mazes: orthogonal, which is a standard maze layout of rectangular passages.
The library supports the following generation algorithms:
Knossos supports the following output types:
ASCII Using the ASCII output, you can simply print a maze to the console or write it to a file to see what it looks like
Game map If you're interested in writing your own game with pseudo 3D graphics or just testing your implementation of the ray casting algorithm, you can convert a maze into a game map. Currently, this formatter supports several colors for maze walls that are randomly set: R (red), G (green), B (blue), Y (yellow), and O (orange)
Image Using the Image output, you can render a maze to PNG or JPG (just use the corresponding filename extension). This type of output is highly customizable: it allows you to specify custom margin, wall and passage width, and even background and foreground colors
Add this to your Cargo.toml
no_test
[dependencies]
knossos = "0.1.0"
Knossos is designed to be super easy and convenient to use. Here are some usage examples of how to generate, display and save mazes:
```rust,no_run use knossos::maze::*;
let maze = OrthogonalMazeBuilder::new().build(); ```
```rust,no_run use knossos::maze::*;
let maze = OrthogonalMazeBuilder::new() .height(10) .width(10) .algorithm(Box::new(GrowingTree::new(Method::Random))) .build(); ```
```rust,no_run use knossos::maze::*;
let maze = OrthogonalMazeBuilder::new().build(); println!("{}", &maze); ```
```rust,no_run use knossos::maze::*;
let maze = OrthogonalMazeBuilder::new().build();
// Save as ascii maze.save("output/maze.txt", Ascii).unwrap(); // Save as a game map maze.save("output/mazegamemap.txt", GameMap::new().span(3)).unwrap(); // Save as a PNG image maze.save("output/maze.png", Image::new().wall(10).passage(30)).unwrap(); ```
You can find more examples in src/main.rs