윷놀이 지역 룰 옵션: 말 없을 때 빽도(버림·다시 던지기·날윷), 낙이면 차례 끝, 던진 순서대로, 업기 고르기, 갈림길 고르기
- 엔진: 새 옵션 5개(기본값은 예전 동작 그대로), MOVE에 piece·alt·stack(선택), 따로 선 무더기는 Piece.group으로 구분 - 컴퓨터: 다른 길·따로 두기·날윷 빽도를 점수로 판단, 따로 선 말도 함께 잡힐 위험으로 계산 - 화면: 방 설정 "지역 룰(우리 동네 규칙)" 묶음(빽도/말 움직이기/던지기, 고른 값 설명, 기본으로 되돌리기), 로비 요약·규칙 보기·도움말에 적용 중인 룰, 게임 중 갈 길 고르기·업기/따로 두기 버튼 - 문서: docs/games/yut.md 2장 표, 7장(추가한 룰·뺀 룰과 이유), 테스트·E2E 갱신 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,14 +23,21 @@ export const THROW_KO: Record<Throw, string> = { do: '도', gae: '개', geol: '
|
||||
/** Display order of the result chips. */
|
||||
export const THROW_ORDER: Throw[] = ['backdo', 'do', 'gae', 'geol', 'yut', 'mo'];
|
||||
|
||||
/** Nodes where a piece that stopped there has two roads ahead: 모, 뒷모, 방. */
|
||||
export const FORKS: readonly NodeId[] = [5, 10, 22];
|
||||
export const isFork = (n: NodeId | 'home'): boolean => n === 5 || n === 10 || n === 22;
|
||||
|
||||
/**
|
||||
* One step forward (§5.2 table). `starting` = this step leaves the node the piece stood on,
|
||||
* `prev` = the node passed just before `node` within the same move (only matters at 방).
|
||||
* `alt` (지역 룰 `forkRule = choose`): when starting on a fork, take the other road — 모/뒷모 keep to the outer ring,
|
||||
* 방 goes on toward 찌모 (23).
|
||||
* Returns GOAL when the piece leaves 참먹이 after a lap.
|
||||
*/
|
||||
export function step(node: NodeId | 'home', starting: boolean, prev: NodeId | null): NodeId | typeof GOAL {
|
||||
export function step(node: NodeId | 'home', starting: boolean, prev: NodeId | null, alt = false): NodeId | typeof GOAL {
|
||||
if (node === 'home') return 1;
|
||||
if (node === 0) return GOAL;
|
||||
if (starting && alt && isFork(node)) return node === 22 ? 23 : node + 1;
|
||||
if (starting) {
|
||||
if (node === 5) return 20;
|
||||
if (node === 10) return 25;
|
||||
@@ -61,14 +68,15 @@ export interface Advance {
|
||||
|
||||
/**
|
||||
* Moves `n` (≥ 1) steps forward from `from`. Reaching GOAL drops the remaining steps.
|
||||
* `alt`: take the other road at the starting fork (see `step`).
|
||||
* With `reach`, arriving at 참먹이 after a lap (always the case when entering 0 by moving forward) finishes at once.
|
||||
*/
|
||||
export function advance(from: NodeId | 'home', n: number, finishRule: 'pass' | 'reach'): Advance {
|
||||
export function advance(from: NodeId | 'home', n: number, finishRule: 'pass' | 'reach', alt = false): Advance {
|
||||
let cur: NodeId | 'home' = from;
|
||||
let prev: NodeId | null = null;
|
||||
const path: NodeId[] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const nxt = step(cur, i === 0, prev);
|
||||
const nxt = step(cur, i === 0, prev, alt && i === 0);
|
||||
if (nxt === GOAL) return { path, to: GOAL };
|
||||
path.push(nxt);
|
||||
prev = cur === 'home' ? null : cur;
|
||||
|
||||
Reference in New Issue
Block a user