컴퓨터 난이도(쉬움 35%·보통 40%·어려움 25%)와 사람 같은 수, 서버 난수를 OS 보안 난수로

- secureRandom(): crypto.getRandomValues 53비트 실수. 서버의 Math.random(컴퓨터 수·생각 시간·AI 말·방 코드·마감 유예)을 모두 교체
- 컴퓨터 id의 ULID를 secureRandom으로 만들고, 그 무작위 부분 30비트로 난이도·말투(smart)를 정함(botDraw)
- humanBest: 오목·체스·장기·오델로·바둑에서 난이도별로 비슷한 수(slip)·사고(lapse)·꼭 둬야 할 수 놓침(miss)
- 문서 09 §9.1(확률표·게임별 기준·대국 결과), 06 §12; 테스트 bots/level.test.ts, 레벨별 완주 테스트

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-11 16:19:06 +09:00
parent 07fe46562f
commit 3cbc3698d3
20 changed files with 312 additions and 41 deletions

View File

@@ -88,7 +88,7 @@ describe('whole games', () => {
players: seats(7, 0),
seed: seedN(s),
isBot,
personaOf: (p, st): BotPersona => ({ smart: roleOf(st, p) === 'mafia' ? mafiaSmart : townSmart, pace: botPace(p), chatty: 0.8 }),
personaOf: (p, st): BotPersona => ({ level: 'normal', smart: roleOf(st, p) === 'mafia' ? mafiaSmart : townSmart, pace: botPace(p), chatty: 0.8 }),
});
if ((r.state as MafiaState).winner === 'town') town++;
}
@@ -128,8 +128,8 @@ describe('timing and answers', () => {
const { st, players } = toPhase('vote');
const names = Object.fromEntries(players.map((p, i) => [p, i ? `컴퓨터 ${i + 1}` : '철수']));
const bot = players[2]!;
const quick = firstAction(st, bot, { smart: true, pace: 0.7, chatty: 0.8 }, names, 'vote')!;
const slow = firstAction(st, bot, { smart: true, pace: 1.5, chatty: 0.8 }, names, 'vote')!;
const quick = firstAction(st, bot, { level: 'hard', smart: true, pace: 0.7, chatty: 0.8 }, names, 'vote')!;
const slow = firstAction(st, bot, { level: 'hard', smart: true, pace: 1.5, chatty: 0.8 }, names, 'vote')!;
expect(quick.at).toBeLessThan(slow.at);
expect(slow.at).toBeLessThan(st.options.voteSeconds * 1000);
});
@@ -142,7 +142,7 @@ describe('timing and answers', () => {
const memory: Record<string, unknown> = {};
let answer: { text: string; at: number } | null = null;
for (let t = now + 1000; t < now + 20_000 && !answer; ) {
const d = mafiaBot({ me: bot, view: mafia.view(asked, bot), now: t, random: Math.random, persona: { smart: true, pace: 1, chatty: 0.8 }, names, memory });
const d = mafiaBot({ me: bot, view: mafia.view(asked, bot), now: t, random: Math.random, persona: { level: 'hard', smart: true, pace: 1, chatty: 0.8 }, names, memory });
const a = d.action as { type: string; text?: string } | null;
if (a?.type === 'chat' && memory.done && Object.keys(memory.done as object).some((k) => k.includes(':r:'))) answer = { text: a.text!, at: t - now - 1000 };
t += Math.max(50, d.next);