updates
This commit is contained in:
parent
e590baf28d
commit
6382de19c9
15 changed files with 239 additions and 28 deletions
|
|
@ -6,7 +6,7 @@ import { DEFAULT_GREEDY, greedyBot } from './bots/greedy.ts';
|
|||
import { randomBot } from './bots/random.ts';
|
||||
import { DEFAULT_CARDS_CSV, loadCards, type CardKind } from './cards.ts';
|
||||
import { playGame } from './play.ts';
|
||||
import { DEFAULT_RULES } from './rules.ts';
|
||||
import { DEFAULT_RULES, withRule } from './rules.ts';
|
||||
import { isImplemented, staleScripts } from './scripts.ts';
|
||||
import { cardReport, formatCardReport, formatSummary, recordOf, summarize, type GameRecord } from './stats.ts';
|
||||
import { PLAYER_NAMES } from './types.ts';
|
||||
|
|
@ -30,6 +30,11 @@ const USAGE = `Files TCG simulator
|
|||
--south BOT South's bot (default greedy)
|
||||
--north BOT North's bot (default greedy)
|
||||
--max-turns N player turns before a draw (default ${DEFAULT_RULES.maxTurns})
|
||||
--rule K=V change a rule in src/rules.ts; repeatable. Examples: winLocations=9,
|
||||
levelRam=4,4,6,8,10, startingAvatars=4, firstTurn.advance=false,
|
||||
firstTurn.captureRam=false, firstTurn.unlock=false, firstTurn.cards=false,
|
||||
secondPlayer.ram=4, secondPlayer.avatars=1, secondPlayer.cards=2,
|
||||
secondPlayer.locations=1
|
||||
--log play one game and print the play-by-play
|
||||
--check check rule invariants after every action (slow)
|
||||
--json FILE also write the summary and every game's result as JSON
|
||||
|
|
@ -47,6 +52,7 @@ const { values: opt } = parseArgs({
|
|||
south: { type: 'string', default: 'greedy' },
|
||||
north: { type: 'string', default: 'greedy' },
|
||||
'max-turns': { type: 'string' },
|
||||
rule: { type: 'string', multiple: true, default: [] },
|
||||
log: { type: 'boolean', default: false },
|
||||
check: { type: 'boolean', default: false },
|
||||
json: { type: 'string' },
|
||||
|
|
@ -81,7 +87,14 @@ const seed = count('seed', opt.seed)!;
|
|||
const maxTurns = count('max-turns', opt['max-turns']);
|
||||
|
||||
const pool = loadCards(opt.cards);
|
||||
const rules = maxTurns === undefined ? DEFAULT_RULES : { ...DEFAULT_RULES, maxTurns };
|
||||
let rules = maxTurns === undefined ? DEFAULT_RULES : { ...DEFAULT_RULES, maxTurns };
|
||||
try {
|
||||
for (const spec of opt.rule) rules = withRule(rules, spec);
|
||||
} catch (e) {
|
||||
console.error((e as Error).message);
|
||||
process.exit(1);
|
||||
}
|
||||
if (opt.rule.length) console.log(`Rules changed: ${opt.rule.join(', ')}`);
|
||||
const bots: [BotFactory, BotFactory] = [BOTS[opt.south].make, BOTS[opt.north].make];
|
||||
|
||||
for (const warning of staleScripts(pool)) console.warn(`warning: ${warning}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue