diff --git a/src/eval.rs b/src/eval.rs index cb23d39..38df8ba 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -509,16 +509,17 @@ mod tests { // expected (signed) value gain of exchange Rook.value(), ), - ( - "8/8/4b3/2kq4/2PKP3/8/8/8 w - - 0 1", - "d5", - Queen.value(), - ), + ("8/8/4b3/2kq4/2PKP3/8/8/8 w - - 0 1", "d5", Queen.value()), ( "r3k2r/1pq2pbp/6p1/p2Qpb2/1N6/2P3P1/PB2PPBP/R3K2R w KQkq - 0 14", "e5", 0, ), + ( + "r3k2r/1pq2pbp/6p1/p3p3/P5b1/2P3P1/1BN1PPBP/R2QK2R b KQkq - 0 14", + "e2", + 0, + ), ]; for (fen, dest, expected) in test_cases { diff --git a/src/movegen.rs b/src/movegen.rs index 612bb34..3ae2ac7 100644 --- a/src/movegen.rs +++ b/src/movegen.rs @@ -1667,25 +1667,23 @@ mod tests { #[test] fn test_capture_movegen() { - let test_cases = [( - // fen - "8/3q4/5N2/8/8/8/8/3K4 w - - 0 1", - // expected moves generated - "f6d7", - ), - ( - "8/8/8/3pP3/2K5/8/8/8 w - d6 0 1", - // holy hell - "e5d6 c4d5", - ), - ( - "8/2q5/3K4/8/8/8/8/8 w - - 0 1", - "d6c7", - ), - ( - "2Q5/3r2R1/2B1PN2/8/3K4/8/8/8 w - - 0 1", - "c6d7 e6d7 c8d7 f6d7 g7d7", - ), + let test_cases = [ + ( + // fen + "8/3q4/5N2/8/8/8/8/3K4 w - - 0 1", + // expected moves generated + "f6d7", + ), + ( + "8/8/8/3pP3/2K5/8/8/8 w - d6 0 1", + // holy hell + "e5d6 c4d5", + ), + ("8/2q5/3K4/8/8/8/8/8 w - - 0 1", "d6c7"), + ( + "2Q5/3r2R1/2B1PN2/8/3K4/8/8/8 w - - 0 1", + "c6d7 e6d7 c8d7 f6d7 g7d7", + ), ]; for (fen, expected) in test_cases { diff --git a/src/prelude.rs b/src/prelude.rs index c57bbbe..d9831e8 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -23,5 +23,5 @@ pub use crate::search::{ best_line, best_move, EngineState, SearchConfig, SearchEval, TimeLimits, TranspositionTable, }; pub use crate::{ - Board, ColPiece, Color, Piece, BOARD_HEIGHT, BOARD_WIDTH, N_COLORS, N_PIECES, N_SQUARES, Square, + Board, ColPiece, Color, Piece, Square, BOARD_HEIGHT, BOARD_WIDTH, N_COLORS, N_PIECES, N_SQUARES, }; diff --git a/src/search.rs b/src/search.rs index c027e04..dd0ee89 100644 --- a/src/search.rs +++ b/src/search.rs @@ -122,9 +122,8 @@ impl Default for SearchConfig { fn default() -> Self { SearchConfig { alpha_beta_on: true, - // try to make this even to be more conservative and avoid horizon problem depth: 10, - qdepth: 2, + qdepth: 4, enable_trans_table: true, transposition_size: 24, } @@ -209,13 +208,20 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec = None; + + if mm.quiesce { + board_eval = Some(board.eval() * EvalInt::from(board.turn.sign())); + } + if mm.depth == 0 { - if mm.quiesce || board.recap_sq.is_none() { - // if we're done with quiescence, static eval. - // if there is no capture, skip straight to static eval. - let eval = board.eval() * EvalInt::from(board.turn.sign()); - return (Vec::new(), SearchEval::Exact(eval)); + if mm.quiesce { + // we hit the limit on quiescence depth + return (Vec::new(), SearchEval::Exact(board_eval.unwrap())); } else { + // enter quiescence search return minmax( board, state, @@ -261,11 +267,15 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec = None; let mut best_continuation: Vec = Vec::new(); - let n_non_qmoves = mvs.len(); - // determine moves that are allowed in quiescence if mm.quiesce { // use static exchange evaluation to prune moves @@ -276,7 +286,11 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec (Vec