tune: only push history for real moves
This commit is contained in:
parent
955c9f1f5e
commit
e06d614885
@ -628,6 +628,11 @@ impl Board {
|
|||||||
Board::from_fen(START_POSITION).unwrap()
|
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.
|
/// Get iterator over all squares.
|
||||||
pub fn squares() -> impl Iterator<Item = Square> {
|
pub fn squares() -> impl Iterator<Item = Square> {
|
||||||
(0..N_SQUARES).map(Square::try_from).map(|x| x.unwrap())
|
(0..N_SQUARES).map(Square::try_from).map(|x| x.unwrap())
|
||||||
|
@ -64,6 +64,7 @@ fn cmd_position_moves(mut tokens: std::str::SplitWhitespace<'_>, mut board: Boar
|
|||||||
for mv in tokens.by_ref() {
|
for mv in tokens.by_ref() {
|
||||||
let mv = Move::from_uci_algebraic(mv).unwrap();
|
let mv = Move::from_uci_algebraic(mv).unwrap();
|
||||||
let _ = mv.make(&mut board);
|
let _ = mv.make(&mut board);
|
||||||
|
board.push_history();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => ignore!(),
|
_ => ignore!(),
|
||||||
|
@ -98,8 +98,6 @@ pub struct AntiMove {
|
|||||||
impl AntiMove {
|
impl AntiMove {
|
||||||
/// Undo the move.
|
/// Undo the move.
|
||||||
pub fn unmake(self, pos: &mut Board) {
|
pub fn unmake(self, pos: &mut Board) {
|
||||||
pos.history.pop();
|
|
||||||
|
|
||||||
Zobrist::toggle_board_info(pos);
|
Zobrist::toggle_board_info(pos);
|
||||||
|
|
||||||
pos.move_piece(self.dest, self.src);
|
pos.move_piece(self.dest, self.src);
|
||||||
@ -186,8 +184,6 @@ impl Move {
|
|||||||
ep_square: pos.ep_square,
|
ep_square: pos.ep_square,
|
||||||
};
|
};
|
||||||
|
|
||||||
pos.history.push(pos.zobrist);
|
|
||||||
|
|
||||||
// undo hashes (we will update them at the end of this function)
|
// undo hashes (we will update them at the end of this function)
|
||||||
Zobrist::toggle_board_info(pos);
|
Zobrist::toggle_board_info(pos);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user