knights-tour

Crates.ioknights-tour
lib.rsknights-tour
version0.0.0
sourcesrc
created_at2023-03-26 02:28:59.76343
updated_at2023-03-26 02:28:59.76343
description...
homepage
repositoryhttps://github.com/oovm/knights-tour
max_upload_size
id820794
size17,295
SasakiSaki (oovm)

documentation

https://docs.rs/knights-tour

README

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();
    }
}
Commit count: 19

cargo fmt