Skip to content

Fix battlekings promotion move encoding#70

Merged
Belzedar94 merged 6 commits intocodex/implement-battle-of-the-kings-variant-7bhqbnfrom
codex/fix-illegal-move-in-battlekings-engine-304qlc
Oct 21, 2025
Merged

Fix battlekings promotion move encoding#70
Belzedar94 merged 6 commits intocodex/implement-battle-of-the-kings-variant-7bhqbnfrom
codex/fix-illegal-move-in-battlekings-engine-304qlc

Conversation

@Belzedar94
Copy link
Copy Markdown
Owner

Summary

  • ensure forced gating promotions encode the chosen promotion type and compute the gating piece from the current position
  • update SAN/heuristics/UCI helpers to rely on the new gating piece lookup
  • add a regression test covering the battlekings promotion move list

Testing

  • python -m unittest test.TestPyffish.test_battlekings_commoner_capture_ends_game_even_if_gate_attacked test.TestPyffish.test_battlekings_pawn_promotion_lists_all_choices

https://chatgpt.com/codex/tasks/task_e_68f68af740c48322a6acc4499aeaa3d0

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

src/position.cpp Outdated
Comment on lines +223 to +233
PieceType Position::gating_piece_type(Move m, Color c) const {

if (!gating() || !is_gating(m))
return NO_PIECE_TYPE;

if (type_of(m) == PROMOTION && !gating_from_hand())
{
Piece moving = moved_piece(m);
if (moving != NO_PIECE)
{
PieceType forced = forced_gating_type(c, type_of(moving));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Determine forced gate before source square is cleared

The new gating_piece_type() tries to infer forced gates by calling moved_piece(m) and using forced_gating_type(...). However Position::do_move() invokes this helper after it has already moved the piece off from (see lines 2025‑2031), so moved_piece(m) returns NO_PIECE and the function falls back to gating_type(m)—which now encodes the chosen promotion piece. As a result forced Battlekings promotions place the gating piece equal to the promotion choice rather than the mandated gate type whenever they differ. The gating piece should be computed using the original moving piece (captured before the board update) or the function must be called before the piece is removed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex address that feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Testing

  • ⚠️ python -m unittest test.TestPyffish.test_battlekings_commoner_capture_ends_game_even_if_gate_attacked test.TestPyffish.test_battlekings_pawn_promotion_lists_all_choices (fails: ModuleNotFoundError: No module named 'pyffish')

View task →

@Belzedar94 Belzedar94 merged commit 7af2b20 into codex/implement-battle-of-the-kings-variant-7bhqbn Oct 21, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant