1 unstable release

0.0.0 Mar 26, 2023

#4 in #tour

MPL-2.0 license

17KB
377 lines

Basic

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);
    }
}

Advanced

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();
    }
}

Dependencies

~1MB
~16K SLoC