Skip to content

♻️ move board-only predicates to Board - #93

Merged
garak merged 1 commit into
p-chess:masterfrom
garak:board-predicates
Oct 9, 2026
Merged

garak merged 1 commit into
p-chess:masterfrom
garak:board-predicates

Conversation

@garak

@garak garak commented Oct 7, 2026

Copy link
Copy Markdown
Member

Part 2 of #91

  • Move Chess::attacked() to Board::isAttacked()
  • Move Chess::insufficientMaterial() logic to Board::hasInsufficientMaterial()
  • Keep Chess::attacked() and Chess::insufficientMaterial() as wrappers for BC
  • Call Board::isAttacked() directly in move generation and check detection
  • Rewrite AttackTest against the public API, drop attackedPublic() from ChessPublicator
  • Add negative insufficient material cases

Perft counts unchanged. Throughput ~12% up, from direct square access.

Part 2 of p-chess#91

- Move Chess::attacked() to Board::isAttacked()
- Move Chess::insufficientMaterial() logic to Board::hasInsufficientMaterial()
- Keep Chess::attacked() and Chess::insufficientMaterial() as wrappers for BC
- Call Board::isAttacked() directly in move generation and check detection
- Rewrite AttackTest against the public API, drop attackedPublic() from ChessPublicator
- Add negative insufficient material cases

Perft counts unchanged. Throughput ~12% up, from direct square access.
@garak
garak requested a balanced review from Copilot October 7, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The extraction preserves behavior, compatibility wrappers, and relevant test coverage.

0 open findings

What changed in this PR

Moves board-only chess predicates into Board while retaining compatibility wrappers in Chess.

Changes:

  • Adds board-level attack and insufficient-material detection.
  • Updates internal callers, tests, and documentation.
  • Raises PHPStan’s memory limit.
File Description
src/​Board.php Adds board predicates.
src/​Chess.php Delegates predicates to Board.
tests/​AttackTest.php Tests the public board API and edge cases.
tests/​ChessPublicator.php Removes the obsolete attack proxy.
docs/​board.md Documents new methods.
Makefile Removes PHPStan’s memory limit.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@garak
garak merged commit d56afd3 into p-chess:master Oct 9, 2026
5 checks passed
@garak
garak deleted the board-predicates branch October 9, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants