|
@@ -30,7 +30,7 @@ pub enum SearchResult {
|
|
/**
|
|
/**
|
|
* searches for moves and returns the best move found plus its value
|
|
* searches for moves and returns the best move found plus its value
|
|
*/
|
|
*/
|
|
-pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, depth: i32) -> SearchResult {
|
|
|
|
|
|
+pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha: PosValue, beta: PosValue, depth: i32) -> SearchResult {
|
|
if depth == 0 {
|
|
if depth == 0 {
|
|
return SearchResult::Invalid;
|
|
return SearchResult::Invalid;
|
|
}
|
|
}
|
|
@@ -41,8 +41,8 @@ pub fn search(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, depth:
|
|
|
|
|
|
info!("moves: {:?}", moves.iter().map(|mv| mv.to_string()).collect::<Vec<String>>());
|
|
info!("moves: {:?}", moves.iter().map(|mv| mv.to_string()).collect::<Vec<String>>());
|
|
|
|
|
|
- let mut alpha: PosValue = MIN_VALUE;
|
|
|
|
- let mut beta: PosValue = MAX_VALUE;
|
|
|
|
|
|
+ //let mut alpha: PosValue = MIN_VALUE;
|
|
|
|
+ //let mut beta: PosValue = MAX_VALUE;
|
|
|
|
|
|
// use a slight offset for the alpha value in the root node in order to
|
|
// use a slight offset for the alpha value in the root node in order to
|
|
// determine possibly multiple good moves
|
|
// determine possibly multiple good moves
|
|
@@ -175,9 +175,14 @@ fn negamax(game: &mut Game, sc: &mut SearchControl, hash: &mut Cache, mut alpha:
|
|
let nmov = Move::Nullmove;
|
|
let nmov = Move::Nullmove;
|
|
let undo = game.apply(nmov);
|
|
let undo = game.apply(nmov);
|
|
|
|
|
|
- let (mut val, ret) = negamax(game, sc, hash, -beta, -alpha, depth / 2 - 2);
|
|
|
|
|
|
+ let (mut val, ret) = negamax(game, sc, hash, -beta, -alpha, depth / 2 - 1);
|
|
val = -val;
|
|
val = -val;
|
|
val = increase_mate_in(val);
|
|
val = increase_mate_in(val);
|
|
|
|
+
|
|
|
|
+ if ret {
|
|
|
|
+ game.undo_move(undo);
|
|
|
|
+ return (alpha, ret)
|
|
|
|
+ }
|
|
|
|
|
|
if val >= beta {
|
|
if val >= beta {
|
|
game.undo_move(undo);
|
|
game.undo_move(undo);
|