Skip to content

Commit

Permalink
chore: add UPDATE_HASH option to after_move
Browse files Browse the repository at this point in the history
  • Loading branch information
raklaptudirm committed May 26, 2024
1 parent 8669242 commit 67f6463
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ataxx/src/perft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn perft<const SPLIT: bool, const BULK: bool>(position: Position, depth: u8)
let movelist = position.generate_moves();

for m in movelist {
let new_position = position.after_move(m);
let new_position = position.after_move::<false>(m);

// Spilt should always be disabled for child perft calls, and a child perft
// should have the same bulk counting behavior as the parent perft call.
Expand Down
10 changes: 7 additions & 3 deletions ataxx/src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ impl Position {
///
/// assert_eq!(pos.after_move(mov).checksum, new_pos.checksum);
/// ```
pub fn after_move(&self, m: Move) -> Position {
pub fn after_move<const UPDATE_HASH: bool>(&self, m: Move) -> Position {
let stm = self.side_to_move;

// A pass move is a do nothing move; just change the side to move.
if m == Move::PASS {
return Position {
bitboards: self.bitboards,
checksum: !self.checksum,
checksum: if UPDATE_HASH { !self.checksum } else { Hash(0) },
side_to_move: !self.side_to_move,
ply_count: self.ply_count + 1,
half_move_clock: self.half_move_clock + 1,
Expand Down Expand Up @@ -269,7 +269,11 @@ impl Position {

Position {
bitboards: [black, white, self.bitboard(Piece::Block)],
checksum: Hash::new(black, white, !stm),
checksum: if UPDATE_HASH {
Hash::new(black, white, !stm)
} else {
Hash(0)
},
side_to_move: !stm,
ply_count: self.ply_count + 1,
half_move_clock,
Expand Down

0 comments on commit 67f6463

Please sign in to comment.