summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5c703b7)
In case we have a correct white pawn move but pawn
is black (or the contrary) we fail to detect the
move as illegal.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
// Proceed according to the type of the moving piece.
if (type_of_piece(pc) == PAWN)
{
// Proceed according to the type of the moving piece.
if (type_of_piece(pc) == PAWN)
{
+ // Move direction must be compatible with pawn color
+ int direction = to - from;
+ if ((us == WHITE) != (direction > 0))
+ return false;
+
// If the destination square is on the 8/1th rank, the move must
// be a promotion.
if ( ( (square_rank(to) == RANK_8 && us == WHITE)
// If the destination square is on the 8/1th rank, the move must
// be a promotion.
if ( ( (square_rank(to) == RANK_8 && us == WHITE)
// Proceed according to the square delta between the source and
// destionation squares.
// Proceed according to the square delta between the source and
// destionation squares.
{
case DELTA_NW:
case DELTA_NE:
{
case DELTA_NW:
case DELTA_NE: