From df7cd94aeeb4e99bed2d46c008efdd5e24085e0f Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 2 May 2010 13:39:47 +0100 Subject: [PATCH] A promotion piece cannot be a king or a pawn Or any other garbage value bigger then QUEEN. Signed-off-by: Marco Costalba --- src/movegen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/movegen.cpp b/src/movegen.cpp index ea58740f..df2b9b87 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -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) -- 2.39.2