This commit is contained in:
Forrest 2026-10-01 17:20:33 -04:00
parent 5368464042
commit 937f44defe
100 changed files with 10185 additions and 2042 deletions

View file

@ -13,6 +13,8 @@ npm run sim -- -n 5000 # 5,000 greedy-vs-greedy games
npm run sim -- -n 5000 --card-report # plus how each card did
npm run sim -- --south greedy --north nocards # does playing cards help?
npm run sim -- --rule secondPlayer.cards=2 # try a rule variant (see src/rules.ts)
npm run sim -- --rule board=grid4 # the 4×4 test board (win with 12 of 16)
npm run sim -- --rule board=lanes # three lanes, linked only across the middle (11 of 15)
npm run sim -- --log --seed 7 # watch one game, play by play
npm run sim -- --json out/run.json # also save every game's result
npm run sim -- --help # all options and bots
@ -29,13 +31,13 @@ of how much a card helps.
- **Rules:** everything in `rules.md`: setup, rounds of alternating commands (or whole turns, with
`--rule commands.on=false`), placement, recall and advancing, attacks, combat with Health and
damage (or one-roll combats with tie rerolls, with `--rule health.on=false`; `health.override=8`
gives every Avatar the same Health), captures, levels and RAM, Avatar unlocks, Firewalls,
gives every Anomaly the same Health), captures, levels and Bandwidth, Anomaly unlocks, Firewalls,
Salvage, response windows and chains, and the win condition.
- **Every card:** all 83 set 1 cards in `../decks/files-deck-1/cards.csv` have a script, including
Avatar Abilities. The 52 set 2 cards (`Set` = 2) have none yet, so they're skipped unless you pass
Anomaly Abilities. The 52 set 2 cards (`Set` = 2) have none yet, so they're skipped unless you pass
`--set 2` or `--set all`; the bots never play an unscripted card. Unclear card text follows the readings in `rules.md` → Card Rules; the ones marked ⚠
are guesses waiting for a decision.
- **Card edits:** stats (RAM, Cores, Health, slots) come straight from the CSV. Each script records the text
- **Card edits:** stats (Bandwidth, Cores, Health, slots) come straight from the CSV. Each script records the text
it was written for, so if you reword a card the sim warns you, and `npm test` fails until the
script is updated.
@ -47,6 +49,20 @@ captures, card triggers) until it needs a player again: a turn step, a response
a card asks for. Each card's effect lives in one script (`src/cards/`), which the engine calls at
fixed hooks: Core totals, costs, combat start, defeat, capture, draws, installs, and so on.
The browser app in `../app` plays on this engine directly. For it:
- `parseCards(csvText)` in `cards.ts` reads the card CSV without Node; `loadCards()` in `load.ts`
reads the file from disk for the CLI and tests.
- `describeAction(s, a)` in `describe.ts` labels every action for people, e.g.
`Play Execute: Force Reboot on D2: Anomaly 2 (Glitch) (5 Gb)`.
- Log lines carry a tag (combat, capture, card, move…) and what they're about. A line naming a card
only one player may see goes to that player, and `logFor(s, p)` gives the other player its public
version. Choices marked `secret` (Callable Server, Diagnostic Module, Race Condition) log that way,
and `viewFor` hides their prompt from the opponent.
- `coresOf` can list where an Anomaly's Cores come from, `rollOdds` in `odds.ts` gives a roll's win,
tie and loss chances with the average damage, and `combatWatch` in `flow.ts` lets an app see
every stage of a combat, even one that starts and ends inside a single `applyAction`.
## Layout
| Path | What it holds |
@ -54,19 +70,20 @@ fixed hooks: Core totals, costs, combat start, defeat, capture, draws, installs,
| `src/engine.ts` | Decisions, legal actions, response windows, the turn loop, player views |
| `src/flow.ts` | Combat, defeat, capture, drawing, copies |
| `src/query.ts` | What's in play, Cores, costs, capacity, protection |
| `src/cards/` | One script per card: `servers`, `programs`, `hardware`, `executions`, `avatars` |
| `src/cards/` | One script per card: `servers`, `programs`, `hardware`, `executions`, `anomalies` |
| `src/scripts.ts` | The script interface and registry, and the stale-text check |
| `src/map.ts`, `src/rules.ts` | Playmat lines and levels; every rules number, for testing variants |
| `src/map.ts`, `src/rules.ts` | Playmats (the rules.md one plus 4×4 and three-lane test boards), lines and levels; every rules number, for testing variants |
| `src/bots/` | `greedy` (with style presets), `random`, and the combat math they share |
| `src/cli.ts`, `src/stats.ts` | Batch runner, summary and card report |
| `src/describe.ts` | Readable labels for actions and their arguments |
| `src/cli.ts`, `src/stats.ts`, `src/load.ts` | Batch runner, summary and card report; reading the card CSV from disk |
| `test/` | Rules tests, one test per card, and fuzz games that check invariants after every action |
## Bots
- **greedy** plans each command: takes the best single advance or attack (open locations first,
rushing the ones that unlock Avatars; attacks at 60%+ odds), guards threatened locations, installs
Hardware and Programs where they help, walls off undefended locations, and keeps RAM for tricks.
With whole turns it plans every Avatar's move at once. On the opponent's commands it answers after the dice are rolled with whichever
rushing the ones that unlock Anomalies; attacks at 60%+ odds), guards threatened locations, installs
Hardware and Programs where they help, walls off undefended locations, and keeps Bandwidth for tricks.
With whole turns it plans every Anomaly's move at once. On the opponent's commands it answers after the dice are rolled with whichever
Execution or Ability most improves the combat, and tries to stop advances into its locations.
- **nocards** is greedy but only uses Core Hardware, like the first version of the sim.
- **bold / cautious / nowall / wall3** change one greedy setting each; **random** picks any legal