fix: board not same after running minmax
caused by an early return from hard stop that bypasses unmake move
This commit is contained in:
parent
4bd2fd1d9a
commit
a47778ae6c
@ -363,6 +363,7 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec<M
|
|||||||
quiesce: mm.quiesce,
|
quiesce: mm.quiesce,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
anti_mv.unmake(board);
|
||||||
|
|
||||||
// propagate hard stops
|
// propagate hard stops
|
||||||
if matches!(score, SearchEval::Stopped) {
|
if matches!(score, SearchEval::Stopped) {
|
||||||
@ -376,7 +377,6 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec<M
|
|||||||
best_continuation = continuation;
|
best_continuation = continuation;
|
||||||
}
|
}
|
||||||
alpha = max(alpha, abs_best.into());
|
alpha = max(alpha, abs_best.into());
|
||||||
anti_mv.unmake(board);
|
|
||||||
if alpha >= beta && state.config.alpha_beta_on {
|
if alpha >= beta && state.config.alpha_beta_on {
|
||||||
// alpha-beta prune.
|
// alpha-beta prune.
|
||||||
//
|
//
|
||||||
@ -596,3 +596,30 @@ pub fn is_quiescent_position(board: &Board, eval: SearchEval) -> bool {
|
|||||||
|
|
||||||
(board.eval() - EvalInt::from(abs_eval)).abs() <= THRESHOLD.abs()
|
(board.eval() - EvalInt::from(abs_eval)).abs() <= THRESHOLD.abs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Test that running minmax does not alter the board.
|
||||||
|
#[test]
|
||||||
|
fn test_board_same() {
|
||||||
|
let (_tx, rx) = mpsc::channel();
|
||||||
|
let cache = TranspositionTable::new(1);
|
||||||
|
let mut engine_state = EngineState::new(
|
||||||
|
SearchConfig {
|
||||||
|
depth: 3,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
rx,
|
||||||
|
cache,
|
||||||
|
TimeLimits::from_movetime(20),
|
||||||
|
);
|
||||||
|
let mut board =
|
||||||
|
Board::from_fen("2rq1rk1/pp1bbppp/3p4/4p1B1/2B1P1n1/1PN5/P1PQ1PPP/R3K2R w KQ - 1 14")
|
||||||
|
.unwrap();
|
||||||
|
let orig_board = board;
|
||||||
|
let (_line, _eval) = best_line(&mut board, &mut engine_state);
|
||||||
|
assert_eq!(board, orig_board)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user