S3-071: Make AI recover from economic deadlocks
Parent and ownership
Parent epic: https://github.com/stacksjs/the-settlers-iii-remake/issues/11
Source owner: stacksjs/the-settlers-iii-remake. Master roadmap: https://github.com/stacksjs/the-settlers-iii-remake/issues/4.
Problem and observable result
Detect food, tool, population, and delivery shortages. Recover through legal actions. Recognize genuinely unrecoverable states.
The current application is a browser prototype. Passing the Riverlands campaign does not establish original-game or native parity. This issue is complete only when its stated behavior has retained evidence.
Evidence and interfaces
AI submits the same commands as players and observes an allowed player view. Difficulty is explicit and seeded. AI must not create resources or use concealed enemy information.
Pin the inspected revisions and fixture hashes in the implementation evidence. Original-game observations govern rules and timing. JSettlers is implementation evidence, not an authoritative balance specification. Unknown values remain explicitly unverified.
Acceptance criteria
- Detect food, tool, population, and delivery shortages.
- Recover through legal actions.
- Recognize genuinely unrecoverable states.
- The visible result agrees with the underlying simulation or platform state, including failure paths.
- Tests exercise the maintained public interface and retain reproducible fixtures or execution receipts.
Test matrix
- Remove a critical AI supply route.
- Exhaust resources and inspect recovery choices.
- Exercise invalid input, cancellation or interruption, and repeated execution where this interface permits them.
- Verify determinism/conservation for simulation changes and resource ownership/disposal for platform changes.
- Run owning-repository lint, relevant type checks and tests. Capture actual native output for native capability claims.
Scope constraints
Implement this behavior as a complete verifiable slice. Do not silently expand into adjacent tickets or substitute simplified gameplay. Keep the shared TypeScript simulation, shared stx signals, and ts-css conventions. Native gameplay and HUD must not depend on a WebView. HomeOS reuse must not introduce a kernel dependency into the game. Existing unrelated edits and authored guidance must be preserved.
Blocked by
- https://github.com/stacksjs/the-settlers-iii-remake/issues/49
- https://github.com/stacksjs/the-settlers-iii-remake/issues/72
Upstream release and adoption
Application behavior belongs here. If a reproduction identifies a framework defect, repair and release its owning source first, update Stacks where affected, then install the verified packages here.
No node_modules edits, copied runtimes, generated-source string patches, fabricated globals, successful no-op implementations, or skipped release gates. Push tested conventional commits as Chris to the owning origin/main without coauthor trailers or force pushes.
Completion evidence
- Implementation commits and relevant upstream issue links.
- Exact checks and results, fixture hashes, and screenshots/native execution evidence where applicable.
- Published package versions, downstream lockfile identity, and release receipts when affected.
- Remaining limitations stated explicitly. Partial work does not close this issue.
Verified completion, 2026-10-23
Implemented by 515d6a1, with the complete reproducible S3-071 acceptance receipt. The receipt retains fixture seeds/hashes, actual food/tool/population/delivery recovery, impossible bootstrap results, cancellation and save/replay checks, resource conservation and owner-only visibility. No grants, concealed enemy knowledge or invented balance values were introduced.
The complete owning suite passed 200 tests with zero failures (20,782 assertions); the focused AI suite passed 23 tests/501 assertions. Lint and application/tools/stx types passed. The subsequent verified framework adoption preserves the AI source and has successful main CI on ec3f897. This closes the engineering AI slice only; original-game balance observations and native capability claims remain separately scoped.