+ Piece pc = piece_on(from);
+
+ // Use a slower but simpler function for uncommon cases
+ if (move_is_special(m))
+ return move_is_pl_full(m);
+
+ // Is not a promotion, so promotion piece must be empty
+ if (move_promotion_piece(m) - 2 != PIECE_TYPE_NONE)
+ return false;
+
+ // If the from square is not occupied by a piece belonging to the side to
+ // move, the move is obviously not legal.
+ if (pc == PIECE_NONE || color_of_piece(pc) != us)
+ return false;
+
+ // The destination square cannot be occupied by a friendly piece
+ if (color_of_piece_on(to) == us)
+ return false;
+
+ // Handle the special case of a pawn move
+ 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;