Skip to content

Test on Python 3.12-3.14, harden CI, add Dependabot and an MIT license - #18

Open
DoRmAmMu1997 wants to merge 84 commits into
mainfrom
claude/tender-allen-i7u4bg
Open

DoRmAmMu1997 wants to merge 84 commits into
mainfrom
claude/tender-allen-i7u4bg

Conversation

@DoRmAmMu1997

Copy link
Copy Markdown
Owner

Summary

This PR makes the four repository-level changes from the whole-codebase self-review, including the three the owner asked for (Dependabot, the CI matrix and the license). Each is its own commit.

  1. Test on Python 3.12–3.14 and raise the floor to 3.12.

    • The CI matrix changes from ["3.11", "3.13"] to ["3.12", "3.13", "3.14"].
    • pygame-ce 2.5.8 ships cp312/cp313/cp314 wheels for Windows and Linux, and every pinned dev tool supports 3.14.
    • 3.11 is no longer tested, so the documented floor moves to 3.12 in the same commit:
      • ruff target-version = "py312"
      • mypy python_version = "3.12"
      • AGENTS.md §5 and §6, the root README and every game README

    The ruff and mypy changes report no new findings.

  2. Harden the CI workflow.

    • actions/checkout and actions/setup-python are pinned to full commit SHAs (v7.0.1 / v7.0.0; both run on node24, off the retiring Node 20).
    • persist-credentials: false
    • The pip cache is keyed on every requirements*.txt file, including requirements-dev.txt, which it previously missed.
    • A newer push now cancels the CI run it supersedes.
    • The working-directory values are quoted.

    No CI command changed, so AGENTS.md §6 needs no edit.

  3. Add Dependabot version updates (.github/dependabot.yaml, checked against SchemaStore's dependabot-2.0 schema). Updates are weekly, with a 7-day release cooldown:

    • A dev-toolchain multi-ecosystem group covers root pip and pre-commit. A ruff release therefore bumps the ruff== pin and the ruff-pre-commit rev in the same PR, which AGENTS.md requires.
    • pygame-ce is bumped in all three game folders together (group-by: dependency-name).
    • GitHub Actions updates keep the SHA pins current.
    • The pre-commit hook id moves from the legacy ruff alias to ruff-check, which behaves the same.
  4. License the games under the MIT License.

    • LICENSE uses the canonical text (word-identical to SPDX MIT) with "Copyright (c) 2026 Hemant Dhamija".
    • The root README gains a License section, and AGENTS.md lists the file in its repository map.
    • Each game README links to the license.
    • The Monopoly README adds a line noting that MONOPOLY is a Hasbro trademark and that this fan-made game is not affiliated with Hasbro.

Verification

All AGENTS.md §6 gates, run locally on Python 3.13 with the SDL dummy drivers:

Gate Result
Ludo pytest 28 passed, 81.32% coverage (floor 75)
Monopoly pytest 21 passed, 84.51% (floor 80)
Orbital Orchard pytest 18 passed, 95.92% (floor 90)
Solitaire pytest 12 passed, 36.83% (floor 32), using a tkinter stub because this container's Python has no Tk; CI has real Tk
LUDO_AUTOTEST, MONOPOLY_AUTOTEST, ORBITAL_ORCHARD_AUTOTEST exit 0
compileall, ruff, mypy ×4, bandit clean
pre-commit validate-config OK
pip-audit no known vulnerabilities

Also checked:

  • The two pinned action SHAs match their release tags, and both versions accept persist-credentials and cache-dependency-path.
  • The ruff-check hook id exists at the pinned ruff-pre-commit v0.15.1.

The 3.12 and 3.14 legs run for the first time in this PR's CI.


Generated by Claude Code

claude added 30 commits November 2, 2026 13:15
CI now runs the full quality gate on Python 3.12, 3.13 and 3.14 instead
of 3.11 and 3.13. pygame-ce 2.5.8 ships cp312/cp313/cp314 wheels for
Windows and Linux, and every pinned dev tool supports 3.14.

Because 3.11 is no longer tested, the documented floor moves to 3.12 in
the same commit: ruff target-version py312 and mypy python_version 3.12
(both report no new findings), AGENTS.md sections 5 and 6, the root
README and every game README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
- Pin actions/checkout and actions/setup-python to full commit SHAs
  (v7.0.1 and v7.0.0). This also moves both off the retiring Node 20
  runtime, because v7 runs on node24.
- Stop persisting the checkout token: the job never pushes, and it runs
  third-party packages and tests after checkout.
- Key the pip cache on every requirements file, including
  requirements-dev.txt, which the default key missed.
- Cancel superseded runs on the same branch or PR.
- Quote the space-containing working-directory values, per AGENTS.md.

No CI command changed, so AGENTS.md section 6 needs no update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
.github/dependabot.yaml opens weekly update PRs, each with a 7-day
release cooldown:
- dev-toolchain: a multi-ecosystem group of root pip
  (requirements-dev.txt) and pre-commit. A ruff release therefore bumps
  the ruff== pin and the ruff-pre-commit rev in the same PR, as
  AGENTS.md requires.
- pygame-ce: the three pygame games' requirements.txt files, grouped by
  dependency name so all three copies move together.
- github-actions: keeps the SHA-pinned actions current.

The pre-commit hook id moves from the legacy `ruff` alias to
`ruff-check`, which behaves the same. AGENTS.md adds the file to its
repository map and notes that the dev-toolchain group keeps the pins
aligned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Add the canonical MIT text as LICENSE ("Copyright (c) 2026 Hemant
Dhamija"; no file extension, so GitHub detects it). The root README
gains a License section and a LICENSE entry in its layout tree, and
AGENTS.md lists the file in its repository map. Each game README links
back to it, so a copied game folder still points at its license.

The Monopoly README also notes that MONOPOLY is a Hasbro trademark and
that this fan-made game is not affiliated with Hasbro. The MIT License
covers only this repository's own code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
A real Ludo token never lands on the square just behind its own start:
it turns into its home column one square earlier, so a lap is 51 shared
cells on the 4P board (64 on 5P, 77 on 6P). The engine used to walk the
whole 52-cell loop, which on the square board ended on the corner (6,14)
and made the token hop diagonally into its column.

BoardLayout gains lap_length (track_length - 1), and every consumer uses
that name: track_index, home_lane_index, finish_steps (57->56, 70->69,
83->82), the blockade path range and the AI danger check. steps_to_reach
now refuses a seat's skipped corner.

The 4P square needs no coordinate change: its last shared cell (7,14)
already sits straight below the column. The 5P/6P radial track rotation
moves one cell (entry_offset home_length + 2), so the start square is the
inbound lane's second cell, as on the square board, and the lap ends on
the arm tip directly above lane[0]. Radial start and star squares each
move one cell on screen; engine start and safe indices are unchanged.

Saves now record lap_version 2. Older saves (no key) shift every step at
or beyond the new lap length down by one, and unknown versions are
refused. The README documents the rule and what migration does to each
kind of token.

Tests: test_final_loop_cell_leads_straight_into_the_home_column replaces
the old adjacency check (it failed on 4P before the change, 59.4 > 44.1,
and on the radial boards before the rotation fix, cosine 0), plus
ClassicLapTests and LegacySaveMigrationTests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
note_no_move passed the turn on a third consecutive 6 even when the
three-sixes penalty was switched off, so a player whose tokens could not
use a 6 lost a roll that a playable 6 would have granted. A 6 now always
earns another roll here, exactly as in apply_move; the penalty, when it
is enabled, is already enforced earlier in record_roll.

Test: test_six_with_no_legal_move_keeps_the_turn_without_the_penalty
(penalty off, seat 0's tokens two cells from home, three no-move 6s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
A damaged savegame.json could crash the Resume button (a top-level list
or null, or a token entry that is a list, raised AttributeError) or load
into a game that could never continue: a current player out of range, a
game_over or unknown turn state, choose_move with no die, a missing
token, steps past home, or an infinite last roll.

LudoGame.from_dict now checks the top level is a JSON object first,
coerces last_roll to int, and validates the rebuilt game's current
player, turn state, pending die and token data, raising ValueError for
anything it cannot resume. load_saved_game also catches AttributeError
and OverflowError (JSON reads 1e400 as inf, and int(inf) overflows), so
a bad save simply leaves the player on the setup screen.

Tests: CorruptSaveTests (ten damaged shapes, plus a valid mid-turn save
that still loads) and the new tests/test_app_persistence.py, which
resumes damaged saves from a temp folder and checks the app stays on
setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
With blockades enabled, an opponent pair on a player's start square
should keep that player's yard shut, because entering lands on the start
square. _blocked_by_blockade skipped every move with from_steps < 0, so
a 6 could still bring a token out onto the wall. Dropping that guard
lets the entering move (-1 to 0) run the normal path loop over
range(0, 1), which checks exactly the start cell.

Test: test_blockade_on_the_start_square_stops_yard_entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
visible_moves was only rebuilt when a frame was drawn, so key presses
arriving in one frame could act on an old list. Pressing 1, R, 2 after a
6 entered token 1, rolled again, and then replayed the previous roll's
"enter token 2 with a 6" move. The engine accepted it because the move
was still legal for a 6, even though the die now showed something else.

The shell now rebuilds the list through _refresh_visible_moves() after
every human roll, human move and AI step (and before drawing), and
_handle_click checks button rects before token hits, so a click inside a
button always runs that button. As a backstop, apply_move raises
ValueError unless the engine is awaiting a move and the move's die is
the die actually rolled; the four engine tests that applied moves
without rolling now call record_roll first.

Tests: test_apply_move_rejects_a_move_before_any_roll,
test_apply_move_rejects_a_move_for_a_different_die, and
StaleMoveTests.test_move_roll_move_keys_in_one_frame_do_not_replay_a_stale_move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Two related click and drawing bugs:

- move_at_pos returned the first highlighted pawn within cell_radius +
  18 px. On the 6P board neighbouring cells are 33 px apart, so a click
  on one pawn could select its neighbour. It now picks the NEAREST
  candidate within TOKEN_HIT_RADIUS = 33 (named in settings).
- Only same-colour pawns on the shared track were offset, so pawns of
  different colours on a safe or start square, stacked lane cells, and
  finished pawns hid each other. Clicks also measured against the cell
  centre, not where the pawn was drawn.

BoardRenderer.token_pins(game, animated_positions) is now the single
place that groups pawns by on-screen point (the rounded position_for
point) and applies _stack_offset: occupants sit on a regular polygon
with STACK_SPACING-long sides (radius STACK_SPACING / (2 sin(pi/k))),
and a lone pawn stays exactly on its cell centre. Drawing, the move
highlight rings and move_at_pos(pos, moves, game) all read these pins,
so a click always measures against what the player sees. The shell
passes the game to move_at_pos.

Tests (tests/test_token_pins.py): a lone pawn sits on its cell centre;
no two pins share a pixel on safe squares, start squares, lane cells or
the finish for 4P/5P/6P; finished pawns resolve to one cell; adjacent
6P pawns 33 px apart each select themselves; each of seat 0's pins in a
five-pawn 6P safe-square stack selects that token; a far click selects
nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The move buttons (from y=566) and the table log sat over the lower
right of the board: on 4P they covered the yellow yard's parking slots
and its name banner, and on 6P the orange yard and banner. They now
live in the free right-hand column under the roster (x >= 932): the
roster ends at y=390 even with six players, the move buttons start at
y=410 and share the roster's 254 px width, and the log's bottom edge
lines up with the dice tray at y=876.

To make the layout testable, main.py names the roster geometry
(PLAY_ROSTER_WIDTH/STEP/CHIP_HEIGHT) and builds move buttons through
_move_button_rect(index), and BoardRenderer.banner_rects() returns each
seat's name-banner rect. Both banner drawing paths now use it, which
replaces _draw_player_tab and the repeated 150x28 literals
(BANNER_WIDTH, BANNER_HEIGHT, SQUARE_BANNER_GAP).

Tests (tests/test_hud_layout.py): no HUD rect intersects any yard slot,
track cell, lane cell or banner on 4P, 5P or 6P; the move buttons and
log sit in the right column below a full roster; clicking inside each
play button (Roll, a move, Save, New) runs that button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Three HUD texts were sized by character count or a too-small box:

- The turn prompt box was 34 px tall, so "Pick a highlighted token or
  use a move button." lost its second line. It is now PLAY_PROMPT_RECT,
  300x44 inside the dice tray with a 2 px line gap, which holds two
  wrapped lines of the small font. The prompt text comes from a small
  _turn_prompt() helper.
- Log lines were cut with [:36], which can still overflow (wide
  letters) and gives no sign the text was cut. They are now shortened
  by ui.ellipsize(), which measures with font.size() and appends "...",
  within the log card's padded width (PLAY_LOG_PADDING).
- Name typing stopped at 18 characters, which overflows the field for
  wide letters. _type_name now rejects a keystroke when the rendered
  name would cross the field's padded width (SETUP_NAME_TEXT_PADDING).

ui.draw_wrapped's wrapping loop moves into ui.wrap_lines() so tests can
measure the wrapped prompt.

Tests (HudTextFitTests): every turn prompt wraps into lines that fit a
>= 40 px box inside the tray; a long log line is ellipsized within the
log width; ellipsize keeps short text and trims long text; typing "W"s
stops exactly at the field's pixel width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
load_stats merged whatever stats.json held over the defaults, so a
damaged or hand-edited file (null, text, a list, a huge number that
JSON reads as infinity, or a null player-count bucket) loaded as-is and
crashed the first int() on it: recording a finished game or drawing the
game-over card.

load_stats now coerces games, human_wins, ai_wins, turn_total and every
by_player_count bucket to int through _stat_count, which falls back to
0 for that one field and logs it by name via _log_error, so every good
counter survives. A healthy file loads unchanged and logs nothing.

Tests (StatsRepairTests, against a temp save dir): None, "x", inf, a
list and null/text buckets become 0 while a good bucket survives; each
repaired field is named in error.log; valid stats load without logging;
a game reaching game over with damaged stats records and draws its
result.

The new class also tidies three stray triple blank lines left in the
test files by earlier commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The BoardRenderer docstring still claimed BoardLayout owns the true
token coordinates and click targets. Since the display overhaul,
BoardLayout owns the authoritative track indices and DisplayLayout owns
every on-screen coordinate (as AGENTS.md says), so the docstring now
says that.

BoardLayout keeps its pixel fields on purpose: they are the headless
fallback the shell uses for animation targets before a renderer exists.
Its docstring and the BOARD_CENTER/BOARD_RADIUS settings comment now say
so, and a test locks the fallback in place.

Dead code removed: _player_outward (unused since the radial rewrite)
and the unused BOARD_RECT, BG, BOARD_BG, BOARD_LINE, TRACK_FILL and
HOME_FILL settings. _radial_display_layout reads HOME_LENGTH directly
instead of measuring the fallback lane, and the setup stepper uses
MIN_PLAYERS/MAX_PLAYERS instead of bare 4 and 6.

Tests: test_board_layout_pixels_are_the_headless_fallback,
test_token_position_falls_back_to_board_layout_without_a_renderer and
test_setup_player_count_stays_within_supported_bounds (characterization
tests that pass before and after the cleanup).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
simulation.py could only run the classic rules, so the house rules the
setup screen offers (blockades, no capture bonus, no home bonus, no
three-sixes penalty) could not be tuned or compared. It now accepts
--blockades, --no-capture-bonus, --no-home-bonus and --no-three-sixes;
rules_from_args() builds LudoRules from them, run_ai_game() takes the
rules, and main() accepts an argv list so the CLI is testable. The
README lists the flags.

The shell also rolled dice itself (game.rng.randint + record_roll) in
two places. Both now call the engine's LudoGame.roll_die(), which does
exactly that, and check the engine's awaiting state instead of the
forfeit flag: a forfeited third 6 has already passed the turn, so it is
never mistaken for a no-move roll. Behaviour is unchanged.

Tests: tests/test_simulation.py (defaults are the classic rules; each
flag flips exactly its own field on the LudoGame the CLI builds; a
seeded game under every flag finishes) and
test_human_and_ai_rolls_go_through_the_engine_roll_die.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The comment on score_move's deterministic nudge said it prefers moving
the most advanced token. The term actually adds the distance the move
covers (to_steps minus the clamped from_steps, so a yard entry counts as
0), and any remaining tie goes to the lowest token index through
choose_move's sort key. The comment now says that. Behaviour is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The window showed a crude drawn icon because pygame cannot decode
ludo_icon.ico ("Unsupported ICO bitmap format"). The .ico already holds
a PNG-encoded 256px image, so that entry is now committed as
ludo_icon.png (extracted with a stdlib ICONDIR parser, no Pillow).

main._resource_path is restored, textually identical to Monopoly's copy,
and _load_icon() loads the PNG through it with a guarded
pygame.image.load, falling back to _make_icon() if anything goes wrong.
The spec bundles the PNG in datas so the frozen .exe finds it under
sys._MEIPASS; the .ico still provides the .exe's own file icon.
_make_icon's literals (canvas, board inset/size/radius/colour, dot
origin/spacing/radius) are now named settings.py knobs.

Tests (tests/test_window_icon.py): the icon resolves beside main.py and
loads to a Surface; _load_icon returns the 256px image; a missing file
falls back to the drawn icon; _make_icon is 64x64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
LUDO_AUTOTEST only drew 8 frames of the setup screen, so the smoke test
never exercised a single roll, move or AI turn. It now plays a seeded
all-AI four-player game for AUTOTEST_FRAMES = 120 frames (seed
AUTOTEST_SEED = 7, both named in settings).

A real game autosaves, which must never disturb a player's saves, so
LudoApp takes persist: bool = True. With persist=False the app still
reads saves and tracks stats in memory, but never writes or deletes the
savegame or stats files: every write site (new game, autosave, Save,
Esc, game-over stats and save clearing) goes through _save_game() or a
persist check. The autotest uses persist=False. The README says so.

Tests: PersistFlagTests (a control showing a normal app overwrites its
save, and a persist=False app that starts, autosaves, saves, escapes
and finishes a game leaves seeded files byte-identical) and AutotestTests
(main() under LUDO_AUTOTEST runs 120 frames of a seeded all-AI game with
persist off, rolls dice, and leaves a seeded save folder byte-identical).
Also checked by hand: the real subprocess autotest leaves a pre-seeded
APPDATA byte-identical, and the gate script confirms the suite and the
autotest leave an empty APPDATA empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
On the 5P and 6P boards every side banner sat at a fixed banner_radius
from the hub, so the wide, short banners beside the left and right
yards covered the yard triangles and their parking slots.

_radial_banner_anchor now measures from the yard's flat outer edge
(yard_base_radius * cos(half angle)) and pushes the banner centre out by
the banner's own reach along the yard direction (half-width * |cos| +
half-height * |sin|) plus BANNER_GAP = 4 px, with banner_radius kept as
a floor. The window clamp is derived from the banner size and
SCREEN_WIDTH/HEIGHT with a 6 px margin instead of hard-coded
92/1188/28/872 (a wider margin would push the 5P left banner back into
its yard). The 5P banner_radius drops from 362 to 350, so the bottom
tab and its shadow clear the dice tray.

Tests (tests/test_visual_polish.py, BannerPlacementTests): no banner
shares a pixel with any yard frame or parking slot on 4P/5P/6P (mask
overlap); every banner and its shadow stays on the canvas; the bottom
banner and its shadow clear the dice tray. Renders inspected for all
three boards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
With six human players the name fields pushed Resume and Start Game
down until the Start button (bottom y=897) spilled past the dark setup
panel (bottom y=891) and off its rounded corner.

The toggle and name rows are now packed a little tighter and named
instead of hard-coded: SETUP_TOGGLE_START_Y/STEP/HEIGHT (386, 42, 36:
6 px gaps), SETUP_RULES_HEADER_Y, SETUP_NAME_HEADER_Y = 556,
SETUP_NAME_START_Y = 592 and SETUP_NAME_FIELD_STEP = 33. Start Game now
ends at y=871, 20 px inside the panel. The panel itself is the named
SETUP_PANEL_RECT, so tests measure against what is drawn.

Tests (SetupPanelTests): with six humans every setup button and name
field sits at least 8 px inside the panel; the "Advanced Rules" and
"Human Names" headers end above their first control. Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
A disabled button (Resume Saved Game with no save) was filled with the
light DISABLED grey and kept its white label, so it looked brighter, and
more clickable, than the enabled buttons around it.

Button.draw now picks fill, border and label per state: a disabled
button uses the new, darker DISABLED_FILL with a muted DISABLED border
and label; hovered and idle enabled buttons are unchanged.

Tests (ButtonStateTests): the disabled fill is no brighter than an idle
enabled fill, and a disabled button draws no near-white label pixels.
Setup renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
CI's quality (3.14) job failed test_section_headers_do_not_touch_the_
controls_below_them: 387 > 386. The P2 layout left the "Advanced Rules"
header exactly 32 px above the first toggle, which only fits a 28 px
FreeSans line. The same 28 pt header renders 32 px tall in Arial or
Liberation Sans and 33 px in DejaVu Sans, so on some machines the
header touched or overlapped the control below it.

The setup layout now reserves SETUP_HEADER_ROOM = 40 px per section
header: a 36 px line allowance (the tallest font seen plus 3 spare
pixels) and a SETUP_HEADER_GAP of 4 px. The rules header moves up to
y=346 (still 8 px below the AI-profile row), and the toggle and name
rows are derived from the header positions. Start Game now ends at
y=875, still inside the panel.

The test (renamed test_section_headers_leave_a_gap_above_their_controls)
now requires the measured header to end at least SETUP_HEADER_GAP above
its control, and also checks the layout against the allowance and that
this machine's header font fits it, so a near miss fails on every
platform instead of only the one with the tallest font. Also verified
with SysFont forced to DejaVu Sans and Liberation Sans.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Each roster chip crammed "Aggressive  Home 4/4  Captures 12" into a
200 px text area: 226 px in FreeSans and up to 270 px in DejaVu Sans,
so the line ran past the chip. The 40 px chip also could not hold the
name and stats lines with taller platform fonts (21 + 18 px), and names
were cut at 18 characters regardless of width.

The chip is now 48 px tall (step 54; the move buttons start at y=420),
and its two text lines are centred as one block from the fonts' real
line heights. The Human/AI-profile tag moves to the right end of the
name line, the name is ellipsized to the width left beside it, and the
second line is just "Home n/4  Captures n" (ellipsized as a guard). The
chip geometry is named (PLAY_ROSTER_TEXT_X, _TEXT_PADDING, _TAG_GAP,
_LINE_GAP) and _roster_chip_rect(index) builds each chip.

Test (RosterChipTests): with a wide 18-character name, the aggressive
profile and 99 captures on a 6P roster, every name, tag and stats line
lies inside its chip and no two overlap. Also passes with SysFont forced
to DejaVu Sans and Liberation Sans. Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Pawns sharing a cell fanned out only 12 px apart at full size, so each
pawn drawn later covered most of the number on the pawn before it; in
a stack of four, usually only the last number could be read.

Stacked pawns now shrink to STACK_PIN_RADIUS = 11 (a lone pawn keeps
the full 15 px pin) and fan out at STACK_SPACING = 24, which keeps
every number clear of the white-ringed heads drawn after it, even in
five- and six-pawn fans, while a full fan stays within about one cell
of its square. token_pins still decides everything, so drawing and
click targets agree.

Test (StackReadabilityTests): on 4P/5P/6P, for stacks of 2 to 6 pawns,
the ink of each pawn's number is not touched by the head of any pawn
drawn after it. Also passes with SysFont forced to DejaVu Sans and
Liberation Sans. Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Start-square arrows were drawn in the seat's own colour on a square of
nearly the same colour, so they vanished. Pawn numbers were always
white, which is 2.1:1 on yellow and 2.9:1 on orange, and banner labels
switched to dark ink only above a rough brightness cut-off that left
orange on white text.

visual_theme gains contrast_ratio() (the WCAG relative-luminance ratio)
and readable_on(fill), which keeps white wherever it reaches the new
MIN_LABEL_CONTRAST = 3.0 setting and uses dark ink otherwise. Start
arrows, pawn numbers and name banners all use it, so most seats keep
their white labels while yellow and orange get dark ink, and every
arrow stands out from its square. _is_light is replaced, and the start
square tint is named START_CELL_BRIGHTEN.

Tests (SeatMarkingContrastTests): contrast_ratio matches the WCAG
formula; the chosen label colour reaches 3:1 on every seat colour; each
rendered start arrow reaches 3:1 against its start square on 4P/5P/6P;
each rendered pawn number reaches 3:1 on every seat colour. Renders
inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
CI's quality (3.12) job failed test_pawn_numbers_stand_out_on_every_
seat_colour for green: 2.99 < 3.0. readable_on kept white until it
barely passed 3:1, so green pawns got white numbers at 3.05:1 by
design, and the test sampled antialiased glyph pixels, which a
different font's thinner strokes pulled just under the bar.

readable_on now returns whichever of LABEL_LIGHT (pure white) or
LABEL_DARK (pure black) contrasts more with the fill. Every seat colour
and start-square tint then reaches at least 4.6:1 (purple is the
closest call), above the new LABEL_CONTRAST_TARGET = 4.5 (WCAG AA for
normal text) and well above the MIN_LABEL_CONTRAST = 3.0 floor. Green,
purple, yellow and orange now get black labels; blue and red keep
white.

The tests no longer rely on font metrics with zero margin:
- the chosen label colour must reach the 4.5 target against every seat
  colour and start tint (plain colour-to-colour, exact);
- each start arrow's shaft pixel must equal readable_on(its square)
  exactly (a plain line, no antialiasing);
- draw_token_pin must render each number in readable_on(pawn colour),
  checked by recording the colour passed to the font;
- the rendered-pixel check stays only as a 3:1 sanity floor, which every
  font here clears at 4.62.
All tests also pass with SysFont forced to DejaVu Sans, Liberation Sans
and pygame's bundled default font.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
After two CI failures from font metrics, I measured every
font-dependent layout under FreeSans, DejaVu Sans, Liberation Sans and
pygame's default font. Three passed with almost no margin:

- The turn prompt box (44 px) held two 21 px lines plus the 2 px gap
  with 0 px to spare in DejaVu, Liberation and Windows Arial. It is now
  48 px (PLAY_PROMPT_RECT), with the tray's player banner named
  PLAY_TRAY_BANNER_RECT and moved up 4 px to make room inside the tray.
- Stacked pawn numbers cleared later pawns' heads by only 0.26 px in
  FreeSans. STACK_SPACING grows from 24 to 26, giving at least 2.5 px
  in every font tried.
- Roster chip text sat 1.5 px inside the test's inset in DejaVu. Chips
  grow from 48 to 50 px (the roster still ends by y=410).

The tests now demand that spare room instead of passing by a hair: the
prompt must fit with every line 2 px taller than this machine's font
and must not touch the tray banner, stack numbers must clear later
heads by LABEL_CLEARANCE = 2 px, and roster text must sit at least 4 px
inside its chip. All pass with SysFont forced to DejaVu Sans,
Liberation Sans and the default font. Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The winner line "<name> wins!" was drawn in the winner's seat colour
straight onto the blue wallpaper: Player 1's blue was nearly invisible,
and other colours were hard to read on the glow. The New Game and Quit
buttons also sat 38 px left of the stats card's centre.

The winner text now sits on a plaque in the winner's colour with the
board edge and drop shadow used by the name banners, lettered in
theme.readable_on(colour). _winner_plaque() sizes the plaque to the
text plus OVER_PLAQUE_PADDING and ellipsizes a very wide name (keeping
" wins!") to OVER_PLAQUE_MAX_WIDTH, so it stays clear of the stats
column. The game-over geometry is named (OVER_RANKING_RECT,
OVER_STATS_RECT, OVER_BUTTON_*), and _over_button_rects() centres both
buttons on the stats card.

Tests (GameOverLayoutTests): the pixels behind the winner text are the
winner's colour and its label beats the 4.5:1 target; an 18-"W" name
is ellipsized and fits a plaque left of the panel; both end buttons
share the stats card's centre line. Font matrix (DejaVu, Liberation,
default) green. Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The ring around each movable pawn was a plain white 4 px band, about
1.0:1 against the cream board, and the gold landing ring only 1.8:1, so
on most cells a human could barely see which pawns they could move or
where they would land.

_draw_edged_ring() paints a slightly wider BOARD_EDGE band first and the
white or gold band on top, leaving a 2 px dark edge on both sides. The
ring geometry is named (MOVE_RING_RADIUS = 33, LANDING_RING_RADIUS = 36,
HIGHLIGHT_RING_WIDTH, HIGHLIGHT_EDGE_WIDTH) instead of cell_radius + 18
and + 21.

Test (MoveHighlightTests): on a cream surface, scanning outward in eight
directions from each ring's centre finds the ring colour and an edge
pixel of at least 3:1 against cream (plain unantialiased bands, so no
font or antialiasing dependence). Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Every shadow used a translucent colour such as (0, 0, 0, 95), but
pygame.draw ignores alpha when drawing straight onto an opaque surface
like the game window, so board, card, banner, hub and pawn shadows all
came out as hard solid-black bands.

visual_theme gains draw_shadow_rect, draw_shadow_polygon and
draw_shadow_ellipse, which paint the shape once onto a small cached
SRCALPHA layer and blit it, so the shadow darkens whatever is beneath
it. draw_shadowed_rect, draw_shadowed_polygon, draw_token_pin (now
PAWN_SHADOW) and the radial hub use them. The layer cache is capped
(SHADOW_CACHE_LIMIT); a full 6P frame still draws in about 4.5 ms.

Tests (BlendedShadowTests): on a light grey canvas, the shadow pixels of
a rect, a polygon, a pawn and the radial hub are darker than the
background but nowhere near black. Renders inspected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Once the Bank's 32 houses were all on the board, an AI whose group sat
at 4/4/3 houses could never finish it: the last house needed the Bank,
and the hotel that would hand four houses back needed that last house.
The shortage then froze development for the rest of the game.

Post-roll, when the Bank has no houses but still has a hotel, and a held
group's lots are all at 4 houses except some at 3, the AI now sells one
house evenly from its lowest-priority other developed group and builds
it onto a 3-house lot in the same move. Its next build is the hotel,
which returns four houses. A test drives this on a constructed board.
The ai.py module docstring describes this and the raise-funds fallback
as the AI's two deliberate compound moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
_on_button tried the turn, asset and trade handlers before it looked at
quit and new_game. Each of those handlers starts with _require_game(),
so clicking Quit on the setup screen, where there is no game yet,
raised an AssertionError instead of closing the window.

Quit and New Game are now handled first, since they are the two buttons
that also exist with no game in progress. A headless test clicks Quit on
the setup screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The MONOPOLY_AUTOTEST self-test plays a full AI game in a hidden window.
Along the way it autosaved over the player's savegame.json, and when the
game ended it bumped stats.json and deleted the save. Running the smoke
test locally could wipe someone's game.

MonopolyApp now takes persist: bool = True. With persist False, the
autosave, Save & Quit, and the game-over stats write and save delete are
all skipped. main() passes persist=False under MONOPOLY_AUTOTEST. Tests
point the save paths at a folder pre-seeded with a save and stats, run
main() in autotest mode (with the frame loop replaced by an autosave and
a finished game) and Save & Quit, and check the folder is byte-identical
afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Both loaders assumed the JSON held an object. A stats.json containing
[] crashed the app at startup with an AttributeError from data.get, and
"Infinity" raised an OverflowError in int(). A non-dict savegame.json
crashed Resume the same way. A save that failed validation simply
returned None, so the Resume button stayed there and failed on every
click.

Both loaders now check isinstance(data, dict) and also catch
AttributeError and OverflowError. Failures are logged through
_log_error; a missing file is still a quiet "nothing saved yet". A save
that cannot be loaded is renamed to savegame.bad.json, which keeps it
for inspection and makes the Resume button disappear. Tests cover
malformed stats and a non-dict save on the setup screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The action bar's four button rows started at 700, 748, 796 and 844. At
40 px tall, the bottom row (Assets on the pre-roll bar) ended at 884,
which is past the bar's bottom edge at 874 and past the 880-pixel
window. The rows are now 700, 744, 788 and 832, so the last button ends
at 872, inside the bar.

The slot geometry and the auction panel rects moved into ui.py layout
helpers (action_bar_layout, bar_slot_rect, auction_layout), following
the trade_layout pattern. main.py builds its buttons from them and
ui.py draws from them, so the drawn bar and dialog can no longer drift
from the clickable rects. Tests check every slot sits inside the bar
and the auction buttons inside their panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The trade-response dialog stacked "You receive" and "You give" in one
column at fixed offsets. An offer with more than a few titles ran
through the mortgage-interest lines (pinned at bottom - 100) and down
under the Accept/Reject buttons, and long names were never shortened.

The dialog now shows the two sides as columns. Each column holds at
most TRADE_RESPONSE_ROWS lines; a longer side shows one fewer and ends
with "+N more". Every line is shortened to its column's measured width.
The consequence notes are wrapped and follow below the longer column,
and stop before panel.bottom - 64, so nothing reaches the button row.

The panel and button rects come from one ui.trade_response_layout()
helper, used by both main.py and ui.py, and the text positions from a
pure trade_response_plan(). Tests check that every planned line stays
inside the panel and above the limit, that "+N more" counts are right,
and that the buttons match the layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Three rough edges in the board-click modes and the prompt:

- Mortgage mode ringed every house-free title, including ones in a
  developed group (which cannot be mortgaged) and mortgaged titles the
  player cannot afford to lift. It now rings exactly the titles where
  can_mortgage or can_unmortgage holds, through a _board_highlights
  helper.
- A refused board click did nothing visible. It now puts the engine's
  blocker reason ("Only streets can take buildings.") in the prompt,
  which in the board-click modes is the message or the fixed hint. Done
  clears it.
- A message from an earlier action (a refused trade, say) lingered in
  the prompt through later turns. Every engine-dispatching button (roll,
  buy, auction, end turn, bid, pass, trade accept/reject, plus the jail
  and debt buttons) now starts from a clean prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Jail only stops a player's token. The engine still lets a jailed player
mortgage, manage titles and trade in pre_roll, but their action bar
offered only Roll, Pay $50 and Use Jail Card. A jailed human short of
the $50 fine could not even mortgage a title to raise it.

The jailed pre-roll bar now also offers Mortgage, Trade and Assets. A
test clicks Trade from jail.

Saving between doubles is now safe, because the save keeps
doubles_count. A test rolls a double, clicks Save & Quit and checks the
reloaded game resumes on the extra roll with its count intact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
When the last human went bankrupt, the game kept playing the AIs at one
move every 750 ms with no buttons at all. Clicks were ignored because
the actor was never human, so the only way out was closing the window,
and the autosave kept overwriting the save with a game nobody could
resume.

Once no solvent human remains, the action bar shows:
- Fast-forward: runs the AI every frame with no delay and no waiting for
  animations, as the self-test does.
- Concede / Main Menu: records the result through _end_game (one more
  game played, not a human win), which also clears the save, then
  returns to the setup screen.

Clicks are accepted while spectating, the prompt says what the options
are, and autosave is skipped in that state. Tests cover the bar,
fast-forward pacing, concede bookkeeping on a pre-seeded save folder,
and the missing autosave. The README lists the controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Buttons drew their label in the 17 px font whatever its width. The
spectator bar's "Concede / Main Menu" measures 159 px in Arial but
182 px in DejaVu Sans, which is what "arial" resolves to on some Linux
machines, and that is exactly the 182 px button. "Declare Bankruptcy"
was 167 px there. Both touched or crossed the button border.

Button.fitted_label now picks the label's font by measured width and
keeps BUTTON_LABEL_MARGIN (8 px) clear on each side: the normal button
font if it fits, else the smaller one, and as a last resort a shortened
label. A test builds every action bar and dialog (spectator, raise
funds, jail, pre/post roll, buy, auction, trade, assets, setup) and
checks each label against its button with that margin. It compares
measured widths, not pixels, and passes with DejaVu Sans, Liberation
Sans and pygame's default font.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The engine has always moved jail cards in a trade, and the README said
they could be traded, but nothing in the shell could put one in an
offer, and an incoming offer that contained one never showed it.

- The trade dialog now has a -1/+1 stepper for jail cards under each
  side, next to a -$50/+$50 cash stepper, with a label showing the count
  and how many that player holds. The count is capped at the cards held
  and the steppers disable at their limits. Stepper rects come from
  ui.trade_layout; the title lists show 12 rows to make room.
- An incoming offer lists its cash and jail cards FIRST, so a long side
  ending in "+N more" can never hide them.
- ai._make_offer may now add the AI's own jail cards as a sweetener,
  tried in order of total value with cards spent before cash, and
  _bundle_value prices each card at JAIL_FINE instead of a bare 50.

Tests cover the stepper caps and a proposed offer carrying a card, the
stepper layout (inside the panel, clear of lists and buttons), the
incoming-offer order, and an AI offer that needs its cards to close.
The README describes the controls. The invariant harness stays at 0
violations.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The prompt strip is 26 px tall, one line, but the prompt was word-wrapped
into it. Anything longer than about 45 characters ("Click a property to
mortgage it, or a mortgaged one to lift it.") wrapped to a second line
that was cut off by the strip's edge and half hidden under the bar.

The prompt is now always one line, centred in its strip. ui.prompt_line
picks the largest of three fonts in which the text fits by measured
width, with 12 px clear at each end and 2 px above and below, and only
shortens the text with "..." if even the smallest is too wide. The same
_fit_line helper now also fits button labels.

The fixed prompts are reworded to fit in full with the longest player
name and the longest title on any board. The buy prompt puts the title
last, so a long name is what gets shortened, and the auction prompt says
"bid or pass" while the dialog keeps the detail.

Tests measure every state's prompt against the strip and check that no
standard prompt is shortened. They pass with DejaVu Sans, Liberation
Sans and pygame's default font.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Tile names were wrapped by character count (11 per line, three lines at
most) into a fixed 64 px block. A tile is only about 63 px wide, so
"Mediterranean", "Connecticut" and "Pennsylvania" ran over the tile's
borders and were clipped ("editerranea"). On the themed boards it was
worse: "Nungambakkam" is 87 px wide at 12 px, and a four-word name lost
its last word.

Labels are now wrapped by measured pixel width inside the tile, inset
6 px from every edge so they also stay clear of the 4 px ownership
border. Each label uses the largest of three sizes (12, 11, 10 px) in
which no word needs breaking and the lines fit the tile's depth. Only a
word too wide even at 10 px is hyphenated, as a printed board breaks
"Mediter-ranean". The label block is as tall as its text and sits
beside the colour band. Corner squares have no band, so their label
hugs the edge, clear of the tokens in the middle.

A test checks every tile of all 13 themes: each line fits the inset
width, the block fits the depth, no letters are lost and the price is
shown. It measures text, not pixels, and passes with DejaVu Sans,
Liberation Sans and pygame's default font.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Player tokens, the pips on the dice and the token-colour disc on each
player card were drawn with pygame.draw.circle, which does not
antialias. At these sizes (5 to 15 px radius) the edges were visibly
stair-stepped next to the antialiased text around them.

All three now use pygame.draw.aacircle, which is available from the
pygame-ce 2.5 floor the game already requires. Their radii are named in
settings.py instead of being bare numbers at the draw calls.

A test draws each shape and checks its rim holds blended pixels. That
is an existence check with no threshold: an aliased circle paints every
rim pixel in exactly one of its colours.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The action bar's two button columns were hard-coded at x = 892 and 1086
inside a bar from 886 to 1274. That left 6 px at each side and 12 px
between the columns. The rows had 4 px above and between them but only
2 px below the last one.

The slots are now derived from the bar instead of fixed coordinates.
The side margins equal the column gap (8 px), and the top and bottom
margins equal the row gap (4 px). The bar keeps the panel-card width
and is exactly four rows and their gaps tall (180 px, ending at 876).
The rows stay at 700, 744, 788 and 832.

A test measures every gap from the layout rects.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The game log cut every line at 46 characters. Character counts say
little about width: "Bartholomew pays $1100 rent to Iris (AI) on Ke"
was chopped mid-word with a quarter of the card still empty, while a
line of wide letters ran off the card's edge.

Log lines are now shortened by measured width, with "..." only when a
line really is too wide, and keep 10 px clear of the card's sides. The
card shows as many of the newest lines as fit under its header, using
the font's own height for the line pitch, instead of a fixed seven.
The log card's rect comes from a ui.log_rect() helper: it now starts
one card gap below the player cards (it left 14 px before), which gives
the text room without moving anything else.

Tests measure each drawn line against the card, with a narrow
60-character line that must stay whole and a wide one that must be
shortened. They pass with DejaVu Sans, Liberation Sans and pygame's
default font.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Tokens on one tile were spread by 28% of the tile's size. On a 63 px
edge tile that put neighbouring centres 17 px apart, but each token is
30 px across, so two players on the same street stacked over each
other and hid their numbers.

Each player now has a fixed spot in a 2x2 grid around the tile centre,
one token width plus a 2 px gap apart. The token radius drops from 15
to 13 px (named in settings.py with TOKEN_GAP) so all four fit inside
an edge tile's border. A test checks all 40 tiles: the four discs stay
inside the tile and never touch each other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The last drawn Chance/Chest card was centred 150 px above the board
centre and the dice sat on the centre itself. Both landed on the
diagonal MONOPOLY title. The card's small gold header ran into its
body text, and gold on the brown Chest face was hard to read. The card
was also a fixed 120 px tall, so long card text could run out of it.

The title runs from the board middle's lower-left to its upper-right,
so the card now sits in the free upper-left triangle and the dice in
the lower-right one, above the hover deed card. The card's height
follows its wrapped text: a bold white header, then the body a few
pixels below it. The Chest face is a slightly deeper brown, and both
deck colours are named in settings.py.

Tests place the longest card text on any card and check that the card
and dice stay inside the board middle, at least half the title's height
plus 8 px from its centre line, and clear of each other. They also
check the header/body ink against both faces at 4.5:1 or better, by
comparing the chosen colours directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The dialogs placed each text line at a fixed y offset, which only works
while every font is exactly the height it was tuned with:
- Auction: the bankruptcy context line (tiny, y + 122) and the "High
  bid" line (med, centred at y + 138) overlapped.
- Asset manager: the instruction and "Owned titles" headings were 18 px
  apart in a 17-20 px font, so they touched. A status reason that
  wrapped to two lines ran into the next status line, because the rows
  were 28 px apart.
- Trade dialog: the header lines had a few pixels of slack in Arial and
  none in wider fonts.

A shared _stack helper now lays each dialog's text out from the top, by
each font's measured height, 4 px apart (DIALOG_LINE_GAP), and shortens
any line wider than its space. The auction, asset header, asset detail
(deed lines, then wrapped status lines, cut before the box's bottom)
and trade header each come from a plan function that the draw code
blits. Tests check every plan: lines in order with the gap, inside the
dialog, and clear of the buttons or title lists below. They pass with
DejaVu Sans, Liberation Sans and pygame's default font.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Two kinds of text were hard to read on the dark panels:
- The game-over winner line was drawn in the winner's token colour.
  Blue and purple reach only 2.5:1 and 3.1:1 on the background.
- Red status text (BANKRUPT, IN JAIL, the asset "M" marker, trade
  errors, "You give") used DANGER, which is 3.8:1 on a player card and
  2.5:1 on the current player's card, where IN JAIL usually appears.

The winner's name is now white, with their token colour shown as an
antialiased disc beside it. Red text uses a new DANGER_TEXT, a lighter
coral of the same red, which reaches 4.85:1 or better on every surface
it sits on: the window, dialogs, player cards, the current card and a
button. DANGER stays for warning fills and strokes. The current card
and default button fills are named in settings.py.

Tests compare the chosen colours directly (WCAG contrast at least 4.5)
rather than sampling antialiased pixels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
On the setup screen the steppers run from x = 90 to 424, but Start Game
and Resume Saved Game were 320 px wide, ending 14 px short of the
column's right edge. The theme name between its < and > buttons was
always drawn in the 30 px font, so "World Landmarks" and "Chandigarh
Tricity" touched or overlapped the arrows.

The left column's edges are now named once, and every stepper, Start
and Resume are built from them, so their edges line up. A stepper's
value (theme or AI difficulty) uses the big font when it fits by
measured width with 8 px clear of each arrow, and the medium font
otherwise. The values and the human count are centred on the column.

Tests check the column edges and fit every theme and profile name
between its steppers, in full. They pass with DejaVu Sans, Liberation
Sans and pygame's default font.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The scoring and danger arithmetic lived inline in the pygame shell, so it
could only be exercised by running the whole game. A new pygame-free
rules.py now owns combo tracking and the combo multiplier, the fail-timer
fill and decay, the stress-meter split, the danger-beep rhythm, and the
cleaning of loaded progress. game.py keeps the sounds and effects and calls
these functions.

The inline literals in the combo and beep maths (3.0, 0.5, 0.66, 0.46, 0.2)
become named, commented settings.py knobs. Behaviour is unchanged; the new
tests/test_rules.py pins the exact numbers, including the original beep
formula.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The launcher sits on a fixed SPAWN_Y line, but near the top of the round
bubble that line lies outside the legal circle (R - r - 3) for most bodies.
A freshly dropped body was therefore snapped up to ~29 px by the wall
solver on its first frame, and the dotted preview for tiers 3-4 collapsed
to a single dot because its very first point was already "at the wall".

PhysicsWorld.spawn_point(x, radius) projects the launch point onto the same
legal circle that keep_inside, the wall solver and preview_trajectory use.
The body spawn, the drawn launcher orb, the preview start and the aim-angle
origin all use it now.

Tests: the first wall solve moves a fresh tier 0-4 body less than 0.1 px at
the left, centre and right of the spawn span, and tier 3-4 previews at
non-zero angles keep a real dotted path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
run() advanced self.now on every frame, including behind the pause menu.
Body ages are measured against that clock, so a body launched just before
pausing came back "old" and immediately counted toward the fail line, and
the merge-arm and impact timers all ran on while the player was away.

The clock now advances only when the scene is not "paused". Cosmetic
twinkles that read the same clock freeze behind the pause veil, which is
acceptable.

Tests use a fake clock (no sleeping): a body launched before a one-second
pause is still younger than FAIL_AGE_GATE afterwards, and the clock still
follows frame time during play.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
The stress meter measured the tallest point of every body, including the
one just leaving the launcher. Because the launcher sits above the danger
line, every drop into even an empty bubble spiked the meter to its full
preview share (0.78) until the body fell.

highest_top now only considers bodies older than FAIL_AGE_GATE, the same
fairness gate the fail timer already uses, and defaults to the bubble floor.

Tests: a drop into an empty bubble leaves the meter at 0.0, and a body that
is past the age gate still raises it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Every frame, the dotted trajectory preview and each of the three faded
aim-guide segments were drawn on their own full-screen 1024x1280 alpha
surface. Allocating, clearing and blending four full-screen surfaces made
_draw_spawn_indicator the most expensive part of the launcher drawing.

The preview trail now uses one surface sized to the dots' bounding box
(inflated by the glow and OVERLAY_PADDING), and each guide segment gets a
surface sized to its own bounding box, drawn with an offset. The blits stay
separate on purpose: overlapping translucent strokes must keep building up
exactly as before. Both padding values are named settings knobs.

Test: across 60 random aims, positions, camera shakes and colours the new
helpers render byte-identical pixels to a full-screen reference.
Measured here: _draw_spawn_indicator went from 2.7-3.2 ms to 0.18-0.29 ms
per frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
radius, mass and inv_mass were properties that looked the tier up in TIERS
(and recomputed the mass) on every access. The pair solver reads them many
times per pair, per iteration, per substep, so this was a hot path.

A body's tier never changes (a merge creates a new body), so the three
values are now computed once in __post_init__ and stored as plain slot
attributes. Results are unchanged.

Tests: the three names are no longer properties, and every tier caches its
table radius and the same area-based mass as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
Every solver iteration (8 per substep, 2 substeps per frame) tested every
pair of bodies, so physics cost grew with n*n/2 and dominated crowded late
games.

_step_once now builds the candidate pairs once per substep with a uniform
grid, then runs all 8 solver iterations over just those pairs. A pair is a
candidate when its centres are within r_i + r_j + margin, where the margin
is the largest radius present + MAX_SPEED * dt + BROAD_PHASE_SLOP (a new
4 px settings knob). The grid's cells are as wide as the longest candidate
distance, so each body only checks its own and the eight neighbouring
cells. Pairs are sorted by index, so the solver visits contacts in exactly
the all-pairs order and results are bit-identical.

Tests: on 40 random mixed-size scenes the grid returns exactly the
brute-force contact set within the margin, in the same order; and over 45
frames of 8 random fast colliding scenes the solver matches an all-pairs
reference world bit for bit (positions, velocities and impact events). The
identity test fails if the margin is made too small.

Measured with a scratch benchmark (settled random piles, dt=1/60):
1.04/2.91/5.69/9.88 ms per frame before, 1.15/2.31/3.43/7.57 ms after, at
20/40/60/80 bodies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
_make_tone wrote two samples per moment for stereo and one for anything
else. On a 4, 6 or 8 channel mixer (surround output devices) each sound
buffer was therefore far too short, so tones played sped-up and garbled.

The sample is now repeated once per channel the mixer reports, which
covers mono, stereo and multichannel layouts with one line.

Test: the generated buffer holds frames * channels 16-bit samples for 1,
2, 4, 6 and 8 channels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
_load_progress caught the usual parse errors, but a save holding 1e999 or
Infinity parses as a float infinity and int() then raises OverflowError,
and a file nested very deeply makes the JSON reader raise RecursionError.
Either one escaped and crashed the game before the window appeared.

Both are now caught and treated as "no progress saved yet". The redundant
json.JSONDecodeError entry is dropped, since it is a ValueError.

Tests: saves holding 1e999, Infinity, or nesting 100000 levels deep load
as default progress, and a whole game can be built on top of one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01468mtoWW8MnhMw3KdyYP6j
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