사과 게임: 같은 판(17×10) 합 10 만들기 경주, 1~8명·혼자 가능, 레벨별 컴퓨터(라이브 봇)
- 규칙 모듈 packages/games/src/apple: 시드로 만든 한 판(1~9, 합 10의 배수)을 모두 각자 풀고, 직사각형 합이 딱 10이면 지운 개수만큼 점수. 빈 칸은 합에 영향 없음, 합≠10·빈 직사각형은 거절(벌점 없음). 3초 카운트다운(판 숨김) → 제한 시간 1/2/3분(기본 2분), 서버 시계 마감(deadline = timeoutNotBefore, 끊긴 사람 조기 시간 초과 없음), 1초 5번 속도 제한, 더 지울 게 없으면 막힘 → 모두 막히면 조기 종료, 나가면 맨 아래 순위·혼자 남으면 끝. 동점은 같은 순위, 결과 "사과 N개". - view는 내 판(170자 문자열)과 모두의 점수만(남의 판 없음). findMoves는 누적합으로 가장 좁은 합 10 직사각형 전부. - 컴퓨터: 마피아처럼 LIVE_BOT_STRATEGIES.apple. live 전략에 level 전달(서버 bots.ts, live-playout). 레벨 따라 찾는 시간(6초→2초)·시야·놓침(쉬움 30%)·고르기가 달라짐. 2분 평균 레벨1 약 28개 ~ 레벨60 약 99개. - 화면 apps/web/src/games/apple: SVG 사과, 포인터 드래그(마우스·터치), 합계 실시간·10이면 초록, 낙관적 지우기와 튀어 오르는 애니메이션, 휴대폰은 판을 돌려 10열×17줄, 키보드(화살표+스페이스 두 번, Esc), 다른 사람 점수 칩, 다크 모드, 도움말·30초 요약. - 등록(GAMES, CATALOG, BOT_GAMES, 화면 레지스트리, 아이콘·파티 탭), 문서 docs/games/apple.md, 09 §9 라이브 봇 줄. - 테스트: 규칙 15개(무차별 대조, 무작위 대국 1·2·5·8명), 컴퓨터 5개, 도움말 2개, 방 통합 2개(컴퓨터와 끝까지), E2E(PC 마우스·키보드, 휴대폰 CDP 터치, 320px, 1분 뒤 결과). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import { lasVegasBot } from '../las-vegas/bot';
|
||||
import { cockroachPokerBot } from '../cockroach-poker/bot';
|
||||
import { ninetyNineBot } from '../ninety-nine/bot';
|
||||
import { mafiaBot } from '../mafia/bot';
|
||||
import { appleBot } from '../apple/bot';
|
||||
|
||||
export type { BotInput, BotStrategy, LiveBotDecision, LiveBotInput, LiveBotStrategy } from './types';
|
||||
export { botDraw, botPace, botPersona, hash01, idLevel, type BotLevel, type BotPersona } from './persona';
|
||||
@@ -97,7 +98,8 @@ export function decideBotAction(
|
||||
return rest.length ? pick(playable(rest), random) : null;
|
||||
}
|
||||
|
||||
/** Live strategies (games where everybody acts at once and talks); also in `BOT_GAMES`. */
|
||||
/** Live strategies (games where everybody acts at once: 마피아 talks, 사과 게임 races on its own board); also in `BOT_GAMES`. */
|
||||
export const LIVE_BOT_STRATEGIES: Record<string, LiveBotStrategy> = {
|
||||
mafia: mafiaBot,
|
||||
apple: appleBot,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Test helper: live bots (마피아) play a whole game on a simulated clock, each on its own timer, like `BotDriver`. */
|
||||
import { SeededRng, type AnyGameDefinition, type PlayerId, type RngState } from '@bg/engine';
|
||||
import { botPersona, type BotPersona } from './persona';
|
||||
import { botPersona, type BotLevel, type BotPersona } from './persona';
|
||||
import type { LiveBotStrategy } from './types';
|
||||
|
||||
export interface LiveLine {
|
||||
@@ -33,6 +33,8 @@ export function liveBotPlayout(
|
||||
names?: Record<PlayerId, string>;
|
||||
/** Override characters (tests): called once after setup with the game state. */
|
||||
personaOf?: (p: PlayerId, state: unknown) => BotPersona;
|
||||
/** Each computer's level (default: none, the strategy's own default). */
|
||||
levelOf?: (p: PlayerId) => BotLevel;
|
||||
maxMs?: number;
|
||||
},
|
||||
): LivePlayoutReport {
|
||||
@@ -72,7 +74,7 @@ export function liveBotPlayout(
|
||||
if (bot === null) throw new Error(`${def.id}: stalled`);
|
||||
now = Math.max(now, due.get(bot)!);
|
||||
const t0 = performance.now();
|
||||
const d = strategy({ me: bot, view: structuredClone(def.view(state, bot)), now, random, persona: persona.get(bot)!, names, memory: memory.get(bot)! });
|
||||
const d = strategy({ me: bot, view: structuredClone(def.view(state, bot)), now, random, persona: persona.get(bot)!, level: opts.levelOf?.(bot), names, memory: memory.get(bot)! });
|
||||
rep.maxBotMs = Math.max(rep.maxBotMs, performance.now() - t0);
|
||||
due.set(bot, now + Math.max(50, d.next));
|
||||
if (d.action) {
|
||||
|
||||
@@ -35,6 +35,8 @@ export interface LiveBotInput<V = any> {
|
||||
now: number;
|
||||
random: () => number;
|
||||
persona: import('./persona').BotPersona;
|
||||
/** The computer's level now (1~60, docs/09 §9.1); absent in tests that only care about the character. */
|
||||
level?: import('./persona').BotLevel;
|
||||
/** Display names of the players (what people call each other in chat). */
|
||||
names: Record<PlayerId, string>;
|
||||
/** The bot's own notes for this game (what it already said or did). Kept by the caller between calls. */
|
||||
|
||||
Reference in New Issue
Block a user