Add self-capture variant support and tests#11
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
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, or 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 fix this CI failure" or "@codex address that feedback".
src/position.cpp
Outdated
| // The destination square cannot be occupied by a friendly piece unless self capture is allowed | ||
| if ((pieces(us) & to) && !(self_capture() && capture(m))) | ||
| return false; |
There was a problem hiding this comment.
[P1] Disallow capturing your own king
The relaxed friendly-occupancy check now simply allows any move that captures a friendly piece when self_capture() is true (if ((pieces(us) & to) && !(self_capture() && capture(m))) return false;). With this change there is no longer any guard against capturing your own king. For example, in capture-anything a knight that attacks ksq will be returned by legal_moves, but do_move() still asserts type_of(captured) != KING and will trip in debug builds (or remove the king in release). Self-capture variants should still forbid moves that take the side-to-move’s king.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@codex, that's correct, fix it. On the other hand, you have defined "capture-anything" twice, both as an in-built variant in variant.cpp, and as a custom one in variants.ini. Remove the in-built one
There was a problem hiding this comment.
Summary
- Removed the dedicated
capture_anything_varianthelper and now transition directly from the standard chess variant to Chess960, leaving capture-anything defined only via configuration. src/variant.cppL48-L80 - Dropped the built-in registration of
capture-anythingfrom the predefined variant list to avoid duplicating the preset provided invariants.ini. src/variant.cppL1828-L1852
Testing
⚠️ Not run (not requested).
Summary
Testing
make -j2 ARCH=x86-64 buildpython3 test.pyhttps://chatgpt.com/codex/tasks/task_e_68cc6d93496c8322954827ff975b91ee