added harness to support bots being able to run / test strategies.
This commit is contained in:
+6
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user