Files
wikideck/docs/game/DUEL_BALANCE.md
claudeanderic dbb89ce9c5 Night 2: 40-card Magic-style duel, PvP with owned decks, polite Wikimedia client, Android mining (#23)
Night 2 (2026-11-17), from the `claude/wikideck` fork's `night/2026-11-17` branch. It follows Night 1 (#22).

## What's in it
- **Duel engine** (fork #72, #80): 40-card decks of cards you own, Notability/Citations, keywords, effects T1–T12, Connected, a hidden-information-safe `viewFor`/`logFor`, and replay. Balance v1 tuning (#84) gives the first player about 51%.
- **Card profiles** (#70, #82): Figure, Location, Event, Institution or Doctrine, plus stats, keywords and rules text, all derived from real article data. Templates only.
- **Design and story** (#66, #69, #83): DUEL_DESIGN.md, plus the match log and the encyclopedic "Battle of X (2026)" recap.
- **PvP** (#74, #77, #81, #76, #85):
  - The server checks ownership, and 40-card eligibility is enforced.
  - Modes: Classic (ranked), Draft and Trending.
  - Invites, quick match, Elo, a ladder and recap pages. Online matches render on the duel board.
- **Duel board UI** (#79): MTG-style card faces and combat declaration, built for 360 px first.
- **Polite Wikimedia client** (#73, #75): throttled, cached and identified requests, the mint-path fix, and a prefetch pool.
- **Android mining** (#78): native RandomX, as a sideload build. The emulator mined a testnet block.
- **Testnet ops** (#67, #68).

PR numbers refer to `claude/wikideck`.

## Status
- **Tests:** 423, of which 422 pass, 0 fail and 1 is skipped. The build is OK (`node:24-alpine`, `--network none`).
- **Testnet:** running this commit (036489c) on r350.
- **Untouched:** no changes to `server/testnet/consensus.ts`, `randomx.ts`, `native/` or the mainnet compose.
- **Review:** night-review reviewed fork #66–#79. #80–#85 came from the agents' unfinished branches and were not reviewed.
- **Known gaps:**
  - The PvP end-to-end test hasn't been run (it needs two eom.dev accounts).
  - Bot matches aren't reachable from Play.
  - Card identity pre-bake hasn't been done.
  - The RandomX verifier latch (`server/testnet/randomx.ts:140`) is still open.

This PR is for Eric to merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: WikiDeck/wikideck#23

Co-authored-by: Claude <claude@eom.dev>
2026-11-18 18:12:24 +00:00

12 KiB
Raw Permalink Blame History

WikiDeck Duel: balance report

Owner: sim-balance (issue #64). Rules: docs/game/DUEL_DESIGN.md, docs/night2/BRIEF.md. Every proposal here is data only: ruleset keys (shared/duel ruleset) or derivation table values (DERIVE_RULES). No code changes are proposed in this file.

How to reproduce

# Node 24 (node:24-alpine on r350/inspiron). At most 4 workers on r350 (Night 1 ran out of memory).
npx tsx scripts/sim/duel-run.ts --engine duel --matches 3000 --workers 4 --mix default \
  --out ../sim-out/duel --label base --sha $(git rev-parse --short HEAD)
# Ruleset overrides as JSON (shallow-merged into the duel ruleset):
npx tsx scripts/sim/duel-run.ts --engine duel --rules '{"startingLife":18}' --label life18 ...
  • Card pool: the 236 real cards in docs/game/card-sample.json, derived by duel-cards (shared/duel/sample.ts, docs/game/duel-card-sample.json). No chain, no network.
  • Decks: 120 decks of exactly 40 unique cards (each NFT once), sampled without replacement (scripts/sim/duel-decks.ts). Half are uniform random; the rest are skewed archetypes: Figure-, Doctrine-, Event-, Location- and Institution-heavy, low curve and high curve.
  • Bots (shared/bots/duel-bots.ts): heuristic (greedy plays on a material evaluation, rule-based attacks and blocks), mc/mc-lite (shallow Monte Carlo over heuristic rollouts, re-sampling hidden cards on every rollout, so it is not clairvoyant), greedy (one-ply) and random. Bots see only viewFor of their seat.
  • Balance stats use bot-symmetric games only (both seats the same bot). Mixed pairs measure skill.
  • Card win rate = win rate of the seat that played the card, in games where only one side played it. It has a positive baseline (winners play more cards), so compare cards against each other and against the "all plays" baseline, not against 50%.
  • Minutes are a model, not a measurement: 10 s per turn plus 4 s per atomic action (each play, attacker toggle, block and confirm).
  • Connected pair rate = share of all 27,730 sample pairs with any Connected tier (connectedTier).

Targets

Metric Target Source
First-player win rate 48–54% DUEL_DESIGN §2.6 (issue #64 asks 48–52%)
Median game length 8–12 turns each, 8–15 minutes issue #64
Stalls < 5% reach turn 20 each DUEL_DESIGN §2.6
Connected 15–30% of pairs BRIEF
Famous cards bigger and pricier, not strictly better: fame vs win rate r ≈ 0 within a cost BRIEF

Balance v1 (00:05, from the v1 runs below)

Ship as ruleset defaults (DEFAULT_DUEL_RULESET, data only):

Key From To Why
secondPlayerCitations 0 1 First player 60.1% → 54.7% [53–57] (v1-cand, n≈2700). The edge is tempo, and this is the only lever that moved it.
turnCap null 40 (20 each) Games past 20 turns each 3.4% → 0%. 3.9% of games are decided at the cap; median and p90 unchanged (8 / 12).

v1-cand (both changes, 3000 matches, engine 4623930 + duel-cards 067de83): first player 54.7% [53–57], turns each 6 / 8 / 12, est. minutes median 7.9 / p90 13.5, 0 library-outs, Connected 17.2% of pairs.

The first-player rate sits at the top edge of DUEL_DESIGN's 48–54% band (issue #64 asked for 48–52%). secondPlayerCitations: 2 was not tested; duel-design prefers to accept ~54% over a 2-Citation swing.

Landed: duel-core set both as DEFAULT_DUEL_RULESET values on engine-wip 0eb80d2. night-review's random-play soak there (300 matches) gives a first-player rate of 51.0%, down from 62.7%, with 0 leaks, exact replay, and turnCap ending forced stalls at turn 40. duel-design recorded both in DUEL_DESIGN v1.3 (#66).

Not shipped, with the evidence:

  • Second seat +1 opening card: no effect (60.7%); the mulligan and the 7-card hand limit absorb it.
  • garrisonStep 15: Location-heavy decks +4 pts, but games get longer (p90 14, 4.5% past 20 turns).
  • territoryCap 3, locationsPerTurn 2, stubMax 1, startingLife 16/24: ≤ ±3 pts on first player or Location decks.
  • libraryEmpty: reshuffle: games stretch out (the run didn't finish in 9 min); BRIEF keeps the MTG rule.
  • firstPlayerDraws: true: worsens the edge (+1.7 pts).

Open for v1.1: Locations. Location-heavy decks win ~17–21% in every variant, and Location cards are the weakest type (47–48%). The T2 rider "When this enters, draw a card" (v1-cand-ld) raises the Location card to 51.7% but does not help Location-heavy decks (16.5%), pushes the first player back to 58.4%, and brings back library-outs (117 of 3000). It needs another lever first, e.g. the conditional version ("if you already control 2 or more Locations") or a Location body (garrisonStep) change, tested together with spc1. Since random collections are ~32% Locations, this matters for real players.

Healthy, leave alone: Connected (17.2% of pairs, fires on 28% of plays, inside 15–30%). Famous cards are bigger, not strictly better: fame vs card win rate r = 0.10–0.20 overall, ≈0 or negative within a cost. Keywords all net positive; Featured strongest, kept per duel-design.

Frozen head (01:15)

Not run. At the 01:15 freeze night/2026-11-17 was still at 2af2e7f: no PR had merged all night (night-lead unreachable, see #53), so there was no frozen head containing the duel engine. The reference result is therefore v1-cand at engine-wip 4623930 + duel-cards 067de83 (not frozen head). At 01:16 the newest unmerged heads were: engine-wip 0eb80d2 (balance v1 as defaults), duel-cards 5076299, duel-adapter d97cbc2. Once they merge, re-run with no overrides:

npx tsx scripts/sim/duel-run.ts --engine duel --workers 4 --mix fast --matches 3000 --label frozen --sha $(git rev-parse --short HEAD)

Results

v1 runs: engine-wip 4623930 + duel-cards 067de83 (Doctrines working)

Run by ui-duel on inspiron-3670 with this harness (duel-adapter acd2c49/7102239), Node 24, 4 workers, --mix fast, 120 decks. Not yet the frozen head; see "Frozen head" below.

Run Overrides n First player (sym) Turns each p10/med/p90 >20 turns each Library-out Loc-heavy Doc-heavy Fig-heavy
v1-base {} 3000 60.1% [58–62] 6 / 8 / 12 3.4% 2.0% 20.5% 42.8% 66.6%
v1-spc1 {"secondPlayerCitations":1} 1500 54.4% [52–57] 6 / 8 / 12 3.9% 2.2% 20.8% 45.9% 63.0%
v1-extra1 second seat +1 opening card (sim-only hook) 1500 60.7% [58–63] 6 / 8 / 12 3.6% 2.3% 16.8% 52.9% 64.7%
v1-garr15 derive garrisonStep 15 1500 58.5% [56–61] 6 / 8 / 14 4.5% 2.3% 24.9% 45.3% 65.3%
v1-terr3 {"territoryCap":3} 1500 59.7% [57–62] 6 / 8 / 12 3.0% 1.9% 21.3% 49.4% 64.7%
v1-cap40 {"turnCap":40} 1500 60.2% [58–63] 6 / 8 / 12 0.0% 0 (turnCap 3.1%) 19.8% 48.3% 65.9%
v1-cand (3000) {"secondPlayerCitations":1,"turnCap":40} 3000 54.7% [53–57] 6 / 8 / 12 0.0% 0 (turnCap 3.9%) 17.9% 41.7% 64.2%
v1-cand-ld (3000) v1-cand + every Location "When this enters, draw a card" 3000 58.4% [57–60] 6 / 8 / 12 0.0% 3.9% (turnCap 0.4%) 16.5% 39.0% 62.5%
v1-combo garr15 + {"secondPlayerCitations":1,"territoryCap":3,"turnCap":40} 1500 52.8% [50–55] 6 / 8 / 13 0.0% 0 (turnCap 4.4%) 21.3% 43.0% 61.8%

Card type WR (seat that played it), v1-base → v1-combo: Doctrine 55.8 → 56.4, Event 51.1 → 51.8, Figure 58.8 → 58.4, Institution 53.1 → 52.8, Location 48.1 → 48.0. Est. minutes v1-combo 5.6 / 8.4 / 14.9.

v1-base other numbers: est. minutes 5.4 / 7.9 / 13.2; Connected 17.2% of pairs, 28.1% of plays (6.96 per game); fame vs card WR r = 0.20 (top vs bottom decile 62.1% vs 53.6%, both above the played-card baseline); card type WR Doctrine 55.8%, Event 51.1%, Location 48.1%.

Old-tree sweep (engine 5cd0ffb + duel-cards ae14bc7, Doctrines inert): relative effects only

Run Overrides First player Turns each p10/med/p90 >20 turns Loc-heavy Doc-heavy Fig-heavy
alpha-base (4000) {} 57.8% [56–59] 6 / 8 / 21 10.3% 23.2% 29.5% 73.1%
p1draws {"firstPlayerDraws":true} 59.5% [57–62] 6 / 8 / 19 9.4% 24 27 74
life24 {"startingLife":24} 55.0% [52–58] 6 / 9 / 24 12.2% 21.8% 29.7% 72.3%
life16 {"startingLife":16} 57.3% [55–60] 5 / 8 / 16 7.7% 27.9% 29.1% 68.2%
terr3 {"territoryCap":3} 56.0% [53–59] 6 / 8 / 18 9.3% 23.9% 30.2% 71.1%
loc2 {"locationsPerTurn":2} 55.1% [52–58] 6 / 8 / 20 9.8% 24.4% 29.1% 71.1%
stub1 {"stubMax":1} 55.0% [52–58] 6 / 8 / 17 7.7% 20.3% 30.8% 68.2%
reshuffle {"libraryEmpty":"reshuffle"} stopped after 9 min: games stretch out

Baseline, engine alpha (duel-core engine-wip 5cd0ffb + duel-cards ae14bc7, merged locally). Not the frozen head.

Superseded: at duel-cards ae14bc7 Doctrines attached but gave no ±k (fixed in 067de83). Doctrine numbers below are therefore wrong, and everything else is slightly off. See the v1 runs. 4000 matches, --mix fast (90% heuristic mirrors, 5% heuristic vs random, 5% heuristic vs greedy), 120 decks, 0 engine errors.

Metric Value Target
First-player win rate 57.8% [56–59] 48–52%
Turns each p10 / median / p90 6 / 8 / 21 8–12
Est. minutes p10 / median / p90 5.6 / 8.6 / 20.3 8–15
Games past 20 turns each 10.3% < 5%
Library-out losses 7.2% (70% of the long games)
Connected pair rate / fires per play 17.2% / 28% 15–30%
Fame vs card WR within each cost r = −0.24, −0.65, −0.54, +0.12, −0.14, +0.07 (costs 1–6) ≈ 0
heuristic vs greedy / random 72.9% / 95.1%

Findings

  1. First-player edge is tempo. 68.5% in games under 7 turns each, 57% at 7–9, ~54% in longer games. firstPlayerDraws: true raises it to 59.5% (1500 matches), so the edge needs compensation for the second seat, not a draw change.
  2. Deck composition dominates. Win rate vs decks without the tag: Figure-heavy 73%, random 67%, high-curve 46%, Event-heavy 44%, Institution-heavy 37%, low-curve 35%, Doctrine-heavy 30%, Location-heavy 23%. By card type (seat that played it): Figure 58.8%, Institution 51.3%, Event 50.2%, Doctrine 47.3%, Location 47.1%. Every one of the 8 bottom cards is a Location: past the 2-Territory cap a Location is only a 0/1–0/4 Garrison. Random collections are ~32% Locations (75 of 236), so this matters for real players, who can't choose what they mine.
  3. Famous cards are not strictly better. Within a cost, fame and win rate are uncorrelated or negative (the keyword tax). Cost-6 cards win 61% when played, but that includes a survivorship effect (you only reach 6 Citations in longer games you're still in).
  4. Keywords are all net positive. When played: Featured 67.6%, Multilingual 67.6%, Well-sourced 59.6%, Protected 59.2%, Translated 59.0%, Legacy 58.6%, Stub 58.2%, Local 54.6%, none 48.6%. Featured is the strongest relative to its tax.
  5. Long games are not mainly Location decks: past 20 turns each in 16% of low-curve games, 13% random, 11% Location-heavy, 3% Event-, Institution-heavy and high-curve. Boards stall and decks run out.

Caveats: the heuristic bot may under-use Doctrines and Events, and may be too cautious to attack into walls (the MC-mirror check was stopped, see below), so the Doctrine/Event numbers and the stall rate are upper bounds on the problem.

The sweep on r350 was stopped at 23:00 when r350 ran out of memory; ui-duel re-ran it on inspiron (tables above).