added harness to support bots being able to run / test strategies.

This commit is contained in:
Jesse
2026-08-08 15:07:42 -04:00
parent 5d825b97d2
commit 35575147cd
9 changed files with 866 additions and 23 deletions
+6 -3
View File
@@ -19,7 +19,7 @@ import type { GameConfig, GameMode } from '../engine/state.ts';
import type { BotPolicy, PlayOutcome } from './bot.ts';
import { developerBot, playGame, randomBot } from './bot.ts';
import type { GameStats } from './stats.ts';
import { formatAggregate, summarize } from './stats.ts';
import { formatAggregate, makeFunnelProbe, summarize } from './stats.ts';
export type SimOptions = {
games: number;
@@ -86,9 +86,12 @@ export function simulate(opts: SimOptions): SimReport {
config: configFor(opts.mode, opts.length),
playerNames: opts.players,
});
const r = playGame(s, opts.policy, pump);
// The probe watches the game as it is played: the funnel gates are conditions at a moment, not
// events, so they cannot be recovered from the log afterwards.
const probe = makeFunnelProbe(0);
const r = playGame(s, opts.policy, pump, 50_000, probe.onEvent, probe.onTurn);
results.push(r);
stats.push(summarize(seed, r.events, r.intents, s));
stats.push(summarize(seed, r.events, r.intents, s, probe.funnel));
}
const finished = results.filter((r) => r.finished);