Skip to content

Add check-only move modality support#23

Open
Belzedar94 wants to merge 2 commits intomasterfrom
codex/add-support-for-check-only-moves
Open

Add check-only move modality support#23
Belzedar94 wants to merge 2 commits intomasterfrom
codex/add-support-for-check-only-moves

Conversation

@Belzedar94
Copy link
Copy Markdown
Owner

Summary

  • extend Betza move parsing and modality enum with the new check-only k qualifier
  • build precomputed data for check-only attacks and include them in attack detection and check-square bookkeeping

Testing

  • cd src && make -j2 ARCH=x86-64 build

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

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 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
Comment on lines +975 to +979
b |= attacks_bb(~c, move_pt, s, occupied) & attacks_bb(~c, move_pt, s, occupied & ~janggiCannons) & pieces(c, JANGGI_CANNON);
else
b |= attacks_bb(~c, move_pt, s, occupied) & pieces(c, pt);

b |= check_attacks_bb(~c, move_pt, s, occupied) & pieces(c, pt);
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] Check-only attacks ignore blocking for asymmetrical riders

The new check_attacks_bb() call is added unconditionally after the asymmetrical-rider branch in attackers_to. For pieces whose check-only movement is asymmetric (e.g., a horse-style piece whose leg squares must be empty), the routine now evaluates check-only attacks using check_attacks_bb(~c, move_pt, s, occupied) without the per-attacker validation performed in the ASYMMETRICAL_RIDERS branch above. This means a piece can be considered to give check through a blocked leg, because the blocking is tested relative to the target square instead of the attacker. Any variant that defines a check-only horse-like move will produce false positive checks and illegal evasions.

Useful? React with 👍 / 👎.

Comment on lines 582 to 591
{
PieceType pt = pop_lsb(ps);
PieceType movePt = pt == KING ? king_type() : pt;
si->checkSquares[pt] = ksq != SQ_NONE ? attacks_bb(~sideToMove, movePt, ksq, pieces()) : Bitboard(0);
si->checkSquares[pt] = ksq != SQ_NONE
? (attacks_bb(~sideToMove, movePt, ksq, pieces())
| check_attacks_bb(~sideToMove, movePt, ksq, pieces()))
: Bitboard(0);
// Collect special piece types that require slower check and evasion detection
if (AttackRiderTypes[movePt] & NON_SLIDING_RIDERS)
si->nonSlidingRiders |= pieces(pt);
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] Non-sliding check-only pieces omitted from slow-check bookkeeping

set_check_info still populates nonSlidingRiders using AttackRiderTypes only. If a piece has no capture moves and only check-only leaping moves (e.g., a horse that can only give check), AttackRiderTypes stays zero while CheckRiderTypes contains the non-sliding rider bits. Such pieces are therefore excluded from nonSlidingRiders, and the later check-handling code treats their checks as if they were sliding and blockable. In positions where a check is delivered by a check-only non-sliding piece, legal move generation can incorrectly accept blocks instead of enforcing capture or king moves. The bookkeeping should also consider check-only rider types.

Useful? React with 👍 / 👎.

@Belzedar94
Copy link
Copy Markdown
Owner Author

@codex fix comments

@chatgpt-codex-connector
Copy link
Copy Markdown

Summary

  • Updated check bookkeeping to treat pieces with check-only rider moves as non-sliding attackers when needed for slow check handling. src/position.cppL585-L591
  • Ensured asymmetrical check-only attacks validate each attacker’s path so blocked legs cannot yield false checks. src/position.cppL963-L990

Testing

  • cd src && make -j2 ARCH=x86-64 build

View task →

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