Skip to content

Commit

Permalink
A promotion piece cannot be a king or a pawn
Browse files Browse the repository at this point in the history
Or any other garbage value bigger then QUEEN.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
  • Loading branch information
mcostalba committed May 5, 2010
1 parent f16c231 commit df7cd94
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/movegen.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit df7cd94

Please sign in to comment.