Rules v0.8: rounds of alternating commands; sim updates
Rules (rules.md, new file): - Rounds of 2 commands per player in snake order (A B B A, then B A A B). A command is one advance or one attack; each Avatar acts once per round. - Flat 4 RAM captures, first row Lv 1, A2-C2 and C2-E2 lines cut, 45-card decks, Code Zero at 3 Cores with Patient Zero at 1+ counters. Simulator: - Command rule (default on): commands.perPlayer, commands.leads, commands.snake; commands.on=false restores whole turns. - Greedy bot values Avatar unlocks (unlockPoints) and picks one action per command. - Prototype switches, off by default: Avatars in the deck (recruit.*), buying Avatars (buyAvatars.*), copy limits (copies.*), turn-1 draw and second-player draw options. - cards.csv card-text revisions, with scripts and tests to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6382de19c9
commit
a3eb6850ee
21 changed files with 1089 additions and 96 deletions
|
|
@ -56,8 +56,39 @@ export const fired = (s: GameState, name: string, p: PlayerId): void => void use
|
|||
export const endOfTurn = (s: GameState): Clock => 2 * s.turn + 1;
|
||||
export const startOf = (turn: number): Clock => 2 * turn;
|
||||
export const endOf = (turn: number): Clock => 2 * turn + 1;
|
||||
/** The turn number of `p`'s next turn (not the current one). */
|
||||
export const nextTurnOf = (s: GameState, p: PlayerId): number => (s.active === p ? s.turn + 2 : s.turn + 1);
|
||||
/** The turn number of `p`'s next turn (not the current one). Under the command rule, their next command. */
|
||||
export function nextTurnOf(s: GameState, p: PlayerId): number {
|
||||
if (!s.rules.commands.on) return s.active === p ? s.turn + 2 : s.turn + 1;
|
||||
let t = s.turn + 1;
|
||||
while (commanderOf(s, t) !== p) t++;
|
||||
return t;
|
||||
}
|
||||
|
||||
// Command rule: game turns are commands. A round is 2 × perPlayer of them, alternating players,
|
||||
// and the lead alternates by round.
|
||||
const commandsPerRound = (s: GameState): number => 2 * s.rules.commands.perPlayer;
|
||||
|
||||
/** Command rule: who takes game turn `turn`. */
|
||||
export function commanderOf(s: GameState, turn: number): PlayerId {
|
||||
const { leads, snake } = s.rules.commands;
|
||||
const round = Math.floor((turn - 1) / commandsPerRound(s));
|
||||
const i = (turn - 1) % commandsPerRound(s);
|
||||
const ones = round.toString(2).split('1').length - 1;
|
||||
const mark = leads === 'thue' ? 'FS'[ones % 2] : leads[round % leads.length];
|
||||
if (mark !== 'F' && mark !== 'S') throw new Error(`commands.leads should use F and S, or be "thue": "${leads}"`);
|
||||
const lead = mark === 'F' ? s.firstPlayer : other(s.firstPlayer);
|
||||
const leadsThis = snake ? i % 4 === 0 || i % 4 === 3 : i % 2 === 0;
|
||||
return leadsThis ? lead : other(lead);
|
||||
}
|
||||
|
||||
/** Command rule: the round game turn `turn` belongs to, from 1. */
|
||||
export const roundOf = (s: GameState, turn: number): number => Math.floor((turn - 1) / commandsPerRound(s)) + 1;
|
||||
|
||||
/** Command rule: whether `turn` is its commander's first command of the round. */
|
||||
export const firstCommand = (s: GameState, turn: number): boolean => (turn - 1) % commandsPerRound(s) < 2;
|
||||
|
||||
/** Rounds played so far: both players taking a turn (or all their commands). */
|
||||
export const roundsPlayed = (s: GameState): number => (s.rules.commands.on ? roundOf(s, s.turn) : Math.ceil(s.turn / 2));
|
||||
export const running = (s: GameState, until: Clock): boolean => until > s.clock;
|
||||
|
||||
/** Once-per-turn bookkeeping. Returns how many times `key` was used this turn. */
|
||||
|
|
@ -116,6 +147,10 @@ export function wearerOf(s: GameState, hw: number): AvatarRef | null {
|
|||
export const isRooted = (s: GameState, r: AvatarRef): boolean => running(s, avatar(s, r).rootedUntil);
|
||||
export const isDisabledAvatar = (s: GameState, r: AvatarRef): boolean => running(s, avatar(s, r).disabledUntil);
|
||||
/** Can act: advance, attack, move, use its Ability. */
|
||||
/** Copy-rule variant: a copy made this player-turn can't advance or attack yet. It can still defend. */
|
||||
export const freshCopy = (s: GameState, r: AvatarRef): boolean =>
|
||||
isCopy(r) && s.rules.copies.waitATurn && avatar(s, r).createdTurn === s.turn;
|
||||
|
||||
export const canAct = (s: GameState, r: AvatarRef): boolean =>
|
||||
inPlay(s, r) && !isRooted(s, r) && !isDisabledAvatar(s, r);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue