1 个不稳定版本

0.0.0 2023 年 3 月 26 日

#4#tour

MPL-2.0 许可证

17KB
377 代码行

基础

use knights_tour::{ChessRole, Chessboard};

#[test]
fn test_knights_tour() {
    let knights = Chessboard::new(8, 8);
    std::fs::create_dir_all("target/").unwrap();
    for (index, state) in knights.into_iter().take(10).enumerate() {
        println!("{}: {}", index, state);
    }
}

高级

use knights_tour::{ChessRole, Chessboard, SvgRender};

#[test]
fn test_pawns_tour() {
    let knights = Chessboard::new(8, 8).with_role(ChessRole::Pawn).walk(false);
    std::fs::create_dir_all("target/").unwrap();
    for (index, state) in knights.into_iter().take(10).enumerate() {
        let render = SvgRender::default();
        let svg = state.draw_svg(&render);
        let file = format!("target/pawn8x8_{}.svg", index);
        std::fs::write(file, svg).unwrap();
    }
}

依赖项

~1MB
~15K SLoC