Skip to main content

demo3/
demo3.rs

1use stockfish::Stockfish;
2
3fn main() -> Result<(), std::io::Error> {
4    let path = if cfg!(target_os = "windows") {
5        "./stockfish.exe"
6    } else {
7        "stockfish"
8    };
9
10    let mut stockfish = Stockfish::new(&path)?;
11    stockfish.setup_for_new_game()?;
12    stockfish.print_board()?;
13
14    let engine_output = stockfish.go_based_on_times(Some(50000), Some(10))?;
15    println!("engine_output: {engine_output:?}");
16
17    let fen = "r1bqkb1r/pppp1ppp/2n2n2/4p3/4P3/2N2N2/PPPP1PPP/R1BQKB1R w KQkq - 0 1";
18
19    stockfish.set_fen_position(fen)?;
20
21    assert_eq!(fen, stockfish.get_fen()?);
22
23    // Testing
24    let moves = ["e2e4", "e7e5", "f1c4"];
25    stockfish.play_moves(&moves)?;
26    //
27
28    Ok(())
29}