aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grossmeister/UCI.rs6
-rw-r--r--src/grossmeister/search.rs14
2 files changed, 16 insertions, 4 deletions
diff --git a/src/grossmeister/UCI.rs b/src/grossmeister/UCI.rs
index 50af980..6f6556c 100644
--- a/src/grossmeister/UCI.rs
+++ b/src/grossmeister/UCI.rs
@@ -14,14 +14,14 @@ impl Grossmeister {
loop {
let mut cmd = String::new();
stdin().read_line(&mut cmd).unwrap();
- let tokens = cmd.trim().split(' ');
- if !self.parse_command(tokens, &mut search_handle) {
+ if !self.parse_command(cmd, &mut search_handle) {
break
}
}
}
- pub fn parse_command(&mut self, mut tokens: Split<char>, search_handle: &mut Option<JoinHandle<Self>>) -> bool {
+ pub fn parse_command(&mut self, cmd: String, search_handle: &mut Option<JoinHandle<Self>>) -> bool {
+ let mut tokens = cmd.trim().split(' ');
if let Some(token) = tokens.next() {
match token {
"uci" => {
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs
index 4a9e5a2..485e4d3 100644
--- a/src/grossmeister/search.rs
+++ b/src/grossmeister/search.rs
@@ -324,7 +324,7 @@ impl Grossmeister {
pub fn iterative_deepening(&mut self, max_depth: u8) -> (Score, Vec<Move>) {
let mut best_score = 0.0;
let mut pv = Vec::new();
- let mut depth = 0;
+ let mut depth = 1;
while depth <= max_depth {
let score = self.negamax_search(-INFINITY, INFINITY, depth, 0);
@@ -573,4 +573,16 @@ mod tests {
dbg!(score, pv);
assert!(score <= 0.0);
}
+
+ #[test]
+ fn broken_position() {
+ let board = Board::new();
+ let mut gm = Grossmeister::new(board);
+
+ gm.parse_command(String::from("position startpos moves e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5c6 d7c6 b1c3 c8g4 d2d3 g8f6 h2h3 g4f3 d1f3 f8b4 c1g5 b4c3 b2c3 d8e7 d3d4 e7e6 g5f6 g7f6 e1c1 e8c8 c1b2 h8g8 h1g1 b7b6 d4d5 c6d5 e4d5 e6d7 f3f6 d7b5 b2c1 d8d5 g2g4 b5c4 f6f5 c8b7 d1d5 c4d5 f5h7 g8d8 c1b2 d5b5 b2c1 b5e2 h7f5 d8d2 f2f3 d2c2 f5c2"), &mut None);
+ gm.board.print();
+ let (score, pv) = gm.iterative_deepening(8);
+ assert!(score.abs() <= 10_000.0);
+ assert!(!pv.is_empty())
+ }
}