컴퓨터 난이도 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:
@@ -55,3 +55,30 @@ export const BOT_GAMES: readonly string[] = [
|
||||
export const PRACTICE_PLAYERS: Readonly<Record<string, number>> = { mafia: 6 };
|
||||
|
||||
export const botsAllowed = (gameId: string): boolean => BOT_GAMES.includes(gameId);
|
||||
|
||||
/**
|
||||
* Computer levels 1~60 (docs/09-game-engine.md §9.1): 1~20 쉬움, 21~40 보통, 41~60 어려움. The host can pick a band
|
||||
* for each computer after adding it; the exact level inside the band is drawn at random and stays hidden until the
|
||||
* game is over (fairness check).
|
||||
*/
|
||||
export const BOT_LEVEL_MAX = 60;
|
||||
export type BotBand = 'easy' | 'normal' | 'hard';
|
||||
export type BotPick = 'random' | BotBand;
|
||||
export const BOT_PICKS: readonly BotPick[] = ['random', 'easy', 'normal', 'hard'];
|
||||
export const BOT_BANDS: Readonly<Record<BotBand, readonly [number, number]>> = { easy: [1, 20], normal: [21, 40], hard: [41, 60] };
|
||||
export const BOT_PICK_LABEL: Readonly<Record<BotPick, string>> = { random: '랜덤', easy: '쉬움', normal: '보통', hard: '어려움' };
|
||||
|
||||
export function bandOf(level: number): BotBand {
|
||||
return level <= BOT_BANDS.easy[1] ? 'easy' : level <= BOT_BANDS.normal[1] ? 'normal' : 'hard';
|
||||
}
|
||||
|
||||
/**
|
||||
* Luck in [-1, 1] as people read it. A computer's luck decides how many shuffles the server tries before a game and
|
||||
* whether it keeps the best or the worst one for that computer (docs/04-stability-security.md §5.1).
|
||||
*/
|
||||
export function luckLabel(luck: number): string {
|
||||
if (luck <= -0.6) return '아주 나쁨';
|
||||
if (luck <= -0.2) return '나쁨';
|
||||
if (luck < 0.2) return '보통';
|
||||
return luck < 0.6 ? '좋음' : '아주 좋음';
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export const ClientMessage = z.discriminatedUnion('t', [
|
||||
z.object({ t: z.literal('host'), userId }),
|
||||
z.object({ t: z.literal('addBot'), seat: z.number().int().min(0).max(31).optional() }),
|
||||
z.object({ t: z.literal('removeBot'), userId }),
|
||||
z.object({ t: z.literal('botLevel'), userId, pick: z.enum(['random', 'easy', 'normal', 'hard']) }),
|
||||
z.object({ t: z.literal('act'), cs: z.number().int().min(1), a: z.unknown() }),
|
||||
z.object({ t: z.literal('chat'), text: z.string().min(1).max(CHAT_MAX) }),
|
||||
z.object({ t: z.literal('emote'), id: z.string().max(20) }),
|
||||
|
||||
@@ -58,6 +58,14 @@ export interface RoomView {
|
||||
lastGamePk: string | null;
|
||||
/** Computers doing something people can see (docs/06 §12.1): "생각 중…" / "입력 중…". */
|
||||
botActivity?: Record<string, 'thinking' | 'typing'>;
|
||||
/** Difficulty the host picked for each computer (랜덤/쉬움/보통/어려움, docs/06 §12). */
|
||||
botPicks?: Record<string, 'random' | 'easy' | 'normal' | 'hard'>;
|
||||
/** Shuffling before the game started (computers' luck, docs/04 §5.1). */
|
||||
starting?: boolean;
|
||||
/** After a game with computers: each computer's level (1~60) and luck in that game, for the fairness check. */
|
||||
lastBots?: Record<string, { level: number; luck: number }>;
|
||||
/** How many shuffles were tried for the computers' luck in that game (1 = the first one, no choice). */
|
||||
lastShuffles?: number;
|
||||
}
|
||||
|
||||
export interface GameResultView {
|
||||
@@ -70,7 +78,7 @@ export interface GameResultView {
|
||||
}
|
||||
|
||||
export type ServerMessage =
|
||||
| { t: 'welcome'; me: PublicUser; serverTime: number; protocol: number; activeRoom: string | null }
|
||||
| { t: 'welcome'; me: PublicUser; serverTime: number; protocol: number; activeRoom: string | null; build?: string | null }
|
||||
| { t: 'room'; seq: number; room: RoomView }
|
||||
| {
|
||||
t: 'state';
|
||||
|
||||
Reference in New Issue
Block a user