3 个版本 (重大更改)

0.3.0 2019 年 8 月 1 日
0.2.0 2019 年 7 月 6 日
0.1.0 2019 年 7 月 3 日

#3 in #mazes

MIT/Apache

36KB
634 代码行

Minotaur

minotaur 是一个命令行迷宫生成器。

Build Status Cargo Version License: MIT OR Apache-2.0

安装

目前,安装需要 Rust 工具链

crates.io

cargo install minotaur

从源码

$ git clone [email protected]:jonstites/minotaur
$ cd minotaur
$ cargo build --release
$ ./target/release/minotaur --version
minotaur 0.3.0

用法

./target/release/minotaur --help
minotaur 0.3.0
Jonathan Stites <[email protected]>
A command-line program for generating mazes.

USAGE:
    minotaur [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -a, --algorithm <algorithm>
            Maze generating algorithm [default: AldousBroder]  [possible values: BinaryTree,
            Sidewinder, AldousBroder, Wilsons, HuntAndKill, RecursiveBacktracker]
    -x, --width <width>                          Maze width in number of cells [default: 5]
    -y, --height <height>                        Maze height in number of cells [default: 5]
        --background-color <background-color>    Background color when saving to an image file [default: #FFFFFF]
        --cell-size <cell-size>                  Cell size when saving to an image file [default: 10]
    -i, --input <input>                          Input file of ".mz" stored from a previous run
    -o, --output <output>
            Output file. Can be ".png" for an image, ".mz" to store the maze inself for later loading, otherwise, saves
            as ASCII art [default: /dev/stdout]
    -s, --seed <seed>                            Seed for random number generator
        --wall-color <wall-color>                Wall color when saving to an image file [default: #000000]
        --wall-size <wall-size>                  Wall size when saving to an image file [default: 1]

示例

./target/release/minotaur --seed 12345678 -a binarytree
+---+---+---+---+---+
|                   |
+   +   +---+---+   +
|   |   |           |
+---+   +   +---+   +
|       |   |       |
+   +---+   +---+   +
|   |       |       |
+   +   +---+---+   +
|   |   |           |
+---+---+---+---+---+
./target/release/minotaur --seed 12345678 -o examples/maze.png --cell-size 50 --wall-size 5 -a binarytree

Generated maze

基准测试

cargo +nightly bench
   Compiling minotaur v0.3.0 (/home/jonstites/Code/rust/minotaur)
    Finished release [optimized] target(s) in 3.65s
     Running target/release/deps/minotaur-7f054a3c582211a2

running 8 tests
test tests::test_aldous_broder ... ignored
test tests::test_aldous_broder_all_mazes ... ignored
test tests::test_binary_tree ... ignored
test tests::test_hunt_and_kill ... ignored
test tests::test_recursive_backtracker ... ignored
test tests::test_sidewinder ... ignored
test tests::test_wilsons ... ignored
test tests::test_wilsons_all_mazes ... ignored

test result: ok. 0 passed; 0 failed; 8 ignored; 0 measured; 0 filtered out

     Running target/release/deps/minotaur-409fa2e8229853a7

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/release/deps/benches-7671d38865a46d79

running 12 tests
test bench::aldous_broder::generate_100_x_100         ... bench:   8,729,860 ns/iter (+/- 2,127,433)
test bench::aldous_broder::generate_10_x_10           ... bench:      32,356 ns/iter (+/- 1,810)
test bench::binary_tree::generate_100_x_100           ... bench:     127,001 ns/iter (+/- 5,049)
test bench::binary_tree::generate_10_x_10             ... bench:       1,990 ns/iter (+/- 97)
test bench::hunt_and_kill::generate_100_x_100         ... bench:   3,741,404 ns/iter (+/- 224,387)
test bench::hunt_and_kill::generate_10_x_10           ... bench:      31,779 ns/iter (+/- 2,358)
test bench::recursive_backtracker::generate_100_x_100 ... bench:   2,928,601 ns/iter (+/- 305,673)
test bench::recursive_backtracker::generate_10_x_10   ... bench:      27,949 ns/iter (+/- 3,844)
test bench::sidewinder::generate_100_x_100            ... bench:     186,256 ns/iter (+/- 17,789)
test bench::sidewinder::generate_10_x_10              ... bench:       2,595 ns/iter (+/- 121)
test bench::wilsons::generate_100_x_100               ... bench:   8,551,824 ns/iter (+/- 3,229,443)
test bench::wilsons::generate_10_x_10                 ... bench:      57,559 ns/iter (+/- 3,439)

test result: ok. 0 passed; 0 failed; 0 ignored; 12 measured; 0 filtered out

许可

许可协议为以下之一

任选其一。

贡献

除非你明确声明,否则任何有意提交以包含在作品中的贡献,根据 Apache-2.0 许可协议定义,应按上述方式双许可,不得附加任何其他条款或条件。

依赖

~8MB
~124K SLoC