(Adaptive Loop) Initial Plan
This commit is contained in:
7 files changed
+1096
No files matched your search
@@ -0,0 +1,40 @@
|
||||
---
|
||||
name: deterministic-game-core
|
||||
description: Build and verify deterministic turn-based game simulations with pure transitions, exact previews, replayable state, and vertical behavior tests.
|
||||
---
|
||||
|
||||
# Deterministic Game Core
|
||||
|
||||
## When to Use
|
||||
|
||||
Use when implementing or changing Adaptive Loop's simulation, scenario rules, previews, saves, replays, or win/lose logic.
|
||||
|
||||
## Procedure
|
||||
|
||||
1. Keep the domain model serializable and independent of rendering.
|
||||
2. Route every committed action through one pure transition: `nextState(state, action)`.
|
||||
3. Generate previews by calling the same transition on cloned state. Never maintain separate forecast rules.
|
||||
4. Resolve each turn in a fixed documented order: chamber rotation → channel reconnection/flow → consumption and growth → biological interactions → migration → adaptation → environmental advance → objective/collapse evaluation.
|
||||
5. Test vertical behavior through public seams. Use worked states and literal expected outcomes, not assertions that reimplement the production algorithm.
|
||||
6. Cover at least: clockwise/counterclockwise loop rotation, overlapping-loop movement, flow direction, capped populations/resources, adaptation threshold, local trait activation, trait cost, species spillover, pressure-driven environment mutation, win, collapse, exact save/restore, preview/commit equality, and deterministic replay.
|
||||
7. When a defect appears, search sibling actions and scenarios for the same failure class; fix the shared transition once.
|
||||
|
||||
8. Compare canonical domain state only: stable-key serialization or normalized deep equality must exclude timestamps, animation, focus, hover, and other transient UI state.
|
||||
9. Scenario verification must replay one known winning and one known losing route per scenario and all reachable campaign inheritance combinations.
|
||||
|
||||
## Pitfalls
|
||||
|
||||
- No randomness unless seeded and serialized; prefer no randomness.
|
||||
- No floating-point simulation where small capped integers suffice.
|
||||
- No mutation of input state.
|
||||
- No UI-owned game rules.
|
||||
- No private-method or implementation-coupled tests.
|
||||
- No snapshots whose expected value is generated by the same logic under test.
|
||||
|
||||
## Verification
|
||||
|
||||
- Identical canonical state plus action produces structurally identical canonical output and deterministic event attribution.
|
||||
- Preview canonical output equals committed canonical output for every legal action in representative states.
|
||||
- Saving and restoring preserves canonical state and the exact next transition.
|
||||
- Replaying an action log from a scenario baseline plus inheritance snapshot reproduces final state and outcome.
|
||||
- Each scenario has verified winning/losing routes; all reachable campaign inheritance combinations remain solvable.
|
||||
Reference in new issue
Block a user