Skip to content

Commit

Permalink
get_unchecked in tt and change repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiaha committed Sep 2, 2023
1 parent 5fd70cd commit 51bff28
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,9 @@ impl Board {
self.history[self.ply].half_move_counter(),
) as usize;

self.history[..self.ply]
self.history[self.ply - lookback..self.ply]
.iter()
.rev()
.take(lookback)
.skip(1)
.step_by(2)
.any(|entry| self.material_hash() == entry.material_hash())
Expand Down
2 changes: 1 addition & 1 deletion src/piece.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl fmt::Display for Piece {
}

impl Piece {
pub const N_PIECES: usize = 13;
pub const N_PIECES: usize = 12;
const PIECE_STR: &'static str = "PNBRQK pnbrqk ";
}

Expand Down
13 changes: 10 additions & 3 deletions src/tt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,20 @@ impl TT {

#[inline(always)]
pub fn insert(&self, board: &Board, depth: Depth, value: Value, best_move: Move, flag: Bound) {
self.table[self.index(board)]
.write(board.hash(), TTEntry::new(value, best_move, depth, flag))
unsafe {
self.table
.get_unchecked(self.index(board))
.write(board.hash(), TTEntry::new(value, best_move, depth, flag))
}
}

#[inline(always)]
pub fn probe(&self, board: &Board) -> Option<TTEntry> {
self.table[self.index(board)].read(board.hash())
unsafe {
self.table
.get_unchecked(self.index(board))
.read(board.hash())
}
}

pub fn clear(&mut self) {
Expand Down

0 comments on commit 51bff28

Please sign in to comment.