마피아 컴퓨터 플레이어: 각자 타이머로 말하고 투표하는 라이브 봇, 똑똑한 편/허술한 편, 반응 속도 차이
- BotDriver live 모드: 컴퓨터마다 자기 타이머로 화면·채팅을 다시 보고 행동 하나 - mafia/bot.ts: 근거 추리(경찰 결과·경찰 주장·투표 기록) vs 느낌·분위기, 존댓말 vs 반말 - 채팅: 인사, 아침 소식, 지목·동의·반박, 이름 불리면 대답, 반론, 마피아 상의 - 연습 방 6명(PRACTICE_PLAYERS), BOT_GAMES에 mafia - 테스트: 옵션 조합별 전체 판, 똑똑한 편 승률, 자기 팀 지목 금지, 반응 속도, 대답 E2E Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
32
packages/games/src/bots/persona.ts
Normal file
32
packages/games/src/bots/persona.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/** Each computer's character, fixed by its id (docs/09-game-engine.md §9). */
|
||||
|
||||
/** FNV-1a of the parts → [0, 1). Stable: the same bot decides the same way about the same thing. */
|
||||
export function hash01(...parts: (string | number)[]): number {
|
||||
let h = 2166136261;
|
||||
const s = parts.join('\u0001');
|
||||
for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619);
|
||||
return (h >>> 0) / 2 ** 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each computer's own pace (0.7 quick … 1.5 careful), fixed for the bot id so "컴퓨터 2" keeps its character for the
|
||||
* whole game, while a new room's 컴퓨터 2 (new id) may be different.
|
||||
*/
|
||||
export function botPace(bot: string): number {
|
||||
let h = 2166136261;
|
||||
for (let i = 0; i < bot.length; i++) h = Math.imul(h ^ bot.charCodeAt(i), 16777619);
|
||||
return 0.7 + ((h >>> 0) / 2 ** 32) * 0.8;
|
||||
}
|
||||
|
||||
export interface BotPersona {
|
||||
/** 똑똑한 편(근거를 보고 추리) / 허술한 편(느낌과 분위기를 따름). About half of the computers each. */
|
||||
smart: boolean;
|
||||
/** Reaction speed multiplier (`botPace`): 0.7 quick … 1.5 slow. */
|
||||
pace: number;
|
||||
/** 0.5 … 1: how likely it speaks up. */
|
||||
chatty: number;
|
||||
}
|
||||
|
||||
export function botPersona(bot: string): BotPersona {
|
||||
return { smart: hash01(bot, 'smart') < 0.5, pace: botPace(bot), chatty: 0.5 + hash01(bot, 'chatty') * 0.5 };
|
||||
}
|
||||
Reference in New Issue
Block a user