aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-28 01:01:15 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-28 01:01:15 +0300
commit70315e4652bb49981108a9b920b95ab82a53edb7 (patch)
treef0bb316ebd5fface6f01aa164bf29afd7e4d6495 /src/main.rs
parent690af97aa6c49a8ad76e47a2cee0c0b23b84ae6e (diff)
downloadchessnost-70315e4652bb49981108a9b920b95ab82a53edb7.tar.gz
feat: interactively play in main loop
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 3e8e461..cc087b6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,19 +1,33 @@
use std::{f32::INFINITY, time::{Duration, Instant}};
-use chessnost::board::Board;
+use chessnost::board::{Board, Color};
fn main() {
- let mut board = Board::new();
+ let fen = String::from("5k2/p2Q4/2p5/4q3/8/2P2Pp1/PP4P1/1K3N2 w - - 1 29");
+ let mut board = Board::from_FEN(fen);
+
+ board.print();
loop {
+ let mov = match board.read_move() {
+ Ok(m) => m,
+ Err(e) => {
+ println!("Error: {}", e);
+ continue;
+ }
+ };
+ print!("{:?}", mov);
+ board.make_move(mov);
+ board.print();
+
let start = Instant::now();
- let (score, pv) = board.iterative_deepening(Duration::from_secs(4));
+ let (score, pv) = board.iterative_deepening(10, Duration::from_secs(10));
println!("Finished in {:?}: score={:?}", start.elapsed(), score);
let mov = pv[0];
println!("{:?}", mov);
board.make_move(mov);
board.print();
- println!("Score for {:?} is now: {} (material advantage={})", board.color(), board.quiscence(-INFINITY, INFINITY), board.material_advantage());
+ println!("Score for {:?} is now: {}", board.color(), board.quiscence(-INFINITY, INFINITY));
}
}