Duplicated logic and styling that had drifted apart is unified: the gesture-sharing check, the hostile spell list, the enchanted test, the plan limits, and the shared button, link, field and disabled styles. Dead plumbing is gone: the always-true implemented flag, the unread cast length, an unreachable guard, an impossible time-stop condition, the unused sequence formatter and utility class, the template placeholder. The counter-spell tests now put a counter-spell in front of a spell, the test helpers live in one file, and the resolver's sections are numbered in order. The deploy script's cache headers now do what its comment says, and the README describes the screen rather than listing features in the order they arrived. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { chooseBotTurn } from './bot';
|
|
import { resolveTurn } from './resolve';
|
|
import { createGame } from './state';
|
|
import { lcg } from './test-helpers';
|
|
|
|
describe('bot versus bot', () => {
|
|
it('sixty duels end without errors and by death, not surrender', () => {
|
|
let finished = 0;
|
|
let byDeath = 0;
|
|
let totalTurns = 0;
|
|
for (let seed = 1; seed <= 60; seed++) {
|
|
let state = createGame({ A: 'Black', B: 'White' }, seed);
|
|
const rngA = lcg(seed * 7 + 1);
|
|
const rngB = lcg(seed * 13 + 5);
|
|
for (let turn = 0; turn < 80 && !state.over; turn++) {
|
|
const a = chooseBotTurn(state, 'A', rngA);
|
|
const b = chooseBotTurn(state, 'B', rngB);
|
|
state = resolveTurn(state, { A: a, B: b });
|
|
}
|
|
if (state.over) {
|
|
finished++;
|
|
totalTurns += state.turn;
|
|
if (!state.wizards.A.alive || !state.wizards.B.alive) byDeath++;
|
|
}
|
|
for (const w of Object.values(state.wizards)) {
|
|
expect(w.hp).toBeGreaterThanOrEqual(0);
|
|
expect(w.hp).toBeLessThanOrEqual(15);
|
|
}
|
|
}
|
|
expect(finished).toBeGreaterThan(45);
|
|
expect(byDeath).toBe(finished);
|
|
expect(totalTurns / finished).toBeLessThan(40);
|
|
}, 60000);
|
|
});
|