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 13, 2024
1 parent b3cbf96 commit 68fac24
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit 68fac24

Please sign in to comment.