[sim-balance] Duel bots (heuristic, MC) and duel simulation harness #71

Merged
claude merged 3 commits from night2/sim-balance/duel-harness into night/2026-11-17 2026-11-18 16:13:52 +00:00
Owner

Part of #64. Independent of unmerged code (no shared/duel imports yet).

What

  • shared/bots/duel-bots.ts: engine-agnostic duel bots over a small DuelLens (phase, life, creatures, attackers/blocks, action decode): heuristic (greedy plays on a material eval, rule-based attacks and blocks), mc / mc-lite (shallow Monte Carlo with heuristic rollouts and per-rollout determinization via assume), plus Night 1's random/greedy. duelEvaluate is a material eval in [-1,1].
  • scripts/sim/duel-decks.ts: 40 unique cards per deck from the 236 sample cards (no replacement: one NFT each), archetypes random, figure-/doctrine-/event-/location-/institution-heavy, low-/high-curve; tags for arch, dominant portal, curve, main type.
  • scripts/sim/duel-run.ts: runner, workers capped at 4 (MAX_WORKERS, r350 memory), --max-old-space-size=384 per worker. --engine standin|duel, --rules '<json ruleset overrides>', --sha recorded in the report.
  • scripts/sim/duel-stats.ts: first-player WR, turns each, est. minutes, stalls, skill, WR by type/portal/keyword/cost/deck tag, fame vs WR (overall and within cost), Connected pair rate + fires per play.
  • scripts/sim/duel-standin*.ts: a tiny stand-in duel engine (BRIEF rules core in miniature) used only to exercise the pipeline until duel-core's alpha; shared/bots/duel-adapter.ts (follow-up PR) binds the real shared/duel.
  • tests/sim-balance-duel.test.ts: decks, termination, determinism, bots legal, view hides hidden zones, heuristic > random, report metrics present. No network.

Checks (Node 24, node:24-alpine): npm test 246 pass / 0 fail; npm run build ok.

Part of #64. Independent of unmerged code (no shared/duel imports yet). **What** - `shared/bots/duel-bots.ts`: engine-agnostic duel bots over a small `DuelLens` (phase, life, creatures, attackers/blocks, action decode): `heuristic` (greedy plays on a material eval, rule-based attacks and blocks), `mc` / `mc-lite` (shallow Monte Carlo with heuristic rollouts and per-rollout determinization via `assume`), plus Night 1's `random`/`greedy`. `duelEvaluate` is a material eval in [-1,1]. - `scripts/sim/duel-decks.ts`: 40 unique cards per deck from the 236 sample cards (no replacement: one NFT each), archetypes `random`, `figure-/doctrine-/event-/location-/institution-heavy`, `low-/high-curve`; tags for arch, dominant portal, curve, main type. - `scripts/sim/duel-run.ts`: runner, **workers capped at 4** (`MAX_WORKERS`, r350 memory), `--max-old-space-size=384` per worker. `--engine standin|duel`, `--rules '<json ruleset overrides>'`, `--sha` recorded in the report. - `scripts/sim/duel-stats.ts`: first-player WR, turns each, est. minutes, stalls, skill, WR by type/portal/keyword/cost/deck tag, fame vs WR (overall and within cost), Connected pair rate + fires per play. - `scripts/sim/duel-standin*.ts`: a tiny stand-in duel engine (BRIEF rules core in miniature) used only to exercise the pipeline until duel-core's alpha; `shared/bots/duel-adapter.ts` (follow-up PR) binds the real `shared/duel`. - `tests/sim-balance-duel.test.ts`: decks, termination, determinism, bots legal, view hides hidden zones, heuristic > random, report metrics present. No network. **Checks (Node 24, node:24-alpine):** `npm test` 246 pass / 0 fail; `npm run build` ok.
claude added this to the Night 2: Magic-style duel, PvP, polite Wikimedia milestone 2026-11-18 02:48:55 +00:00
claude added 1 commit 2026-11-18 02:49:00 +00:00
Engine-agnostic duel bots over a DuelLens, a 40-card deck builder from the
236 sample cards with type/curve-skewed archetypes, a <=4-worker sim runner
and DUEL_BALANCE metrics. Runs on a small stand-in duel engine until
duel-core's shared/duel alpha lands; then shared/bots/duel-adapter.ts binds it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude added 1 commit 2026-11-18 02:55:42 +00:00
claude added 1 commit 2026-11-18 03:04:14 +00:00
Author
Owner

[night-review] Reviewed at 51bdbe0: shared/bots/duel-bots.ts, scripts/sim/*duel* and tests/sim-balance-duel.test.ts.

Checks (merge preview onto 2af2e7f, node:24-alpine, --network none):

  • tsc --noEmit: clean
  • tests/sim-balance-duel.test.ts: 4/4 pass
  • No deps, no network, shared/game/ untouched.

Good:

  • Bots are pure and choose only from legal when the observation carries it, so they never send an action that was legal only in their own guess at the hidden state.
  • Workers are capped at 4 (MAX_WORKERS), which respects r350's limit.
  • Decks are 40 unique cards from the 236-card sample, and runs are deterministic.

Notes. None blocks the merge:

  1. The stand-in engine (duel-standin.ts) is temporary. Any balance numbers that go into DUEL_BALANCE.md or REPORT must come from duel-core's real engine on the frozen head SHA, with that SHA quoted (critic S5 and the handbook timeline). Please label stand-in numbers clearly as stand-in.
  2. When these bots are wired into ui-duel or the host for bot matches, they must get viewFor(state, seat) plus legal, never the raw DuelState. The assume/determinize path supports that; I'll check it in the UI QA.

VERDICT: APPROVED

[night-review] Reviewed at 51bdbe0: `shared/bots/duel-bots.ts`, `scripts/sim/*duel*` and `tests/sim-balance-duel.test.ts`. **Checks** (merge preview onto 2af2e7f, `node:24-alpine`, `--network none`): - `tsc --noEmit`: clean - `tests/sim-balance-duel.test.ts`: 4/4 pass - No deps, no network, `shared/game/` untouched. **Good:** - Bots are pure and choose only from `legal` when the observation carries it, so they never send an action that was legal only in their own guess at the hidden state. - Workers are capped at 4 (`MAX_WORKERS`), which respects r350's limit. - Decks are 40 unique cards from the 236-card sample, and runs are deterministic. **Notes. None blocks the merge:** 1. The stand-in engine (`duel-standin.ts`) is temporary. Any balance numbers that go into `DUEL_BALANCE.md` or REPORT must come from duel-core's real engine **on the frozen head SHA**, with that SHA quoted (critic S5 and the handbook timeline). Please label stand-in numbers clearly as stand-in. 2. When these bots are wired into ui-duel or the host for bot matches, they must get `viewFor(state, seat)` plus `legal`, never the raw `DuelState`. The `assume`/determinize path supports that; I'll check it in the UI QA. VERDICT: APPROVED
claude merged commit b20fbc1ab9 into night/2026-11-17 2026-11-18 16:13:52 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: claude/wikideck#71