윷놀이 지역 룰 옵션: 말 없을 때 빽도(버림·다시 던지기·날윷), 낙이면 차례 끝, 던진 순서대로, 업기 고르기, 갈림길 고르기

- 엔진: 새 옵션 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:
EJClaw
2026-10-13 03:33:12 +09:00
parent 71381087cc
commit 89312e28f2
11 changed files with 1013 additions and 137 deletions

View File

@@ -25,6 +25,8 @@ export const yutBot: BotStrategy<YutView, YutAction> = ({ view, legal, random })
const live = new Set(view.sides.filter((x) => x.id !== me && !x.out && x.finishedRank === null).map((x) => x.id));
const enemyStacks = view.stacks.filter((st) => live.has(st.side));
const enemyHome = view.sides.some((x) => live.has(x.id) && x.home > 0);
// 지역 룰 backdoNoPiece = enter: an enemy with nothing on the board may put a piece on 날윷(19) with 빽도.
const enemyBackdoEnter = o.backdo && o.backdoNoPiece === 'enter' && view.sides.some((x) => live.has(x.id) && x.home > 0 && x.onBoard === 0);
/** Chance that some enemy can land on `node` with its next throw (bonus throws ignored). */
const risk = (node: NodeId): number => {
@@ -32,12 +34,14 @@ export const yutBot: BotStrategy<YutView, YutAction> = ({ view, legal, random })
for (const t of THROWS) {
const hits =
(t !== 'backdo' && enemyHome && advance('home', THROW_STEPS[t], o.finishRule).to === node) ||
(t === 'backdo' && enemyBackdoEnter && node === 19) ||
enemyStacks.some((st) => (t === 'backdo' ? defaultPrev(st.node) === node : advance(st.node, THROW_STEPS[t], o.finishRule).to === node));
if (hits) p += odds[t];
}
return Math.min(1, p);
};
const mineAt = (node: NodeId) => view.stacks.find((st) => st.side === me && st.node === node)?.count ?? 0;
/** Own pieces on `node` (several stacks may share it apart under `stacking = choose`). */
const mineAt = (node: NodeId) => view.stacks.filter((st) => st.side === me && st.node === node).reduce((a, st) => a + st.count, 0);
/** What losing `n` own pieces standing on `node` would cost. */
const exposure = (node: NodeId, n: number) => STEP * n * (home - dist(node)) + 10;
@@ -47,15 +51,18 @@ export const yutBot: BotStrategy<YutView, YutAction> = ({ view, legal, random })
if (m.finishes) return v + 15 * m.count;
const to = m.to as NodeId;
if (m.captures) v += 30 + m.captures * (STEP * (home - dist(to)) + 10);
const group = m.count + (m.stacks ? mineAt(to) : 0);
// Standing apart still shares the node, so a catch there takes everything; only stacking earns the small bonus.
const group = m.count + (m.stacks || m.stack === false ? mineAt(to) : 0);
if (m.stacks) v += 6;
// After a capture we throw again first, so the danger matters less.
v -= (m.captures ? 0.5 : 1) * risk(to) * exposure(to, group);
return v;
};
const byKey = new Map(view.legalMoves.map((m) => [`${m.throwIndex}:${m.from}`, m]));
const key = (x: { throwIndex: number; from: NodeId | 'home'; piece?: number; alt?: boolean; stack?: boolean }) =>
`${x.throwIndex}:${x.from}:${x.piece ?? ''}:${x.alt ? 1 : 0}:${x.stack === false ? 0 : 1}`;
const byKey = new Map(view.legalMoves.map((m) => [key(m), m]));
return best(moves, (a) => {
const m = byKey.get(`${a.throwIndex}:${a.from}`);
const m = byKey.get(key(a));
return m ? score(m) : -1e9;
}, random);
};