use std::env::args; use chessly::PerftTestCase; const PERF_FILE_PATH: &str = "tests/perfsuite.epd"; const MAX_DEPTH: u8 = 6; fn main() { let n = args() .nth(1) .map(|n| n.parse::().expect("Invalid perft number")); let perf_data = std::fs::read_to_string(PERF_FILE_PATH).expect("Unable to read file"); for (index, case) in perf_data.lines().map(PerftTestCase::try_from).enumerate() { if let Some(n) = n { if index != n { continue; } } let case = case.expect("Invalid test case"); println!("FEN: {}", case.fen); case.run(MAX_DEPTH, |result| { let message = if result.is_ok() { "OK" } else { "FAIL" }; println!( "Depth: {} - {}\t{} ({} ms)", result.depth, result.expected, message, result.duration.as_millis() ); }); } }