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

View File

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

View File

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