라이어 게임: 관리자 화면에서 주제·제시어 추가/수정/삭제, 바보 모드 라이어는 비슷한 단어(같은 묶음)

- 제시어 1,519개를 주제별 '비슷한 단어 묶음' 391개로 정리(bank/*.ts groups). 바보 모드 라이어는 제시어와 같은 묶음의 다른 단어를 받음
- 관리자 → 라이어 제시어(/admin/liar): 주제 추가·이름 변경·삭제(내장 주제는 다시 살리기/처음 값으로), 제시어·묶음·다른 표기·컴퓨터 설명 편집, 저장 시 topicProblems 검사
- 저장: liar_topics(바뀐 주제), liar_bank_versions(판본). 새 판 옵션에 bank 판본을 붙여(prepareOptions) 다시 보기·복구가 같은 은행 사용
- 판 상태에 주제 이름·단어 목록·다른 표기를 복사해 진행 중 판은 관리자 수정의 영향을 받지 않음
- 대기실 주제 목록은 GET /api/liar/topics, 관리자 API /api/admin/liar/topics, 기록 liar.topic.*
- 테스트: 엔진(묶음·바보 모드·판본·검사), 서버(관리자 API·새 판·재시작), E2E(관리자 편집 → 대기실 새 주제)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 04:16:17 +09:00
parent 5a878ba991
commit 1bd69200fd
46 changed files with 1639 additions and 75 deletions

View File

@@ -92,10 +92,12 @@ interface TopicModel {
}
const models = new Map<string, TopicModel>();
function model(id: LiarView['topic']): TopicModel {
const hit = models.get(id);
/** The game's topic in the bank version it was set up with (a topic missing there: no sentences, the bot leans on others). */
function model(v: Pick<LiarView, 'topic' | 'topicKo' | 'options'>): TopicModel {
const key = `${v.options.bank ?? ''}|${v.topic}`;
const hit = models.get(key);
if (hit) return hit;
const topic = topicById(id);
const topic = topicById(v.topic, v.options.bank) ?? { id: v.topic, ko: v.topicKo, generic: [], words: [] };
const corpus = new Map<string, Set<string>>();
const df = new Map<string, number>();
for (const w of topic.words) {
@@ -108,7 +110,8 @@ function model(id: LiarView['topic']): TopicModel {
const idf = new Map<string, number>();
for (const [g, d] of df) idf.set(g, Math.log((n + 1) / d) - 0.15);
const m = { topic, corpus, idf };
models.set(id, m);
if (models.size > 200) models.clear();
models.set(key, m);
return m;
}
@@ -158,7 +161,7 @@ class LiarBot {
this.q = Math.min(1, Math.max(0, (level - 1) / 59));
const ph = this.v.phase;
this.phaseId = `${ph.kind}:${ph.round}:${ph.turn}:${ph.voteRound ?? 0}:${ph.startedAt}`;
this.m = model(this.v.topic);
this.m = model(this.v);
}
private h(...k: (string | number)[]): number {
@@ -447,7 +450,7 @@ class LiarBot {
const g = this.guessWord();
if (g) return g;
const words = this.m.topic.words.map((w) => w.word).filter((w) => w !== this.my.word);
return words[Math.floor(this.h('blind') * words.length)]!;
return words[Math.floor(this.h('blind') * words.length)] ?? (this.smart ? '모르겠어요' : '몰라');
}
private replies(key: (s: string) => string, chat: (t: string) => LiarAction | null): Intent[] {