1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

A promotion piece cannot be a king or a pawn

Or any other garbage value bigger then QUEEN.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-05-02 13:39:47 +01:00
parent f16c231bc9
commit df7cd94aee

View 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))) ||(square_rank(to) == RANK_1 && us != WHITE)) != bool(move_is_promotion(m)))
return false; 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 // Proceed according to the square delta between the origin and
// destination squares. // destination squares.
switch (direction) switch (direction)