Make history heuristic param optional on move ordering to avoid allocating space in q search
This commit is contained in:
@@ -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),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user