라이어 게임: 설명·토론·투표·정답 맞히기 시간 무제한(할 일을 마칠 때까지, 연결 끊긴 사람은 유예 뒤 넘김), 설명·투표·지목 소리, 움직임
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,7 @@ function reject(s: LiarState, actor: PlayerId, a: LiarAction, now?: number): str
|
||||
}
|
||||
const tick = (s: LiarState) => {
|
||||
if (s.phase.kind === 'ended') throw new Error('tick after the end');
|
||||
return act(s, s.players[0]!.id, { type: 'phaseTimeout' }, s.phase.endsAt);
|
||||
return act(s, s.players[0]!.id, { type: 'phaseTimeout' }, s.phase.endsAt!);
|
||||
};
|
||||
function until(s: LiarState, kind: LiarState['phase']['kind']): LiarState {
|
||||
for (let i = 0; i < 60 && s.phase.kind !== kind && s.phase.kind !== 'ended'; i++) s = tick(s);
|
||||
@@ -231,7 +231,7 @@ describe('차례대로 설명 (§5.2)', () => {
|
||||
|
||||
test('한 바퀴 옵션, 시간 초과는 넘김, 설명은 80자까지', () => {
|
||||
let s = tick(rig(3, { rounds: 1, describeSeconds: 15 }));
|
||||
expect(s.phase.kind === 'describe' && s.phase.endsAt - s.phase.startedAt).toBe(15_000);
|
||||
expect(s.phase.kind === 'describe' && s.phase.endsAt! - s.phase.startedAt).toBe(15_000);
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '가'.repeat(81) })).toContain('80자');
|
||||
s = tick(s);
|
||||
expect(s.descriptions[0]).toMatchObject({ from: 'P0', text: null });
|
||||
@@ -381,6 +381,54 @@ describe('나가기 (§8.5)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('시간 무제한 (§8.5)', () => {
|
||||
const U = { describeSeconds: null, discussionSeconds: null, voteSeconds: null, guessSeconds: null };
|
||||
|
||||
test('설명·토론·투표·맞히기 모두 무제한: 마감 없이 할 일을 마칠 때까지, 기다리는 사람만 시간 초과 대상', () => {
|
||||
let s = tick(rig(3, { ...U, rounds: 1 }));
|
||||
expect(s.phase.kind === 'describe' && s.phase.endsAt).toBeNull();
|
||||
expect(liar.deadline!(s)).toBeNull();
|
||||
expect(liar.timeoutPlayers!(s)).toEqual(['P0']);
|
||||
expect(reject(s, 'P1', { type: 'phaseTimeout' })).toBe('아직 기다리는 중이에요.');
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'chat', text: `${p} 설명` }, T0 + 3_600_000);
|
||||
expect(s.phase.kind).toBe('discussion');
|
||||
expect(liar.timeoutPlayers!(s)).toEqual(['P0', 'P1', 'P2']);
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'ready' });
|
||||
expect(s.phase.kind).toBe('vote');
|
||||
s = votes(s, { P0: 'P2', P1: 'P2' });
|
||||
expect(liar.timeoutPlayers!(s)).toEqual(['P2']);
|
||||
s = act(s, 'P2', { type: 'vote', target: 'P0' });
|
||||
expect(s.phase.kind).toBe('guess');
|
||||
expect(liar.timeoutPlayers!(s)).toEqual(['P2']);
|
||||
s = act(s, 'P2', { type: 'guess', text: '수박' }, T0 + 7_200_000);
|
||||
expect(s.final!.reason).toBe('guessed');
|
||||
});
|
||||
|
||||
test('자리 비운 사람은 방의 유예 시간 뒤 자기 차례만 넘김: 설명 넘김·토론 끝·표 없음·답 없음', () => {
|
||||
let s = tick(rig(4, { ...U, rounds: 1 }));
|
||||
s = act(s, 'P0', liar.onTimeout(s, 'P0'));
|
||||
expect(s.descriptions[0]).toMatchObject({ from: 'P0', text: null });
|
||||
for (const p of ['P1', 'P2', 'P3']) s = act(s, p, { type: 'chat', text: `${p} 설명` });
|
||||
for (const p of ['P1', 'P2', 'P3']) s = act(s, p, { type: 'ready' });
|
||||
s = act(s, 'P0', liar.onTimeout(s, 'P0'));
|
||||
expect(s.phase.kind).toBe('vote');
|
||||
s = votes(s, { P1: 'P3', P2: 'P3', P3: 'P1' });
|
||||
expect(liar.view(s, null).players.find((p) => p.id === 'P0')!.voted).toBe(false);
|
||||
s = act(s, 'P0', liar.onTimeout(s, 'P0'));
|
||||
expect(lastEv(s, 'vote')).toMatchObject({ accused: 'P3', votes: { P1: 'P3', P2: 'P3', P3: 'P1' } });
|
||||
s = act(s, 'P3', liar.onTimeout(s, 'P3'));
|
||||
expect(s.final).toMatchObject({ winner: 'citizens', reason: 'caught', guess: null });
|
||||
});
|
||||
|
||||
test('무작위 대국(모두 무제한)도 끝나요', () => {
|
||||
for (let k = 1; k <= playoutSeeds(40); k++) {
|
||||
const n = 3 + (k % 8);
|
||||
const r = randomPlayout(liar, { players: ids(n), options: opts(U), seed: seedN(5000 + k), maxSteps: 3000 });
|
||||
expect(r.finished).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------- engine checks
|
||||
|
||||
describe('무작위 대국 (엔진 공통 검사)', () => {
|
||||
|
||||
Reference in New Issue
Block a user