Add game-simulation package with multi-run balance testing, fix stalled-pipeline trap
Adds a full simulation harness (game-simulation package) with greedy/random strategies, 36-metric diagnostics, multi-run orchestration via child processes, and a statistical interpreter. Includes 2.3x engine performance optimizations (research bonus caching, per-DC dirty tracking, reduced allocations in tick pipeline, single-pass loops). Fixes a critical balance bug where training pipelines stalled on insufficient VRAM would permanently block training slots — the engine never re-checked stalled pipelines, and the greedy strategy didn't pre-check VRAM requirements. This caused 20-25% of seeds to get stuck in Scale-up era. All three fixes (engine un-stalling, strategy VRAM pre-check, stalled pipeline cancellation) bring pass rate from 75% to 100% across 20 random seeds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
name: Balance Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'packages/shared/src/constants/**'
|
||||
- 'packages/game-engine/src/**'
|
||||
- 'packages/game-simulation/**'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'packages/shared/src/constants/**'
|
||||
- 'packages/game-engine/src/**'
|
||||
- 'packages/game-simulation/**'
|
||||
|
||||
jobs:
|
||||
balance-simulation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run greedy simulation
|
||||
run: pnpm --filter @ai-tycoon/game-simulation simulate:ci
|
||||
|
||||
- name: Run random simulation
|
||||
if: always()
|
||||
run: |
|
||||
cd packages/game-simulation
|
||||
npx tsx src/simulate.ts --strategy random --ticks 28800 --json --seed 42
|
||||
|
||||
- name: Upload balance reports
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: balance-reports
|
||||
path: |
|
||||
packages/game-simulation/balance-report*.json
|
||||
packages/game-simulation/balance-metrics*.csv
|
||||
|
||||
multi-run-balance:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run multi-simulation (5 runs)
|
||||
run: pnpm --filter @ai-tycoon/game-simulation multirun -- --runs 5 --parallel 2 --strategy greedy --ticks 28800 --no-timeseries
|
||||
|
||||
- name: Interpret results
|
||||
if: always()
|
||||
run: pnpm --filter @ai-tycoon/game-simulation interpret -- --summary packages/game-simulation/multirun-summary.csv
|
||||
|
||||
- name: Upload multi-run reports
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: multirun-reports
|
||||
path: packages/game-simulation/multirun-*.csv
|
||||
Reference in New Issue
Block a user