tune: only push history for real moves

This commit is contained in:
dogeystamp 2024-12-25 17:31:32 -05:00
parent 955c9f1f5e
commit e06d614885
No known key found for this signature in database
3 changed files with 6 additions and 4 deletions

View File

@ -628,6 +628,11 @@ impl Board {
Board::from_fen(START_POSITION).unwrap()
}
/// Save the current position's hash in the history.
pub fn push_history(&mut self) {
self.history.push(self.zobrist);
}
/// Get iterator over all squares.
pub fn squares() -> impl Iterator<Item = Square> {
(0..N_SQUARES).map(Square::try_from).map(|x| x.unwrap())

View File

@ -64,6 +64,7 @@ fn cmd_position_moves(mut tokens: std::str::SplitWhitespace<'_>, mut board: Boar
for mv in tokens.by_ref() {
let mv = Move::from_uci_algebraic(mv).unwrap();
let _ = mv.make(&mut board);
board.push_history();
}
}
_ => ignore!(),

View File

@ -98,8 +98,6 @@ pub struct AntiMove {
impl AntiMove {
/// Undo the move.
pub fn unmake(self, pos: &mut Board) {
pos.history.pop();
Zobrist::toggle_board_info(pos);
pos.move_piece(self.dest, self.src);
@ -186,8 +184,6 @@ impl Move {
ep_square: pos.ep_square,
};
pos.history.push(pos.zobrist);
// undo hashes (we will update them at the end of this function)
Zobrist::toggle_board_info(pos);