컴퓨터 방 자동 정리 + 게스트 계정 삭제(로그아웃·하루 미접속) + 테스트 10분→1분
- 방 화면을 벗어나면(홈·규칙) detach: 자리·접속 상태는 유지, 방 접속 수에서 빠짐 - 컴퓨터가 있는 방: 사람이 모두 [방 나가기]하면 바로 닫고, 아무도 안 보면 대기실·끝난 방 1분, 게임 중 30분 뒤 정리 - 게스트 로그아웃 = 계정 삭제(자리·전적·세션·소켓), 사이트를 닫고 24시간 지난 게스트도 1분 주기로 삭제 - users.last_seen_at을 요청·소켓 종료 때 갱신(이전엔 갱신 안 됨), 003 마이그레이션에서 기존 게스트 시계 초기화 - 테스트: 무작위 대국 시드를 playoutSeeds()로 평소 1/10, test:full은 전부. bun test --parallel=4, 테스트 서버 종료 대기 1s→50ms Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/** 그림 맞히기 rules tests (docs/games/catchmind.md §10) + seeded random playouts (docs/09 §7). */
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { SeededRng, randomPlayout, seedN, type GameEvent, type PlayerId, type RngState } from '@bg/engine';
|
||||
import { SeededRng, playoutSeeds, randomPlayout, seedN, type GameEvent, type PlayerId, type RngState } from '@bg/engine';
|
||||
import {
|
||||
BUILTIN_WORDS,
|
||||
CHOOSE_MS,
|
||||
@@ -592,10 +592,12 @@ function invariants(s: CatchmindState, poolSize: number): void {
|
||||
}
|
||||
|
||||
describe('무작위 대국(§10, docs/09 §7)', () => {
|
||||
test('1,000판: 예외 없음, 단어·점수 보존, 종료, 결정성', () => {
|
||||
const GAMES = playoutSeeds(1000);
|
||||
const DEEP_GAMES = playoutSeeds(150);
|
||||
test(`${GAMES}판: 예외 없음, 단어·점수 보존, 종료, 결정성`, () => {
|
||||
const t0 = performance.now();
|
||||
let finished = 0;
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
for (let i = 0; i < GAMES; i++) {
|
||||
const pk = SeededRng.fromSeed(seedN(9000 + i));
|
||||
const n = 2 + pk.int(9);
|
||||
const options = opts({
|
||||
@@ -609,7 +611,7 @@ describe('무작위 대국(§10, docs/09 §7)', () => {
|
||||
speedBonus: pk.int(3) === 0,
|
||||
difficulty: (['easy', 'normal', 'mixed'] as const)[pk.int(3)]!,
|
||||
});
|
||||
const run = fastPlayout(P(n), options, seedN(i), 4000, i < 150);
|
||||
const run = fastPlayout(P(n), options, seedN(i), 4000, i < DEEP_GAMES);
|
||||
if (run.state.finished) finished++;
|
||||
else throw new Error(`seed ${i}: not finished after ${run.steps} steps`);
|
||||
if (i % 100 === 0) {
|
||||
@@ -617,7 +619,7 @@ describe('무작위 대국(§10, docs/09 §7)', () => {
|
||||
expect(JSON.stringify(again.state)).toBe(JSON.stringify(run.state));
|
||||
}
|
||||
}
|
||||
expect(finished).toBe(1000);
|
||||
expect(finished).toBe(GAMES);
|
||||
expect(performance.now() - t0).toBeLessThan(55_000);
|
||||
}, 60_000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user