Skip to content

Fix: Avoid Adjacent Red Pips (implementing official spiral pattern)#363

Merged
bcollazo merged 10 commits into
masterfrom
fix/adjacent-red-pips
Mar 22, 2026
Merged

Fix: Avoid Adjacent Red Pips (implementing official spiral pattern)#363
bcollazo merged 10 commits into
masterfrom
fix/adjacent-red-pips

Conversation

@bcollazo

Copy link
Copy Markdown
Owner

Summary

Implements official spiral number-token placement for random maps to prevent adjacent red pips, wires the configuration through the game/CLI stack, and refactors tile model types into dedicated modules to break circular dependencies.

Changes

Official spiral number placement

  • Added official_spiral as the default number-placement mode for generated maps.
  • Added a spiral_land_coordinates(...) generator to walk land tiles in coast-following spiral order.
  • Added BASE_NUMBERS_IN_SPIRAL_ORDER and use it to assign number tokens after tile/resource placement while skipping the desert.
  • Applied this logic to base and mini map templates.
  • Kept random placement available for callers and tests that depend on the legacy fully-random setup.

CLI and game wiring

  • Added --config-number-placement to catanatron-play with official_spiral and random choices.
  • Extended GameConfigOptions, build_map(...), Game, and State so number-placement selection flows from the CLI into board creation.
  • Updated board-related helpers/tests that need stable legacy behavior to explicitly request random.

Model refactor

  • Moved tile dataclasses and related aliases into catanatron/models/tiles.py.
  • Moved the Coordinate alias into catanatron/models/coordinate_system.py.
  • Updated imports accordingly.

Test updates

  • Added coverage for spiral traversal ordering and validation errors.
  • Added repeated-map tests to verify official spiral placement avoids adjacent 6/8 tiles.
  • Added CLI coverage for random number placement.
  • Updated reproducibility expectations and feature/board tests to account for the new default placement.

Why

Random number-token placement can create adjacent 6 and 8 tiles, producing boards that are much swingier than standard Catan setups. This change makes generated boards follow the official spiral-style placement by default while preserving an escape hatch for fully-random layouts.

Fixes #344

@netlify

netlify Bot commented Mar 22, 2026

Copy link
Copy Markdown

Deploy Preview for catanatron-staging canceled.

Name Link
🔨 Latest commit 5783bdf
🔍 Latest deploy log https://app.netlify.com/projects/catanatron-staging/deploys/69bff14d843288000893c026

@netlify

netlify Bot commented Mar 22, 2026

Copy link
Copy Markdown

Deploy Preview for catanatron-staging canceled.

Name Link
🔨 Latest commit 2f0242e
🔍 Latest deploy log https://app.netlify.com/projects/catanatron-staging/deploys/69bff61e120fa40008c7472f

@coveralls

coveralls commented Mar 22, 2026

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23404651851

Details

  • 99 of 103 (96.12%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.4%) to 93.904%

Changes Missing Coverage Covered Lines Changed/Added Lines %
catanatron/catanatron/models/spiral.py 32 33 96.97%
catanatron/catanatron/models/tiles.py 28 29 96.55%
catanatron/catanatron/models/map.py 24 26 92.31%
Totals Coverage Status
Change from base Build 23323908990: 1.4%
Covered Lines: 3235
Relevant Lines: 3445

💛 - Coveralls

@bcollazo bcollazo merged commit d54af65 into master Mar 22, 2026
15 checks passed
@bcollazo bcollazo deleted the fix/adjacent-red-pips branch March 22, 2026 15:27
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.

Ensure Red Number Tokens are not next to each other

2 participants