윷놀이: 증강 윷놀이 옵션 추가 (원작 증강 71개 + 추가 10개, 증강 탭·선택 창·능력·알까기·특수 승리)
- 엔진 aug.ts: 라운드·동시 비공개 증강 선택(1·6·12 등, 혼돈 모드, 후보 수, 제외 목록), 질문(거머리·접기·돌림판·투표·색 맞히기 등), 특수 말·보호막·함께 서기·함정/선물/똥/마늘/조준/지뢰, 특수 승리·탈락·순위, 컴퓨터(aug-bot.ts), 알까기 물리(physics.ts) - 화면: 방 설정 [게임 종류] + [증강 윷놀이] 탭(켜기/끄기·찾기), 증강 선택 창, 내 증강 쓰기, 증강 칸, 특수 승리 팝업, 안개, 알까기 조준 - 문서 docs/games/yut-augmented.md, 테스트 aug.test.ts 59개, e2e yut-aug Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -158,3 +158,78 @@ export function throwProbabilities(p: number, backdo = true): Record<Throw, numb
|
||||
mo: q ** 4,
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- geometry (증강 윷놀이)
|
||||
|
||||
/**
|
||||
* Node centres on a 0..100 board (same layout as the screen): 참먹이 bottom-right, 모 top-right, 뒷모 top-left,
|
||||
* 찌모 bottom-left. Used by augments that fold, turn or flick the board.
|
||||
*/
|
||||
export const NODE_POS: readonly (readonly [number, number])[] = (() => {
|
||||
const LO = 8;
|
||||
const HI = 92;
|
||||
const GAP = (HI - LO) / 5;
|
||||
const p: [number, number][] = [];
|
||||
p[0] = [HI, HI];
|
||||
for (let i = 1; i <= 4; i++) p[i] = [HI, HI - GAP * i];
|
||||
p[5] = [HI, LO];
|
||||
for (let i = 6; i <= 9; i++) p[i] = [HI - GAP * (i - 5), LO];
|
||||
p[10] = [LO, LO];
|
||||
for (let i = 11; i <= 14; i++) p[i] = [LO, LO + GAP * (i - 10)];
|
||||
p[15] = [LO, HI];
|
||||
for (let i = 16; i <= 19; i++) p[i] = [LO + GAP * (i - 15), HI];
|
||||
const lerp = (a: [number, number], b: [number, number], t: number): [number, number] => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
||||
[20, 21, 22, 23, 24].forEach((n, k) => (p[n] = lerp(p[5]!, p[15]!, (k + 1) / 6)));
|
||||
[25, 26].forEach((n, k) => (p[n] = lerp(p[10]!, p[0]!, (k + 1) / 6)));
|
||||
[27, 28].forEach((n, k) => (p[n] = lerp(p[10]!, p[0]!, (k + 4) / 6)));
|
||||
return p;
|
||||
})();
|
||||
|
||||
/** The six straight lines of the board, end to end (4 sides, 2 diagonals through 방). */
|
||||
export const STRAIGHT_LINES: readonly (readonly NodeId[])[] = [
|
||||
[0, 1, 2, 3, 4, 5],
|
||||
[5, 6, 7, 8, 9, 10],
|
||||
[10, 11, 12, 13, 14, 15],
|
||||
[15, 16, 17, 18, 19, 0],
|
||||
[5, 20, 21, 22, 23, 24, 15],
|
||||
[10, 25, 26, 22, 27, 28, 0],
|
||||
];
|
||||
|
||||
/** Nodes joined by a board line (graph neighbours, both directions). */
|
||||
export const NEIGHBOURS: readonly (readonly NodeId[])[] = (() => {
|
||||
const nb: Set<NodeId>[] = Array.from({ length: NODE_COUNT }, () => new Set<NodeId>());
|
||||
for (const line of STRAIGHT_LINES)
|
||||
for (let i = 0; i + 1 < line.length; i++) {
|
||||
nb[line[i]!]!.add(line[i + 1]!);
|
||||
nb[line[i + 1]!]!.add(line[i]!);
|
||||
}
|
||||
return nb.map((x) => [...x].sort((a, b) => a - b));
|
||||
})();
|
||||
|
||||
/** Node whose centre is `pt` (exact layout match); throws if none. */
|
||||
function nodeAt(pt: readonly [number, number]): NodeId {
|
||||
const i = NODE_POS.findIndex((q) => Math.abs(q[0] - pt[0]) < 1e-6 && Math.abs(q[1] - pt[1]) < 1e-6);
|
||||
if (i < 0) throw new Error(`no node at ${pt}`);
|
||||
return i;
|
||||
}
|
||||
|
||||
const mapNodes = (f: (p: readonly [number, number]) => [number, number]): NodeId[] => NODE_POS.map((p) => nodeAt(f(p)));
|
||||
|
||||
/** Mirror over the 참먹이–뒷모 diagonal: walking the mirrored board forward = walking this one backwards (달걸음). */
|
||||
export const MIRROR_DIAG: readonly NodeId[] = mapNodes(([x, y]) => [y, x]);
|
||||
/** Left ↔ right, top ↔ bottom mirrors and a quarter turn clockwise (as seen on screen). */
|
||||
export const MIRROR_LR: readonly NodeId[] = mapNodes(([x, y]) => [100 - x, y]);
|
||||
export const MIRROR_TB: readonly NodeId[] = mapNodes(([x, y]) => [x, 100 - y]);
|
||||
export const ROTATE_CW: readonly NodeId[] = mapNodes(([x, y]) => [100 - y, x]);
|
||||
|
||||
/** Nodes on the two diagonals, corners excluded (크고 빨간 버튼). */
|
||||
export const DIAGONAL_NODES: readonly NodeId[] = [20, 21, 22, 23, 24, 25, 26, 27, 28];
|
||||
|
||||
/** Result of `k` sticks of which `flats` show 배 (0 = 모, ≥ 4 = 윷); the marked stick alone gives 빽도. */
|
||||
export function throwOfCount(flats: number, markedOnly: boolean, backdo: boolean): Throw {
|
||||
if (flats === 0) return 'mo';
|
||||
if (flats === 1) return backdo && markedOnly ? 'backdo' : 'do';
|
||||
if (flats === 2) return 'gae';
|
||||
if (flats === 3) return 'geol';
|
||||
return 'yut';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user