위협 가이드 제거: 오목 위험 자리, 체스·장기 위험 기물 경고, 바둑 단수 경고

- 오목: 상대 3·4를 막으라는 빨간 동그라미·노란 점선(hints 옵션, view.hints, threatHints) 삭제
- 체스·장기: hints 'movesAndThreats'(주황 점선 위험 기물) 삭제 → 'off' / 'moves'만 남김
- 바둑: atariWarning 옵션과 atariWarnings(깜빡이는 단수 돌) 삭제
- 도움말 문구·설정 화면·docs 정리, 테스트는 "어떤 view에도 위협 표시 없음"으로 바꿈
- 갈 수 있는 칸 점, 금수 ×, 둘 수 없는 점 같은 규칙 표시는 그대로

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-07 15:34:58 +09:00
parent 53fbbc1c9d
commit 4cb71d8cbe
22 changed files with 40 additions and 135 deletions

View File

@@ -1,7 +1,7 @@
import { describe, expect, test } from 'bun:test';
import { SeededRng, randomPlayout, seedN } from '@bg/engine';
import { chess, type ChessAction, type ChessOptions, type ChessState } from './index';
import { START_FEN, adapterPerft, cannotMate, chess960Fen, fullFen, insufficientMaterial, keyOf, load, positionKey, threatenedSquares } from './rules';
import { START_FEN, adapterPerft, cannotMate, chess960Fen, fullFen, insufficientMaterial, keyOf, load, positionKey } from './rules';
const rng = () => SeededRng.fromSeed([1, 2, 3, 4]);
@@ -323,19 +323,17 @@ describe('requests', () => {
});
describe('views and playouts', () => {
test('legalMoves / threatened only for the player to move; no rng anywhere', () => {
const s = make({ hints: 'movesAndThreats' }, '4k3/8/8/3q4/8/8/3N4/K7 w - - 0 1');
test('legalMoves only for the player to move; no threat warnings; no rng anywhere', () => {
const s = make({}, '4k3/8/8/3q4/8/8/3N4/K7 w - - 0 1');
const mine = chess.view(s, 'A');
expect(mine.legalMoves?.length).toBeGreaterThan(0);
expect(mine.threatened).toEqual(['d2']);
for (const v of [chess.view(s, 'B'), chess.view(s, null)]) {
expect(v.legalMoves).toBeNull();
expect(v.threatened).toBeNull();
for (const v of [chess.view(s, 'B'), chess.view(s, null)]) expect(v.legalMoves).toBeNull();
for (const v of [mine, chess.view(s, 'B'), chess.view(s, null)]) {
expect(v).not.toHaveProperty('threatened');
expect(JSON.stringify(v)).not.toMatch(/rng/i);
}
expect(chess.view(make(), 'A').threatened).toBeNull();
for (const v of [mine, chess.view(s, 'B'), chess.view(s, null)]) expect(JSON.stringify(v)).not.toMatch(/rng/i);
expect(JSON.stringify(s)).not.toMatch(/rng/i);
expect(threatenedSquares(load('4k3/8/8/3q4/8/8/3N4/K2Q4 w - - 0 1'))).toEqual([]);
expect(chess.optionsSchema.safeParse({ hints: 'movesAndThreats' }).success).toBe(false);
});
test('view shape: board, check square, captured pieces and material, promotion flag', () => {
const s = play(make(), 'e2e4', 'd7d5', 'e4d5', 'd8d5', 'b1c3', 'd5e5');

View File

@@ -20,7 +20,6 @@ import {
positionKey,
pseudoReachable,
startFenFor,
threatenedSquares,
toSide,
type Color,
type LegalMove,
@@ -73,9 +72,9 @@ export const chessOptionsSchema = z.object({
.default(600)
.meta({ title: '시간 제한 없음일 때 무응답 한도', labels: { 300: '5분', 600: '10분' } }),
hints: z
.enum(['off', 'moves', 'movesAndThreats'])
.enum(['off', 'moves'])
.default('moves')
.meta({ title: '초보 도움말', labels: { off: '끄기', moves: '갈 수 있는 칸 표시', movesAndThreats: '갈 수 있는 칸 + 위험한 기물 경고' } }),
.meta({ title: '초보 도움말', labels: { off: '끄기', moves: '갈 수 있는 칸 표시' } }),
});
export type ChessOptions = z.infer<typeof chessOptionsSchema>;
@@ -181,8 +180,6 @@ export interface ChessView {
hints: ChessOptions['hints'];
/** Only for the player to move. */
legalMoves: LegalMove[] | null;
/** Only for the player to move with hints=movesAndThreats. */
threatened: string[] | null;
result: ChessResult | null;
}
@@ -589,7 +586,6 @@ export const chess: GameDefinition<ChessState, ChessAction, ChessView, ChessOpti
autoQueen: s.options.autoQueen,
hints: s.options.hints,
legalMoves: mover ? legalMoves(c) : null,
threatened: mover && s.options.hints === 'movesAndThreats' ? threatenedSquares(c) : null,
result: s.result,
};
},

View File

@@ -193,15 +193,6 @@ export function cannotMate(c: Position, side: 'w' | 'b'): boolean {
return false;
}
/** The side to move's non-king pieces that are attacked and not defended (hints=movesAndThreats). */
export function threatenedSquares(c: Position): string[] {
const us = c.turn();
const them = us === 'w' ? 'b' : 'w';
return pieces(c)
.filter((p) => p.color === us && p.type !== 'k' && c.isAttacked(p.square, them) && !c.isAttacked(p.square, us))
.map((p) => p.square);
}
export function kingSquare(c: Position, side: 'w' | 'b'): string {
return c.kingSquare(side);
}