Skip to content

Types + docs follow-up: Player/Game/GameController/Piece subclasses (#46, #47)#56

Open
dbqpdb wants to merge 1 commit into
masterfrom
chore/types-docs-piece-game
Open

Types + docs follow-up: Player/Game/GameController/Piece subclasses (#46, #47)#56
dbqpdb wants to merge 1 commit into
masterfrom
chore/types-docs-piece-game

Conversation

@dbqpdb

@dbqpdb dbqpdb commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #54 (types, Board+Move) and PR #55 (docs, Board+Move). Same treatment applied to the rest of the engine's core classes:

  • Player, RLMPlayer, HumanPlayer, NRLMPlayer
  • GameController
  • Game (every method)
  • Piece, KQRBN_Piece
  • King, Queen, Rook, Bishop, Knight, Pawn

Why one combined commit (not split like #54 / #55)

For these classes the type-hint changes and docstring changes co-locate on the same methods — splitting would have produced artificial diff units. Keeping them as one commit makes each method's changes reviewable in one place.

What each method got

  • Annotations on parameters and return types, using the SquareName / BoardIdxs / PieceChar aliases introduced in Type hints for Board + Move; mypy CI workflow (advisory) (#46) #54 plus modern T | None union syntax.
  • Google-style docstring trimmed to a single-line summary plus Args: / Returns: / Raises: only where they add information.
  • Inline cleanup — dropped comments that restate code; kept the ones that explain non-obvious "why" (e.g. en-passant rank quirk, ray termination, castling check propagation, the allow_own_king_checked semantics).

Other things in here

Verification

All 4 TestRLM cases pass; test_entered_move_processing runs to completion and returns True. Annotations and docstring changes only — no behavior changes.

Out of scope

Lexicon, Loudmouth, TestRLM, and top-level helpers (sillyDude, run_me_if_i_am_the_main_file). These are commentary / test scaffolding and benefit from a different treatment — future pass after the dead-code cleanup in #40 is resolved.

Diff shape

376 insertions, 452 deletions — net negative thanks to the comment cleanup outpacing the annotation additions.

Interactions with other open PRs

Closes #46 and #47 partially.

🤖 Generated with Claude Code

…lasses (#46, #47)

Combined follow-up pass to PR #54 (type hints, Board+Move) and PR #55
(docstrings, Board+Move). For these classes the type hints and the
docstring cleanup co-locate on the same methods, so splitting into
two commits would have produced artificial diff units — bundled here.

Covered:
- Player + RLMPlayer + HumanPlayer + NRLMPlayer
- GameController
- Game (with all its methods)
- Piece + KQRBN_Piece
- King + Queen + Rook + Bishop + Knight + Pawn

Each method got:
- Annotations on parameters and return type (using the SquareName /
  BoardIdxs / PieceChar aliases from #54 plus PEP 604 `T | None`).
- A Google-style docstring trimmed to a single-line summary plus
  Args/Returns/Raises where they add information beyond the signature.
- Inline comments restating obvious code dropped; comments explaining
  non-obvious *why* preserved (en-passant rank quirk, ray termination,
  castling check propagation, the `allow_own_king_checked` semantics).

Adds `from __future__ import annotations` at the top so forward refs
work (Player -> Game -> Move all reference each other).

Two known bugs got one-line `# Bug #N:` markers at their sites:
- #34 (castling rights on rook capture) in Game.make_move
- #35 (FEN game-state ignored) in Game.__init__

Annotations only — no behavior changes. All 4 TestRLM cases pass plus
test_entered_move_processing.

Still out of scope: Lexicon, Loudmouth, TestRLM, top-level helpers —
these are mostly commentary / test scaffolding and benefit from a
different style than the core engine classes. Future pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Cleanup: add complete type hints across the codebase

1 participant