Skip to content

Commit

Permalink
some cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiaha committed Aug 17, 2023
1 parent e58e99e commit 38b73e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 11 additions & 15 deletions src/move_sorter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ impl MoveSorter {
return Self::WINNING_CAPTURES_OFFSET;
}

score += Self::mvv_lva_score(board, m);

if Self::see(board, m) {
score += Self::WINNING_CAPTURES_OFFSET;
} else {
score += Self::LOSING_CAPTURES_OFFSET;
}
score += Self::mvv_lva_score(board, m)
+ if Self::see(board, m) {
Self::WINNING_CAPTURES_OFFSET
} else {
Self::LOSING_CAPTURES_OFFSET
};
}

score += match m.promotion() {
Expand All @@ -85,8 +84,10 @@ impl MoveSorter {

pub fn add_killer(&mut self, board: &Board, m: Move, ply: Ply) {
let color = board.ctm().index();
self.killer_moves[color][ply].rotate_right(1);
self.killer_moves[color][ply][0] = Some(m);
let killer_moves = &mut self.killer_moves[color][ply];

killer_moves.rotate_right(1);
killer_moves[0] = Some(m);
}

pub fn add_history(&mut self, m: Move, depth: Depth) {
Expand All @@ -105,12 +106,7 @@ impl MoveSorter {
}

fn is_killer(&self, board: &Board, m: Move, ply: usize) -> bool {
for killer_move in self.killer_moves[board.ctm().index()][ply] {
if Some(m) == killer_move {
return true;
}
}
false
self.killer_moves[board.ctm().index()][ply].contains(&Some(m))
}

#[inline(always)]
Expand Down
2 changes: 1 addition & 1 deletion src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl TryFrom<&str> for TimeControl {

fn try_from(s: &str) -> Result<Self, Self::Error> {
if s.is_empty() {
return Ok(TimeControl::Infinite)
return Ok(TimeControl::Infinite);
}

if s.is_empty() {
Expand Down

0 comments on commit 38b73e5

Please sign in to comment.