Make history heuristic param optional on move ordering to avoid allocating space in q search

This commit is contained in:
2026-07-15 19:29:48 +03:00
parent edfa430db3
commit cb47cc3c8b
3 changed files with 8 additions and 13 deletions

View File

@@ -11,7 +11,7 @@ pub fn score_move(
mv: Move, mv: Move,
killer_move: Option<Move>, killer_move: Option<Move>,
color: Color, color: Color,
history_heuristic: &[[[i32; 64]; 64]; 2], history_heuristic: Option<&[[[i32; 64]; 64]; 2]>,
tt_move: Option<Move>, tt_move: Option<Move>,
) -> i32 { ) -> i32 {
if Some(mv) == tt_move { if Some(mv) == tt_move {
@@ -30,7 +30,9 @@ pub fn score_move(
return 6; return 6;
} }
-history_heuristic[color][mv.src()][mv.dst()] + MAX_HISTORY + 6 + 1 history_heuristic.map_or(MAX_HISTORY + 6 + 1, |hh| {
-hh[color][mv.src()][mv.dst()] + MAX_HISTORY + 6 + 1
})
} }
#[cfg(test)] #[cfg(test)]
@@ -53,14 +55,7 @@ mod tests {
let mut moves = vec![castle, queen_takes_pawn, pawn_takes_queen]; let mut moves = vec![castle, queen_takes_pawn, pawn_takes_queen];
moves.sort_unstable_by_key(|mv| { moves.sort_unstable_by_key(|mv| {
score_move( score_move(&game.mailbox, *mv, None, game.current_player(), None, None)
&game.mailbox,
*mv,
None,
game.current_player(),
&[[[0; 64]; 64]; 2],
None,
)
}); });
assert_eq!(moves, vec![pawn_takes_queen, queen_takes_pawn, castle]); assert_eq!(moves, vec![pawn_takes_queen, queen_takes_pawn, castle]);
@@ -71,7 +66,7 @@ mod tests {
*mv, *mv,
None, None,
game.current_player(), game.current_player(),
&[[[0; 64]; 64]; 2], None,
Some(castle), Some(castle),
) )
}); });

View File

@@ -101,7 +101,7 @@ pub fn negamax(
*mv, *mv,
game.killer[plies as usize], game.killer[plies as usize],
color, color,
&game.history_heuristic, Some(&game.history_heuristic),
entry.and_then(|entry| entry.mv), entry.and_then(|entry| entry.mv),
) )
}); });

View File

@@ -48,7 +48,7 @@ pub fn quiescence(
*mv, *mv,
None, None,
color, color,
&[[[0; 64]; 64]; 2], None,
entry.and_then(|entry| entry.mv), entry.and_then(|entry| entry.mv),
) )
}); });