Merge feature/catan-engine into dev (Katan rules engine + AI, WALA-119) #2

Merged
devadmin merged 3 commits from catan-into-dev into dev 2026-10-14 15:57:04 -06:00
Owner

Summary

Brings the Katan rules engine into dev; supersedes closed PR #1 ("Will merge to dev later, then to main").

  • Katan engine, board, model and heuristic AI (game/catan/*), 51 unit tests, docs/RULES-catan.md.
  • Shared code: adds Engine.isLegalMove() (default move in legalMoves(...), so existing games are unchanged) and switches MatchController to call it. Catan overrides it because trade offers are too combinatorial to enumerate.
  • Katan catalogue entry restored (GameCatalog.CATAN, available = false): Coming soon on dev builds, hidden from production until the screen lands. CatalogTest updated to match. This had been dropped with Gitea's old 5c797c8 during the GitHub-lineage migration; CatanRules.kt does not compile without it.
  • docs/README.md conflict resolved: engine's docs index kept, dead CI.md link pointed at the root README.

Testing

CI dispatched on this branch (run 24): build, unit tests (incl. Catan suite) and lint all green. Nothing published.

Review notes

  • Not yet reviewed line by line: CatanRules.kt (905 lines).
  • Merging to dev triggers a dev-channel build and Cloudflare deploy of this code; no playable Katan UI yet.
  • Worth a dev install to confirm no regression in the other games, since MatchController changed.

Co-Authored-By: Claude Sonnet 5.5 [email protected]
Claude-Session: https://claude.ai/code/session_01JdMNbY5hLR7FjtfEE712xG

## Summary Brings the Katan rules engine into `dev`; supersedes closed PR #1 ("Will merge to dev later, then to main"). - Katan engine, board, model and heuristic AI (`game/catan/*`), 51 unit tests, `docs/RULES-catan.md`. - Shared code: adds `Engine.isLegalMove()` (default `move in legalMoves(...)`, so existing games are unchanged) and switches `MatchController` to call it. Catan overrides it because trade offers are too combinatorial to enumerate. - Katan catalogue entry restored (`GameCatalog.CATAN`, `available = false`): *Coming soon* on dev builds, hidden from production until the screen lands. `CatalogTest` updated to match. This had been dropped with Gitea's old `5c797c8` during the GitHub-lineage migration; `CatanRules.kt` does not compile without it. - `docs/README.md` conflict resolved: engine's docs index kept, dead `CI.md` link pointed at the root README. ## Testing CI dispatched on this branch ([run 24](https://git.wallacenet.ca/devadmin/ProLibertateGames/actions/runs/24)): build, unit tests (incl. Catan suite) and lint all green. Nothing published. ## Review notes - Not yet reviewed line by line: `CatanRules.kt` (905 lines). - Merging to `dev` triggers a dev-channel build and Cloudflare deploy of this code; no playable Katan UI yet. - Worth a dev install to confirm no regression in the other games, since `MatchController` changed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdMNbY5hLR7FjtfEE712xG
devadmin added 3 commits 2026-10-14 15:42:23 -06:00
Katan rules engine + AI (WALA-119)
CI / Build and check (pull_request) Failing after 8s
3a930f5423
The island game as a pure-Kotlin state machine under game/catan/, wired to
the upstream GameRules / GameAi contract and fully unit-tested on the JVM.

- game/catan/: CatanModel (state, moves, phases), CatanBoard (19-hex
  geometry, seeded island generation with the 6/8 separation rule, shared
  vertex/edge graph), CatanRules (setup, production, the seven and the
  robber, domestic and maritime trade, building, development cards,
  Longest Road, Largest Army, win detection), CatanAi (a heuristic opponent
  that reads only public information).
- GameRules.isLegalMove: a defaulted structural legality check so a game
  with a combinatorial move space (Catan's trade offers) is gated the same
  way as one with an enumerated move list; MatchController uses it.
- GameCatalog.CATAN: the catalogue entry, listed but not yet available
  (descriptor and screen land with the screen task).
- Tests: 51 across CatanBoardTest, CatanRulesTest and CatanAiTest —
  geometry invariants, generation balance, setup, production, the
  seven/robber, both trade types, development-card timing, Longest Road
  edge cases, Largest Army, win detection, and AI games played to a result.
- docs/RULES-catan.md, in the per-game style, with the rule choices and
  the known gaps called out.

Two real engine bugs found and fixed while getting the suite green:
VERTEX_EDGES counted each shared edge once per adjacent hex, so an
interior vertex looked like it had six edges (which also double-counted
segments in the Longest Road search and duplicated setup moves); and the
applyRoll seven-transition was a discarded expression, so a seven never
left AWAIT_ROLL. Three test fixtures rolled from the PLAYING phase and two
assumed a two-seat rotation; corrected to the phases and seat order the
engine actually uses.

Verified: ./gradlew :app:testDebugUnitTest --offline — 679 tests, 0 failures.

Co-Authored-By: Paperclip <[email protected]>
Brings in the Katan rules engine, board, model and AI (WALA-119), its 51 unit
tests and docs/RULES-catan.md. Only conflict was docs/README.md, which the
GitHub-lineage migration had dropped: kept the engine branch's index and
pointed the CI link (docs/CI.md no longer exists) at the root README.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdMNbY5hLR7FjtfEE712xG
Restore the Katan catalogue entry the engine depends on
CI / Build and check (pull_request) Successful in 13m46s
CI / Deploy to Cloudflare Pages (pull_request) Skipped
fb59372802
The Option 2 migration dropped Gitea's 5c797c8, which added GameCatalog.CATAN
and a Katan entry (available = false: Coming soon on dev, hidden from
production). CatanRules.kt references GameCatalog.CATAN, so the merge did not
compile without it. Taken verbatim from feature/catan-engine, with the
matching CatalogTest assertions.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdMNbY5hLR7FjtfEE712xG
devadmin merged commit a778e4732f into dev 2026-10-14 15:57:04 -06:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: devadmin/ProLibertateGames#2