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
|
|
@ -4,6 +4,7 @@ import { DEFAULT_GREEDY, greedyBot } from '../src/bots/greedy.ts';
|
|||
import { randomBot } from '../src/bots/random.ts';
|
||||
import { loadCards } from '../src/cards.ts';
|
||||
import { playGame } from '../src/play.ts';
|
||||
import { DEFAULT_RULES, withRule } from '../src/rules.ts';
|
||||
|
||||
const pool = loadCards();
|
||||
|
||||
|
|
@ -26,6 +27,42 @@ test('greedy bots play 200 games without breaking a rule', () => {
|
|||
assert.ok(wins >= 196, `only ${wins}/200 games ended in a win`);
|
||||
});
|
||||
|
||||
test('bots play the recruit rule without breaking a rule', () => {
|
||||
for (const k of [3, 7]) {
|
||||
const rules = withRule(withRule(DEFAULT_RULES, 'recruit.on=true'), `recruit.avatarsInDeck=${k}`);
|
||||
for (let seed = 1; seed <= 25; seed++) {
|
||||
assert.ok(playGame({ pool, bots: [randomBot, randomBot], seed, rules, check: true }).over);
|
||||
assert.ok(playGame({ pool, bots: [() => greedyBot(), () => greedyBot()], seed, rules, check: true }).over);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('bots play the buy-Avatars rule without breaking a rule', () => {
|
||||
const rules = withRule(DEFAULT_RULES, 'buyAvatars.on=true');
|
||||
for (let seed = 1; seed <= 25; seed++) {
|
||||
assert.ok(playGame({ pool, bots: [randomBot, randomBot], seed, rules, check: true }).over);
|
||||
assert.ok(playGame({ pool, bots: [() => greedyBot(), () => greedyBot()], seed, rules, check: true }).over);
|
||||
}
|
||||
});
|
||||
|
||||
test('bots play the copy-rule variants without breaking a rule', () => {
|
||||
for (const spec of ['copies.waitATurn=true', 'copies.needAvatar2=true', 'copies.allowed=false']) {
|
||||
const rules = withRule(DEFAULT_RULES, spec);
|
||||
for (let seed = 1; seed <= 15; seed++) {
|
||||
assert.ok(playGame({ pool, bots: [randomBot, randomBot], seed, rules, check: true }).over);
|
||||
assert.ok(playGame({ pool, bots: [() => greedyBot(), () => greedyBot()], seed, rules, check: true }).over);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('bots play the command rule without breaking a rule', () => {
|
||||
const rules = withRule(DEFAULT_RULES, 'commands.on=true');
|
||||
for (let seed = 1; seed <= 25; seed++) {
|
||||
assert.ok(playGame({ pool, bots: [randomBot, randomBot], seed, rules, check: true }).over);
|
||||
assert.ok(playGame({ pool, bots: [() => greedyBot(), () => greedyBot()], seed, rules, check: true }).over);
|
||||
}
|
||||
});
|
||||
|
||||
test('greedy beats random', () => {
|
||||
let wins = 0;
|
||||
for (let seed = 1; seed <= 100; seed++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue