게임 속도 배율: 1배도 애니메이션·연출·컴퓨터 생각 시간을 예전의 1.5배로 늦추고, 관리자 사이트 설정 "게임 속도 배율"(1/16~16배, 기본 1)로 나눠 조절. 저장하면 열린 방에도 바로 적용(RoomView.gameSpeed 재전송)
- 서버: SiteSettings.gameSpeed, /api/config에 노출, 컴퓨터 생각 시간(defaultBotDelay)과 마피아·라이어 컴퓨터가 살펴보는 간격에 BOT_SLOWDOWN(1.5)/배율. 게임이 정한 반응 시각(원카드 외치기)은 그대로 - 웹: lib/motion.ts — .game-layout 안 CSS 애니메이션·트랜지션은 useMotionScope가 playbackRate로, Web Animations는 fxAnim, 연출 타이머(배너 유지·다음 단계·복사본 정리·숫자 세기·다시 보기 한 칸)는 fxMs. 채팅·role="timer"·규칙 시간·꾹 눌러 보기는 제외 - 관리자 사이트 탭에 배율 버튼(1/16~16)과 직접 입력 - 테스트: 배율 검증(API 400/200, 열린 방 즉시 반영), 컴퓨터 생각 시간 배율, motion 단위 테스트, e2e/speed.e2e.ts(돌 애니메이션 재생 배율·컴퓨터 응답 시간), 관리자 e2e에 배율 저장 - 문서: 14-admin §5, 07-ui-ux, 06-lobby-rooms, 13-decisions, README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,8 @@ export interface BotRoom {
|
||||
profile?(bot: string): { level: number; base: number };
|
||||
/** The computers' talk and visible activity with the local model (docs/06 §12.1). */
|
||||
brain?: BotBrain;
|
||||
/** Multiplies the computers' thinking time and live games' look intervals (game speed, docs/14 §5); absent = 1. */
|
||||
timeScale?(): number;
|
||||
}
|
||||
|
||||
/** What a planned computer move looks like, for its thinking time. */
|
||||
@@ -47,18 +49,23 @@ export interface BotDelayInput {
|
||||
* Human-like thinking time (ms). A forced move still takes a moment to notice (0.7~1.3 s); a real choice takes longer
|
||||
* the more moves there are (1.6~3.9 s), and now and then the computer hesitates (+1~3 s). Each bot scales it by its
|
||||
* own pace, and a follow-up move of the same turn is quicker. When people may act in the same window the computer
|
||||
* waits 1.5 s more so it never beats a person to a reaction just by being fast.
|
||||
* waits 1.5 s more so it never beats a person to a reaction just by being fast. `scale` (game speed, `BOT_SLOWDOWN /
|
||||
* speed`) multiplies the whole thinking time; a reaction the game timed itself (`reactMs`) is never scaled, so who
|
||||
* calls first stays fair.
|
||||
*/
|
||||
export function defaultBotDelay(input: BotDelayInput, random: () => number = secureRandom): number {
|
||||
export function defaultBotDelay(input: BotDelayInput, random: () => number = secureRandom, scale = 1): number {
|
||||
const { choices, withPeople, bot, followUp } = input;
|
||||
if (input.reactMs !== undefined) return Math.max(0, Math.round(input.reactMs));
|
||||
let ms = choices <= 1 ? 700 + random() * 600 : 1300 + 300 * Math.min(Math.log2(choices), 4) + random() * 1400;
|
||||
if (choices > 1 && !followUp && random() < 0.12) ms += 1000 + random() * 2000;
|
||||
ms *= botPace(bot);
|
||||
if (followUp) ms *= 0.5;
|
||||
return Math.round(withPeople ? ms + 1500 : ms);
|
||||
return Math.round((withPeople ? ms + 1500 : ms) * scale);
|
||||
}
|
||||
|
||||
/** At game speed ×1 the computers take this much longer than `defaultBotDelay`'s base times (2026-10-14: a bit slower). */
|
||||
export const BOT_SLOWDOWN = 1.5;
|
||||
|
||||
/** Never use more than this share of the time left on the turn timer for thinking. */
|
||||
export const BOT_DEADLINE_SHARE = 0.5;
|
||||
|
||||
@@ -86,7 +93,7 @@ export class BotDriver {
|
||||
constructor(
|
||||
private room: BotRoom,
|
||||
private random: () => number = secureRandom,
|
||||
private delay: (input: BotDelayInput) => number = (input) => defaultBotDelay(input, random),
|
||||
private delay: (input: BotDelayInput) => number = (input) => defaultBotDelay(input, random, room.timeScale?.() ?? 1),
|
||||
) {}
|
||||
|
||||
/** Plans the next bot action if the game is waiting on a bot. Keeps an already planned one (the bot is "thinking"). */
|
||||
@@ -154,6 +161,10 @@ export class BotDriver {
|
||||
this.liveDue.clear();
|
||||
}
|
||||
|
||||
private timeScale(): number {
|
||||
return this.room.timeScale?.() ?? 1;
|
||||
}
|
||||
|
||||
private liveStrategy(): LiveBotStrategy | null {
|
||||
return LIVE_BOT_STRATEGIES[this.room.def.id] ?? null;
|
||||
}
|
||||
@@ -177,7 +188,7 @@ export class BotDriver {
|
||||
}
|
||||
const now = this.room.now();
|
||||
for (const p of g.players) {
|
||||
if (isBotId(p) && !this.liveDue.has(p)) this.liveDue.set(p, now + Math.round((300 + this.random() * 1200) * botPace(p)));
|
||||
if (isBotId(p) && !this.liveDue.has(p)) this.liveDue.set(p, now + Math.round((300 + this.random() * 1200) * botPace(p) * this.timeScale()));
|
||||
}
|
||||
const next = Math.min(...this.liveDue.values());
|
||||
this.dueAt = Number.isFinite(next) ? next : null;
|
||||
@@ -210,7 +221,7 @@ export class BotDriver {
|
||||
}
|
||||
const ms = performance.now() - t0;
|
||||
if (ms > BOT_SLOW_MS) this.room.log?.('warn', 'slow bot move', { game: def.id, ms: Math.round(ms) });
|
||||
this.liveDue.set(bot, now + Math.max(100, decision.next));
|
||||
this.liveDue.set(bot, now + Math.max(100, Math.round(decision.next * this.timeScale())));
|
||||
if (decision.action == null) continue;
|
||||
if (!def.validate(g.state, bot, decision.action, { now }).ok) continue; // the moment passed (phase changed); look again later
|
||||
const brain = this.room.brain;
|
||||
|
||||
Reference in New Issue
Block a user