From 4998a057f517b28437d3ba19606333eae75aeff2 Mon Sep 17 00:00:00 2001 From: Ole Morud Date: Sat, 27 Dec 2025 17:33:46 +0100 Subject: [PATCH] Fix bug where pawn can't promote and capture at the same time --- engine.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine.h b/engine.h index 467f8d4..59c4e43 100644 --- a/engine.h +++ b/engine.h @@ -1646,10 +1646,12 @@ static enum move_result board_move(struct pos* restrict pos, else { POS_MOVE(us, from_piece, move.from, move.to); /* capture */ - /**/ if (to_mask & pos->occupied[them]) { + if (to_mask & pos->occupied[them]) { POS_REMOVE(them, to_piece, move.to); } - else if (from_piece == PIECE_PAWN) { + + /* promote / ep */ + if (from_piece == PIECE_PAWN) { bitboard const finishline = (us == PLAYER_WHITE ? RANK_MASK_8 : RANK_MASK_1); /* en passent */ @@ -1669,6 +1671,7 @@ static enum move_result board_move(struct pos* restrict pos, pos->ep_targets |= RANK_SHIFT_DOWN_1(from_mask); pos->hash = tt_hash_update_ep_targets(pos->hash, INDEX_SHIFT_DOWN(move.from, 1)); } + /* promote */ else if (to_mask & finishline) { /* already moved to `move.to` */ POS_REMOVE(us, PIECE_PAWN, move.to);