|
@@ -93,6 +93,8 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alp
|
|
|
let undo = game.apply(mov);
|
|
|
|
|
|
let val = -negamax(game, sc, hash, decrease_mate_in(-beta), decrease_mate_in(-alpha), depth - 1);
|
|
|
+
|
|
|
+ //info!("moveval {} -> {}\n", mov.to_string(), val);
|
|
|
|
|
|
game.undo_move(undo);
|
|
|
|
|
@@ -119,7 +121,7 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alp
|
|
|
return SearchResult::Cancelled(Some((chosen_mov.0, -chosen_mov.1)));
|
|
|
}
|
|
|
else {
|
|
|
- hash.cache(game, CacheEntry::new_value(depth, chosen_mov.1));
|
|
|
+ hash.cache(game, CacheEntry::new_value(depth, chosen_mov.0, chosen_mov.1));
|
|
|
sc.pv[0] = chosen_mov.0;
|
|
|
return SearchResult::Finished(chosen_mov.0, -chosen_mov.1);
|
|
|
}
|
|
@@ -129,8 +131,9 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alp
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-pub fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha: PosValue, beta: PosValue, depth: i32) -> PosValue {
|
|
|
+pub fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha: PosValue, mut beta: PosValue, depth: i32) -> PosValue {
|
|
|
|
|
|
+ let mut pvmove: Option<Move> = None;
|
|
|
if let Some(e) = hash.lookup(game) {
|
|
|
if e.depth >= depth {
|
|
|
//println!("TABLE HIT!");
|
|
@@ -214,7 +217,6 @@ pub fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut al
|
|
|
|
|
|
let val = -negamax(game, sc, hash, -decrease_mate_in(beta), -decrease_mate_in(alpha), depth - 1);
|
|
|
game.undo_move(undo);
|
|
|
- //val = increase_mate_in(val);
|
|
|
|
|
|
// return if the search has been cancelled
|
|
|
if sc.stopping {
|
|
@@ -222,9 +224,7 @@ pub fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut al
|
|
|
}
|
|
|
|
|
|
if val >= beta {
|
|
|
- hash.cache(game, CacheEntry::new_upper(depth, val));
|
|
|
- //println!("but ret {}: {}", depth, beta);
|
|
|
- //info!("{} causes beta cutoff at {} ", mov.to_string(), val);
|
|
|
+ hash.cache(game, CacheEntry::new_upper(depth, mov, val));
|
|
|
if !mov.is_capture() {
|
|
|
sc.insert_killer(ply_depth, mov);
|
|
|
}
|
|
@@ -239,12 +239,12 @@ pub fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut al
|
|
|
|
|
|
|
|
|
if alpha_is_exact {
|
|
|
- hash.cache(game, CacheEntry::new_value(depth, alpha));
|
|
|
+ hash.cache(game, CacheEntry::new_value(depth, best_move, alpha));
|
|
|
let cur_depth = (sc.initial_depth - depth) as usize;
|
|
|
sc.pv[cur_depth] = best_move;
|
|
|
}
|
|
|
else {
|
|
|
- hash.cache(game, CacheEntry::new_lower(depth, alpha));
|
|
|
+ //hash.cache(game, CacheEntry::new_lower(depth, alpha));
|
|
|
}
|
|
|
//info!("best alpha {}", alpha);
|
|
|
return alpha;
|