Skip to content

Commit

Permalink
Quickly check for check in pseudo legality test
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed May 12, 2024
1 parent 7845abf commit 44bd300
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/moves/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use self::{
attacks::specials::pawn_attacks,
gen::{piece_attacks, MoveDirection},
gen::{piece_attacks, square_attackers, MoveDirection},
};
use crate::position::{
bitboard::Bitboard, board::Piece, square::Square, CastlingRights, Color, Position,
Expand Down Expand Up @@ -130,6 +130,18 @@ impl Move {
return false;
}

// Basic check test for king moves.
if piece == Piece::King
&& square_attackers::<true>(
&position.board,
self.to(),
position.side_to_move.opposite(),
)
.is_not_empty()
{
return false;
}

match self.flag() {
MoveFlag::Quiet if piece == Piece::Pawn => {
to_color.is_none() && self.to().file() == self.from().file()
Expand Down
4 changes: 2 additions & 2 deletions src/search/constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ mod tests {
game_history: vec![],
};

assert!(!constraint.should_stop_search());
assert!(!constraint.should_stop_search::<false>());

stop_now.store(true, std::sync::atomic::Ordering::Release);

assert!(constraint.should_stop_search());
assert!(constraint.should_stop_search::<false>());
assert!(constraint.remaining_time().unwrap() > Duration::from_millis(90));
}
}

0 comments on commit 44bd300

Please sign in to comment.