방 설정 "컴퓨터 채팅": 컴퓨터가 혼자 말하는 건 방장이 켤 때만(기본 끄기), 마피아는 항상 켜짐
- RoomConfig/RoomView.botChat, config 메시지에 botChat. 새 방·옛 방 모두 끄기. - BotBrain: 꺼져 있으면 도발·반응·대답·시작 인사·끝 인사 안 함, 모델 미리 올리기도 안 함. 바퀴벌레 포커 진짜/블러핑 판단은 그대로, 한마디만 뺌. - BOT_CHAT_REQUIRED(마피아): 설정과 상관없이 항상 켜짐, 설정 칸에 "항상 켜짐" 표시. - 대기실 설정에 컴퓨터 채팅 켜기/끄기(컴퓨터 상대가 있는 게임만). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* something to sell it. In 마피아 it says each line of the computer's plan in its own words.
|
||||
* Moves themselves still come from each game's computer strategy (it sees only its own screen). Without a model
|
||||
* (not configured, busy, down) the computers simply play as before, silently, and 마피아 uses its built-in lines.
|
||||
* Talking on their own is a room setting (`chatty`, off by default); 마피아 talks always because the game needs it.
|
||||
*/
|
||||
import { secureRandom } from '@bg/engine';
|
||||
import { botPace, hash01 } from '@bg/games/bots';
|
||||
@@ -31,6 +32,11 @@ export interface BrainRoom {
|
||||
recentChat(): { from: string; text: string }[];
|
||||
/** 똑똑한 편 (존댓말) or 허술한 편 (반말), docs/09 §9.1. */
|
||||
smart(bot: string): boolean;
|
||||
/**
|
||||
* The computers may chat on their own (room setting "컴퓨터 채팅"; always on in 마피아). Off: no small talk,
|
||||
* reactions, answers, greetings or end-of-game words — they just play (still showing "생각 중…").
|
||||
*/
|
||||
chatty(): boolean;
|
||||
now(): number;
|
||||
}
|
||||
|
||||
@@ -128,7 +134,7 @@ export class BotBrain {
|
||||
if (!type || type === 'chat' || type === 'say' || type === 'reaction' || type === 'ping' || type === 'timeout') return;
|
||||
this.happened.push(`${this.room.nameOf(actor)} ${ACTION_KO[type] ?? '행동함'}`);
|
||||
if (this.happened.length > 12) this.happened.shift();
|
||||
if (!this.enabled() || this.room.bots().includes(actor) || this.room.gameId() === 'mafia') return;
|
||||
if (!this.enabled() || !this.room.chatty() || this.room.bots().includes(actor) || this.room.gameId() === 'mafia') return;
|
||||
const bots = this.room.bots().filter((b) => this.canTalk(b, 10_000, 30_000));
|
||||
if (!bots.length || this.random() > 0.12) return;
|
||||
const bot = bots[Math.floor(this.random() * bots.length)]!;
|
||||
@@ -152,9 +158,10 @@ export class BotBrain {
|
||||
const r = await this.cockroachBluff(bot, a, view);
|
||||
if (r) {
|
||||
act = r.action;
|
||||
line = r.say;
|
||||
// Chat off: the model still decides truth or bluff, the computer just hands the card over without a word.
|
||||
line = this.room.chatty() ? r.say : null;
|
||||
}
|
||||
} else if (this.canTalk(bot) && this.random() < temperOf(bot).talk) {
|
||||
} else if (this.room.chatty() && this.canTalk(bot) && this.random() < temperOf(bot).talk) {
|
||||
const type = String(a.type ?? '');
|
||||
line = await writeLine(this.llm, this.request(bot, this.situation(), `나는 지금 "${ACTION_KO[type] ?? '내 수'}"를 하려 한다. 이 수를 두며 상대에게 던지는 도발이나 심리전 한마디.`));
|
||||
}
|
||||
@@ -195,7 +202,7 @@ export class BotBrain {
|
||||
|
||||
/** People chatting: a named computer answers; otherwise sometimes one of them joins in. */
|
||||
onHumanChat(from: string, text: string): void {
|
||||
if (!this.enabled() || this.room.gameId() === 'mafia') return;
|
||||
if (!this.enabled() || !this.room.chatty() || this.room.gameId() === 'mafia') return;
|
||||
const bots = this.room.bots();
|
||||
const named = bots.find((b) => {
|
||||
const n = /^컴퓨터 (\d+)$/.exec(this.room.nameOf(b))?.[1];
|
||||
@@ -212,9 +219,10 @@ export class BotBrain {
|
||||
|
||||
onGameStart(): void {
|
||||
this.happened = [];
|
||||
// A game with computers and people: make sure the model is loaded before anyone talks.
|
||||
if (this.llm?.available() && this.room.humans().length && this.room.bots().length) void this.llm.warm();
|
||||
if (!this.enabled() || this.room.gameId() === 'mafia' || this.random() > 0.7) return;
|
||||
// A game with computers and people where the model will be used: make sure it is loaded before anyone talks.
|
||||
const usesModel = this.room.chatty() || this.room.gameId() === 'cockroach-poker';
|
||||
if (usesModel && this.llm?.available() && this.room.humans().length && this.room.bots().length) void this.llm.warm();
|
||||
if (!this.enabled() || !this.room.chatty() || this.room.gameId() === 'mafia' || this.random() > 0.7) return;
|
||||
const bots = this.room.bots();
|
||||
const bot = bots[Math.floor(this.random() * bots.length)];
|
||||
if (!bot) return;
|
||||
@@ -226,7 +234,7 @@ export class BotBrain {
|
||||
|
||||
/** The game ended: a computer that won gloats a little, or one that lost takes it with a word. */
|
||||
onGameEnd(ranking: string[][]): void {
|
||||
if (!this.llm?.available() || !this.room.humans().length || this.room.gameId() === 'mafia' || this.random() > 0.85) return;
|
||||
if (!this.llm?.available() || !this.room.chatty() || !this.room.humans().length || this.room.gameId() === 'mafia' || this.random() > 0.85) return;
|
||||
const bots = this.room.bots();
|
||||
const winner = (ranking[0] ?? []).find((p) => bots.includes(p));
|
||||
const bot = winner ?? bots[Math.floor(this.random() * bots.length)];
|
||||
|
||||
Reference in New Issue
Block a user