How tucefull/3-muenzen-spiel works
Purpose and Entry Points
This is a presentation-oriented Vue 3/TypeScript simulator for the imperfect-information three-coin game. It demonstrates a randomized, small-memory Player 1 strategy and exposes each round as a trace.
The primary desktop entry is Electron: electron/main.cjs, which loads the Vite frontend rooted at index.html. The frontend bootstraps from src/main.ts into src/App.vue.
Desktop Shell and Runtime Boundary
Electron provides the application window and development launch integration, while Vue/Vite owns the rendered UI.
• Electron main process: electron/main.cjs
• Vite application document: index.html
• Build/runtime configuration: vite.config.ts, package.json
The game engine runs in the frontend TypeScript context; no server, database, or network service is represented.
Application Composition
src/App.vue is the top-level orchestration layer. It connects simulation state and commands to the interactive display.
• Root composition: src/App.vue
• Simulation state/controller composable: src/composables/useSimulation.ts
• Shared UI styling: src/styles.css
The composable is the UI-to-domain boundary: controls such as step, batch runs, seed/reset behavior, trace retention, and display state should remain outside the core game rules.
Simulation Control Flow
User actions flow from the application UI into useSimulation, which advances or resets a simulation and returns reactive state for rendering. Batch actions (“Run 10” / “Run 100”) repeatedly apply the same single-round transition.
• Controller/state layer: src/composables/useSimulation.ts
• Round simulation orchestration: src/game/simulator.ts
• Core state and trace contracts: src/game/types.ts
Each completed round produces state suitable for both subsequent strategy decisions and a human-readable trace record.
Game Domain and Rule Engine
The engine encodes the three-coin game’s authoritative transitions: Player 1 acts from only the observable count of heads/tails, Player 2 flips the selected coin and may swap the other two, and terminal states are HHH and TTT.
• Rule/state transition logic: src/game/engine.ts
• Simulation sequencing: src/game/simulator.ts
• Domain types: src/game/types.ts
This is the main correctness boundary: Vue components should render domain outputs, not duplicate legal-move or win/loss logic.
Player Strategies and Randomness
Player strategies are separated from engine mechanics. Player 1 implements the randomized, memory-limited behavior central to the demo; Player 2 supplies the adversarial flip/swap behavior. Randomness is seedable for reproducible runs.
• Player 1 strategy: src/game/player1.ts
• Player 2 strategy: src/game/player2.ts
• Seeded RNG abstraction: src/game/rng.ts
The RNG should be injected or passed through simulation/strategy paths rather than using uncontrolled ambient randomness, preserving deterministic traces for a given seed.
Presentation Components
The UI is split between current-game controls/status and the round history. Optional coin visibility is a presentation concern and must not alter Player 1’s observation model.
• Current game panel: src/components/GamePanel.vue
• Trace rendering: src/components/TraceTable.vue
• Root wiring: src/App.vue
Main entry points: simulator.ts Round simulator · types.ts Game contracts · App.vue App root · useSimulation.ts Simulation controller
Components 15
Desktop shell
- Electron main · Creates the application window and loads the frontend.
electron/main.cjs - Vite document
index.html - Vite config
vite.config.ts
Vue presentation
- App root · Composes simulation state with presentation components.
src/App.vue - Vue bootstrap
src/main.ts - Game panel · Shows current state, controls, and status.
src/components/GamePanel.vue - Trace table · Renders completed-round history.
src/components/TraceTable.vue - Shared styles
src/styles.css
Simulation domain
- Simulation controller · Owns reactive state, commands, seed/reset, and trace retention.
src/composables/useSimulation.ts - Round simulator · Sequences one-round transitions and trace creation.
src/game/simulator.ts - Game engine · Authoritative legal moves and terminal-state transitions.
src/game/engine.ts - Game contracts · State and trace contracts shared across the simulation.
src/game/types.ts - Player 1 strategy · Uses only observable heads/tails counts.
src/game/player1.ts - Player 2 strategy · Flips the selected coin and may swap the others.
src/game/player2.ts - Seeded RNG · Provides reproducible random decisions.
src/game/rng.ts
Connections 21
- Electron main → Vite document: loads frontend
- Vite config → Vite document: builds
- Vite document → Vue bootstrap: starts
- Vue bootstrap → App root: mounts
- App root → Simulation controller: uses
- App root → Game panel: renders
- App root → Trace table: renders
- App root → Shared styles: applies
- Game panel → Simulation controller: issues controls
- Simulation controller → Round simulator: steps and resets
- Simulation controller → Game contracts: exposes reactive state
- Trace table → Game contracts: displays traces
- Round simulator → Game engine: applies transitions
- Round simulator → Player 1 strategy: gets Player 1 action
- Round simulator → Player 2 strategy: gets Player 2 action
- Round simulator → Seeded RNG: passes seeded randomness
- Round simulator → Game contracts: creates round trace
- Game engine → Game contracts: reads and produces state
- Player 1 strategy → Seeded RNG: randomizes choices
- Player 1 strategy → Game contracts: uses observation contract
- Player 2 strategy → Game contracts: uses action contract