커넥트 포(사목) 규칙·컴퓨터 상대·화면·테스트
- 규칙 모듈 packages/games/src/connect-four: 7×6 기본, 8×7·9×7 판, 열을 고르면 맨 아래 빈칸으로 떨어짐, 가로·세로·대각선 4개(이상) 즉시 승리(이긴 줄 전부 기록), 판이 차면 무승부. 먼저 두는 사람은 오목·오셀로와 같은 관례(무작위/방장 먼저/방장 나중/판마다 번갈아 — gameNo). 시간: 한 수당·피셔·없음, 시간 초과 자동 두기(승리 > 막기 > 위 칸을 내주지 않는 가운데 열), 허용 횟수 넘으면 시간패, 기권·나가기. - 컴퓨터 상대: 네가맥스 알파베타 + 반복 심화 + 치환표, 바로 이기기/막기·강제 수 판정, 열린 줄과 홀짝 줄 위협을 증분 평가. 레벨 1~60에 따라 1~10수 읽기(어려움은 빈칸 24개부터 끝까지 시도), 국면 5만 개 상한으로 한 수 평균 수 ms·최악 수십 ms. humanBest로 사람 같은 실수, 낮은 단계는 4목 막기를 가끔 놓침. - 화면 apps/web/src/games/connect-four: 구멍 뚫린 파란 판(마스크), 떨어지는 애니메이션(움직임 줄이기 존중), 이긴 줄 강조, 열 전체 터치 영역, 키보드 ←·→·Home·End·Enter, 스크린리더 안내, 다크 모드, 30초 요약·도움말. - 등록: GAMES, CATALOG, BOT_GAMES, BOT_STRATEGIES, NO_LUCK, 화면 레지스트리, 아이콘·판 탭, 공통 테스트 목록. - 문서 docs/games/connect-four.md, 목록 한 줄. E2E 계획(PC 키보드 + 휴대폰 터치, 꽉 찬 열 무시, 끝까지). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,7 @@ test('decideBotAction returns null when the bot has nothing to do', () => {
|
||||
});
|
||||
|
||||
describe('levels (docs/09 §9.1)', () => {
|
||||
const BOARD = ['omok', 'chess', 'janggi', 'othello', 'baduk'];
|
||||
const BOARD = ['omok', 'chess', 'janggi', 'othello', 'baduk', 'connect-four'];
|
||||
test.each(BOARD)('%s: the weakest and strongest computers still finish a game against each other', (id) => {
|
||||
const def = GAMES[id]!;
|
||||
for (const level of [1, 60]) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import { ninetyNineBot } from '../ninety-nine/bot';
|
||||
import { mafiaBot } from '../mafia/bot';
|
||||
import { appleBot } from '../apple/bot';
|
||||
import { clueBot } from '../clue/bot';
|
||||
import { connectFourBot } from '../connect-four/bot';
|
||||
|
||||
export type { BotInput, BotStrategy, LiveBotDecision, LiveBotInput, LiveBotStrategy } from './types';
|
||||
export { botDraw, botPace, botPersona, hash01, idLevel, type BotLevel, type BotPersona } from './persona';
|
||||
@@ -62,6 +63,7 @@ export const BOT_STRATEGIES: Record<string, BotStrategy> = {
|
||||
'cockroach-poker': cockroachPokerBot,
|
||||
'ninety-nine': ninetyNineBot,
|
||||
clue: clueBot,
|
||||
'connect-four': connectFourBot,
|
||||
};
|
||||
|
||||
/** The bot's legal actions as the game lists them (validated lazily: only the chosen one, see below). */
|
||||
|
||||
@@ -33,8 +33,8 @@ describe('luck', () => {
|
||||
});
|
||||
|
||||
test('luck is for games with cards, tiles, dice or hidden roles — not for board games', () => {
|
||||
for (const id of ['omok', 'chess', 'janggi', 'othello', 'baduk', 'quoridor', 'mafia', 'dobble']) expect(luckApplies(id)).toBe(false);
|
||||
for (const id of Object.keys(BOT_STRATEGIES).filter((g) => !['omok', 'chess', 'janggi', 'othello', 'baduk', 'quoridor'].includes(g))) {
|
||||
for (const id of ['omok', 'chess', 'janggi', 'othello', 'baduk', 'quoridor', 'connect-four', 'mafia', 'dobble']) expect(luckApplies(id)).toBe(false);
|
||||
for (const id of Object.keys(BOT_STRATEGIES).filter((g) => !['omok', 'chess', 'janggi', 'othello', 'baduk', 'quoridor', 'connect-four'].includes(g))) {
|
||||
expect(luckApplies(id)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ import { BOT_STRATEGIES, decideBotAction } from './index';
|
||||
import type { BotLevel } from './persona';
|
||||
|
||||
/** Games where everything is in view from the start: a shuffle only decides who goes first, so luck stays out. */
|
||||
const NO_LUCK = new Set(['omok', 'othello', 'chess', 'janggi', 'baduk', 'quoridor']);
|
||||
const NO_LUCK = new Set(['omok', 'othello', 'chess', 'janggi', 'baduk', 'quoridor', 'connect-four']);
|
||||
|
||||
export const luckApplies = (gameId: string): boolean => gameId in BOT_STRATEGIES && !NO_LUCK.has(gameId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user