From 3dcdb892ab6553660675d8648645f288e13892a1 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 21 Dec 2024 21:23:08 -0500 Subject: [PATCH] refactor: remove many transposition entry fields seemingly having a smaller transposition table entry makes the engine way faster (for example, position startpos - go now gets a depth of 6 compared to 5 before) --- src/search.rs | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/search.rs b/src/search.rs index 4b0b54e..43df4c5 100644 --- a/src/search.rs +++ b/src/search.rs @@ -138,17 +138,13 @@ fn lvv_mva_eval(src_pc: Piece, cap_pc: Piece) -> EvalInt { } /// Assign a priority to a move based on how promising it is. -fn move_priority(board: &mut Board, mv: &Move, state: &mut EngineState) -> EvalInt { +fn move_priority(board: &mut Board, mv: &Move) -> EvalInt { // move eval let mut eval: EvalInt = 0; let src_pc = board.get_piece(mv.src).unwrap(); let anti_mv = mv.make(board); - if state.config.enable_trans_table { - if let Some(entry) = &state.cache[board.zobrist] { - eval = entry.eval.into(); - } - } else if let Some(cap_pc) = anti_mv.cap { + if let Some(cap_pc) = anti_mv.cap { // least valuable victim, most valuable attacker eval += lvv_mva_eval(src_pc.into(), cap_pc) } @@ -239,19 +235,15 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec>() .into_iter() - .map(|mv| (move_priority(board, &mv, state), mv)) + .map(|mv| (move_priority(board, &mv), mv)) .collect(); // get transposition table entry if state.config.enable_trans_table { if let Some(entry) = &state.cache[board.zobrist] { - if entry.is_qsearch == mm.quiesce && entry.depth >= mm.depth { - if let SearchEval::Exact(_) | SearchEval::Upper(_) = entry.eval { - // no point looking for a better move - return (vec![entry.best_move], entry.eval); - } + if (entry.depth & 0x80 > 0) == mm.quiesce && (entry.depth & !0x80) >= (mm.depth as u8) { + mvs.push((EVAL_BEST, entry.best_mv)) } - mvs.push((EVAL_BEST, entry.best_move)); } } @@ -336,10 +328,8 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec (Vec;