rule change

This commit is contained in:
Forrest 2026-09-29 13:28:06 -04:00
parent 62b2b9feca
commit 5d771eed1b
9 changed files with 199 additions and 75 deletions

View file

@ -27,13 +27,14 @@ of how much a card helps.
## What's simulated
- **Rules:** everything in `rules.md`: setup, rounds of alternating commands (or whole turns, with
`--rule commands.on=false`), placement and advancing, attacks,
combat with tie rerolls, captures, levels and RAM, Avatar unlocks, Firewalls, Salvage, response
windows and chains, and the win condition.
`--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,
Salvage, response windows and chains, and the win condition.
- **Every card:** all 83 cards in `../decks/files-deck-1/cards.csv` have a script, including Avatar
Abilities. 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, slots) come straight from the CSV. Each script records the text
- **Card edits:** stats (RAM, 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.

View file

@ -19,7 +19,7 @@ export interface RulesConfig {
deck: { avatars: number; servers: number; main: number; maxCopies: number };
/** Avatars face up at the start (rules: Avatar 1 only). */
startingAvatars: number;
/** What the first player may do on turn 1 (the rules skip the draw and allow the rest). */
/** What the first player may do on turn 1 (the rules since v0.9 allow all of it; v0.8 skipped the draw). */
firstTurn: {
draw: boolean;
advance: boolean;
@ -90,12 +90,12 @@ export const DEFAULT_RULES: RulesConfig = {
maxProgramsPerLocation: 2,
deck: { avatars: 4, servers: 20, main: 45, maxCopies: 2 },
startingAvatars: 1,
firstTurn: { draw: false, advance: true, captureRam: true, unlock: true, cards: true },
firstTurn: { draw: true, advance: true, captureRam: true, unlock: true, cards: true },
secondPlayer: { ram: 0, avatars: 0, cards: 0, firstDraw: 0, locations: 0 },
recruit: { on: false, avatarsInDeck: 3, price: 6, pricePerCore: 0 },
buyAvatars: { on: false, prices: [8, 12, 16] },
copies: { allowed: true, waitATurn: false, needAvatar2: false },
commands: { on: true, perPlayer: 2, leads: 'FS', snake: true },
commands: { on: true, perPlayer: 2, leads: 'F', snake: true },
health: { on: true, override: 0, recall: true },
};

View file

@ -29,21 +29,21 @@ test('setup follows rules.md', () => {
assert.deepEqual(checkInvariants(s), []);
});
test('the first player skips the draw; the second player draws', () => {
test('both players draw on their first turn (since v0.9); firstTurn.draw=false makes the first player skip it', () => {
// The test table pins the old skip, so card tests start from a known hand.
const t = new Table({ south: { main: ['Additional Core'] }, north: { main: ['Additional Core'] } });
assert.equal(t.s.players[0].hand.length, 0);
t.to('playAgain').end();
assert.equal(t.s.active, 1);
assert.equal(t.s.players[1].hand.length, 1);
});
test('rule variants: the first player draws on turn 1', () => {
const pool = loadCards();
const hand = (rules: RulesConfig) => {
const s = createGame({ pool, decks: [randomDeck(pool, makeRng(1), rules), randomDeck(pool, makeRng(2), rules)], seed: 5, rules });
return s.players[s.firstPlayer].hand.length;
};
assert.equal(hand(withRule(DEFAULT_RULES, 'firstTurn.draw=true')), hand(DEFAULT_RULES) + 1);
assert.equal(DEFAULT_RULES.firstTurn.draw, true);
assert.equal(hand(withRule(DEFAULT_RULES, 'firstTurn.draw=false')), hand(DEFAULT_RULES) - 1);
});
test('rule variants: the second player draws extra in their first draw step only', () => {
@ -119,7 +119,8 @@ test('rule variants: the second player can start with extra cards and a location
const rules = withRule(withRule(DEFAULT_RULES, 'secondPlayer.cards=2'), 'secondPlayer.locations=1');
const s = createGame({ pool, decks: [decks[0], decks[1]], seed: 3, rules });
const p2 = s.firstPlayer === 0 ? 1 : 0;
assert.equal(s.players[p2].hand.length, s.players[s.firstPlayer].hand.length + 2);
assert.equal(s.players[p2].hand.length, rules.openingHand + 2);
assert.equal(s.players[s.firstPlayer].hand.length, rules.openingHand + 1, 'the first player drew on turn 1');
assert.equal(s.locations[p2 === 0 ? 'A2' : 'E2'].owner, p2);
assert.equal(s.players[p2].serverPile.length, 18);
assert.deepEqual(checkInvariants(s), []);
@ -389,10 +390,10 @@ test('buy rule: captures unlock nothing', () => {
// ---------------------------------------------------------------------------------------------
// Command rule (prototype): alternating commands, 2 per player per round
/** Command rule with plain A B A B rounds, so tests can predict whose command it is. */
/** Command rule with plain A B A B rounds and an alternating lead, so tests can predict whose command it is. */
function commandTable(): Table {
const t = new Table();
t.s.rules = withRule(withRule(t.s.rules, 'commands.on=true'), 'commands.snake=false');
for (const sp of ['commands.on=true', 'commands.snake=false', 'commands.leads=FS']) t.s.rules = withRule(t.s.rules, sp);
return t;
}
@ -418,8 +419,8 @@ test('command rule: the order of commands can follow a pattern of round leads, o
assert.equal(order('commands.leads=FFSS'), 'FSFS' + 'FSFS' + 'SFSF' + 'SFSF');
assert.equal(order('commands.leads=thue'), 'FSFS' + 'SFSF' + 'SFSF' + 'FSFS');
assert.equal(order('commands.snake=true', 'commands.leads=F'), 'FSSF'.repeat(4));
assert.equal(order('commands.snake=true'), 'FSSF' + 'SFFS' + 'FSSF' + 'SFFS', 'the default order');
assert.equal(DEFAULT_RULES.commands.snake, true);
assert.equal(order('commands.snake=true'), 'FSSF' + 'SFFS' + 'FSSF' + 'SFFS', 'the v0.8 order');
assert.deepEqual(DEFAULT_RULES.commands, { on: true, perPlayer: 2, leads: 'F', snake: true }, 'the default since v0.9: the first player leads every round, snake order');
});
test('command rule: one advance or attack per command, each Avatar once a round', () => {

View file

@ -36,12 +36,13 @@ export class Table {
main: [...(x.main ?? []), ...Array(12).fill(FILLER)],
});
const decks = [side(o.south), side(o.north)] as const;
// Classic turns (one turn each, every Avatar acts) and one-roll combats, which the card tests
// are written for. The command rule has its own tests in engine.test.ts, the health rule in
// health.test.ts (`health: true`).
// Classic turns (one turn each, every Avatar acts), no turn-1 draw for the first player, and
// one-roll combats, which the card tests are written for. The command rule has its own tests in
// engine.test.ts, the health rule in health.test.ts (`health: true`).
const rules: RulesConfig = {
...DEFAULT_RULES,
commands: { ...DEFAULT_RULES.commands, on: false },
firstTurn: { ...DEFAULT_RULES.firstTurn, draw: false },
health: { ...DEFAULT_RULES.health, on: o.health ?? false },
openingHand: 0,
deck: { avatars: 4, servers: decks[0].servers.length, main: decks[0].main.length, maxCopies: 99 },