summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
158014b)
This is difficult code becuase a bug here could lead
to very subtle crashes in case of SMP games where we
have TT move corruption due to concurrent access.
Anyhow I have fully verified te code throwing at it
random moves. It shoudl work.
No functional change.
bool Position::is_pseudo_legal(const Move m) const {
Color us = sideToMove;
bool Position::is_pseudo_legal(const Move m) const {
Color us = sideToMove;
- Color them = ~sideToMove;
Square from = from_sq(m);
Square to = to_sq(m);
Piece pc = piece_moved(m);
Square from = from_sq(m);
Square to = to_sq(m);
Piece pc = piece_moved(m);
case DELTA_SE:
// Capture. The destination square must be occupied by an enemy
// piece (en passant captures was handled earlier).
case DELTA_SE:
// Capture. The destination square must be occupied by an enemy
// piece (en passant captures was handled earlier).
- if (piece_on(to) == NO_PIECE || color_of(piece_on(to)) != them)
+ if (piece_on(to) == NO_PIECE || color_of(piece_on(to)) != ~us)
return false;
// From and to files must be one file apart, avoids a7h5
return false;
// From and to files must be one file apart, avoids a7h5
{
if (type_of(pc) != KING)
{
{
if (type_of(pc) != KING)
{
- Bitboard b = checkers();
- Square checksq = pop_lsb(&b);
-
- if (b) // double check ? In this case a king move is required
+ // Double check? In this case a king move is required
+ if (more_than_one(checkers()))
return false;
// Our move must be a blocking evasion or a capture of the checking piece
return false;
// Our move must be a blocking evasion or a capture of the checking piece
- if (!((between_bb(checksq, king_square(us)) | checkers()) & to))
+ if (!((between_bb(lsb(checkers()), king_square(us)) | checkers()) & to))
return false;
}
// In case of king moves under check we have to remove king so to catch
return false;
}
// In case of king moves under check we have to remove king so to catch