컴퓨터 난이도 1~60단계·방장 선택·판마다 변화·운, 공정성 확인에 표기, 업데이트 알림 팝업
- 난이도 1~60(쉬움 1~20·보통 21~40·어려움 41~60): 넣을 때 랜덤, 방장이 대기실에서 [랜덤][쉬움][보통][어려움] 선택(botLevel) → 범위 안 무작위 - 다음 판마다 -2~+2, 처음 단계 ±5·같은 범위 안(drift); 말투는 처음 단계(>30 존댓말) - humanBest 확률을 단계별로 보간(BOT_PLAY_ANCHORS: 1·10·30·50·60) - 운(-1~+1): 카드·주사위 게임에서 시작 전에 시드 후보 1~5개를 작업 스레드에서 끝까지 둬 보고 운에 맞는 것을 고름(luck.ts, luck-worker.ts). 해시 공개는 그대로 - 결과 화면 공정성 확인에 컴퓨터별 단계·운, 섞어 본 후보 수 - 업데이트 알림: 빌드 ID meta + /api/version + welcome.build → 상단 팝업 [지금 새로고침하기] [✕] - 문서 03·04 §5.1·06 §12·07 §11.1·09 §9.1, 테스트(bot-level.room, luck, version, e2e bots·pwa) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,8 @@ export interface BrainRoom {
|
||||
roomChat(bot: string, text: string): void;
|
||||
setActivity(bot: string, a: BotActivity | null): void;
|
||||
recentChat(): { from: string; text: string }[];
|
||||
/** 똑똑한 편 (존댓말) or 허술한 편 (반말), docs/09 §9.1. */
|
||||
smart(bot: string): boolean;
|
||||
now(): number;
|
||||
}
|
||||
|
||||
@@ -90,6 +92,7 @@ export class BotBrain {
|
||||
return {
|
||||
bot,
|
||||
name: this.room.nameOf(bot),
|
||||
smart: this.room.smart(bot),
|
||||
game: this.room.gameName(),
|
||||
situation,
|
||||
task,
|
||||
@@ -175,6 +178,7 @@ export class BotBrain {
|
||||
this.llm,
|
||||
bot,
|
||||
this.room.nameOf(bot),
|
||||
this.room.smart(bot),
|
||||
`바퀴벌레 포커. 나는 ${target}에게 카드를 건넨다. 실제 카드는 ${KO[kind] ?? kind}다. ${target}의 앞마당: ${pile}.\n` +
|
||||
`진짜 이름을 말할지(bluff=false) 다른 벌레라고 거짓말할지(bluff=true) 정하고, 건네며 할 한마디(say, 30자 이내, 실제 카드를 밝히지 말 것)를 정해.`,
|
||||
{ type: 'object', properties: { bluff: { type: 'boolean' }, say: { type: 'string' } }, required: ['bluff', 'say'] },
|
||||
@@ -243,6 +247,7 @@ export class BotBrain {
|
||||
const line = await writeLine(this.llm, {
|
||||
bot,
|
||||
name: this.room.nameOf(bot),
|
||||
smart: this.room.smart(bot),
|
||||
game: '마피아(낮 토론, 모두가 보는 채팅)',
|
||||
situation: '누가 마피아인지 추리하며 이야기하는 중이다. 너는 자신이 시민 팀이라고 말한다.',
|
||||
task: hint,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* What a computer says, written by the local model (docs/06 §12.1): a character (성격 + 말투) per computer, a prompt
|
||||
* per moment, and a strict clean-up so only one short, kind, Korean chat line ever reaches people.
|
||||
*/
|
||||
import { botPersona, hash01 } from '@bg/games/bots';
|
||||
import { hash01 } from '@bg/games/bots';
|
||||
import { chatProblem } from '@bg/games/mafia';
|
||||
import type { Llm, LlmMessage } from './llm';
|
||||
|
||||
@@ -27,16 +27,17 @@ export function temperOf(bot: string): Temper {
|
||||
return TEMPERS[Math.floor(hash01(bot, 'temper') * TEMPERS.length)]!;
|
||||
}
|
||||
|
||||
export function speechOf(bot: string): string {
|
||||
return botPersona(bot).smart ? '존댓말(해요체), 또박또박' : '반말, 짧고 가볍게, ㅋㅋ를 가끔 붙임';
|
||||
/** `smart` = 똑똑한 편 (the room's `botPersona`). */
|
||||
export function speechOf(smart: boolean): string {
|
||||
return smart ? '존댓말(해요체), 또박또박' : '반말, 짧고 가볍게, ㅋㅋ를 가끔 붙임';
|
||||
}
|
||||
|
||||
export function systemPrompt(bot: string, name: string, maxLen: number): string {
|
||||
export function systemPrompt(bot: string, name: string, maxLen: number, smart: boolean): string {
|
||||
const t = temperOf(bot);
|
||||
return [
|
||||
`너는 온라인 보드게임 사이트 "같이 놀자"에서 사람들과 함께 게임하는 컴퓨터 플레이어 "${name}"이다.`,
|
||||
`성격: ${t.ko} — ${t.desc}`,
|
||||
`말투: ${speechOf(bot)}.`,
|
||||
`말투: ${speechOf(smart)}.`,
|
||||
`규칙: 한국어 채팅 한 줄만 쓴다. ${maxLen}자 이내. 대사만 쓰고 따옴표·설명·괄호·영어·한자는 쓰지 않는다.`,
|
||||
'욕설, 비하, 외모·성별·나이 언급, 개인정보, 링크는 절대 쓰지 않는다. 게임과 상관없는 이야기는 하지 않는다.',
|
||||
'자신이 AI나 프로그램이라고 말하지 않는다. 숨겨진 정보(내 패, 내 카드, 내 직업)는 절대 밝히지 않는다.',
|
||||
@@ -46,6 +47,8 @@ export function systemPrompt(bot: string, name: string, maxLen: number): string
|
||||
export interface LineRequest {
|
||||
bot: string;
|
||||
name: string;
|
||||
/** 똑똑한 편 (존댓말) / 허술한 편 (반말). */
|
||||
smart: boolean;
|
||||
game: string;
|
||||
/** What is going on, in plain Korean. */
|
||||
situation: string;
|
||||
@@ -99,7 +102,7 @@ export async function writeLine(llm: Llm | null, req: LineRequest): Promise<stri
|
||||
if (req.example) parts.push(`예시(뜻은 같게, 표현은 너답게 새로): ${req.example}`);
|
||||
parts.push(`할 말: ${req.task}`);
|
||||
const messages: LlmMessage[] = [
|
||||
{ role: 'system', content: systemPrompt(req.bot, req.name, maxLen) },
|
||||
{ role: 'system', content: systemPrompt(req.bot, req.name, maxLen, req.smart) },
|
||||
{ role: 'user', content: parts.join('\n') },
|
||||
];
|
||||
const raw = await llm.chat(messages, { maxTokens: 70, temperature: 0.95 });
|
||||
@@ -107,11 +110,11 @@ export async function writeLine(llm: Llm | null, req: LineRequest): Promise<stri
|
||||
}
|
||||
|
||||
/** Structured choice (JSON schema) — e.g. 바퀴벌레 포커: tell the truth or bluff, and what to say. */
|
||||
export async function decide<T>(llm: Llm | null, bot: string, name: string, prompt: string, schema: object): Promise<T | null> {
|
||||
export async function decide<T>(llm: Llm | null, bot: string, name: string, smart: boolean, prompt: string, schema: object): Promise<T | null> {
|
||||
if (!llm || !llm.available()) return null;
|
||||
const raw = await llm.chat(
|
||||
[
|
||||
{ role: 'system', content: systemPrompt(bot, name, 40) + '\n대답은 요청한 JSON 형식으로만 한다.' },
|
||||
{ role: 'system', content: systemPrompt(bot, name, 40, smart) + '\n대답은 요청한 JSON 형식으로만 한다.' },
|
||||
{ role: 'user', content: prompt },
|
||||
],
|
||||
{ maxTokens: 120, temperature: 0.9, format: schema },
|
||||
|
||||
Reference in New Issue
Block a user