]> git.sesse.net Git - stockfish/commitdiff
A promotion piece cannot be a king or a pawn
authorMarco Costalba <mcostalba@gmail.com>
Sun, 2 May 2010 12:39:47 +0000 (13:39 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 5 May 2010 11:16:16 +0000 (12:16 +0100)
Or any other garbage value bigger then QUEEN.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movegen.cpp

index ea58740f59ccadb3e9a71c5702831f7ef53a8b93..df2b9b87b1b2cd96adb42986b0e14e3be40c81dd 100644 (file)
@@ -338,6 +338,10 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
            ||(square_rank(to) == RANK_1 && us != WHITE)) != bool(move_is_promotion(m)))
           return false;
 
+      // The promotion piece, if any, must be valid
+      if (move_promotion_piece(m) > QUEEN || move_promotion_piece(m) == PAWN)
+          return false;
+
       // Proceed according to the square delta between the origin and
       // destination squares.
       switch (direction)