forked from WikiDeck/wikideck
[sim-balance] easy duel bot (heuristic with 30% blunders) for the UI
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -211,13 +211,20 @@ export function duelMCBot<S, A>(engine: EngineAdapter<S, A>, lens: DuelLens<S, A
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DUEL_BOT_NAMES = ['random', 'greedy', 'heuristic', 'mc', 'mc-lite'] as const;
|
/** Heuristic with blunders: with probability `rate` a uniformly random legal action instead (UI "Easy"). */
|
||||||
|
export function blunderBot<S, A>(engine: EngineAdapter<S, A>, lens: DuelLens<S, A>, rate = 0.3): BotFn<unknown, A> {
|
||||||
|
const h = heuristicBot(engine, lens), r = duelRandomBot(engine);
|
||||||
|
return (obs, seat, rng) => (rng() < rate ? r(obs, seat, rng) : h(obs, seat, rng));
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DUEL_BOT_NAMES = ['random', 'greedy', 'easy', 'heuristic', 'mc', 'mc-lite'] as const;
|
||||||
|
|
||||||
export function makeDuelBot<S, A>(name: string, engine: EngineAdapter<S, A>, lens: DuelLens<S, A>): BotFn<unknown, A> {
|
export function makeDuelBot<S, A>(name: string, engine: EngineAdapter<S, A>, lens: DuelLens<S, A>): BotFn<unknown, A> {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'random': return duelRandomBot(engine);
|
case 'random': return duelRandomBot(engine);
|
||||||
case 'greedy': return duelGreedyBot(engine);
|
case 'greedy': return duelGreedyBot(engine);
|
||||||
case 'heuristic': return heuristicBot(engine, lens);
|
case 'heuristic': return heuristicBot(engine, lens);
|
||||||
|
case 'easy': return blunderBot(engine, lens);
|
||||||
case 'mc': return duelMCBot(engine, lens);
|
case 'mc': return duelMCBot(engine, lens);
|
||||||
case 'mc-lite': return duelMCBot(engine, lens, { rollouts: 3, k: 3, horizon: 60 });
|
case 'mc-lite': return duelMCBot(engine, lens, { rollouts: 3, k: 3, horizon: 60 });
|
||||||
case 'lookahead': return lookaheadBot(engine);
|
case 'lookahead': return lookaheadBot(engine);
|
||||||
|
|||||||
Reference in New Issue
Block a user