증강 윷놀이: 얼음!·뒤로 돌아·자리 바꾸기가 같은 칸의 상대 말뭉치 중 고른 하나만 대상으로 함 (targetPiece)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ export function augBotAction(view: YutView, legal: A[], random: () => number): A
|
||||
}
|
||||
// ---- my turn: abilities before throwing / moving
|
||||
const uses = has('AUG_USE') as Extract<A, { type: 'AUG_USE' }>[];
|
||||
const opt = (a: Extract<A, { type: 'AUG_USE' }>) => aug.uses.find((u) => u.uid === a.uid && u.action.piece === a.piece && u.action.node === a.node && u.action.node2 === a.node2 && u.action.target === a.target && u.action.result === a.result);
|
||||
const opt = (a: Extract<A, { type: 'AUG_USE' }>) => aug.uses.find((u) => u.uid === a.uid && u.action.piece === a.piece && u.action.node === a.node && u.action.node2 === a.node2 && u.action.target === a.target && u.action.targetPiece === a.targetPiece && u.action.result === a.result);
|
||||
const idOf = (a: Extract<A, { type: 'AUG_USE' }>) => aug.sides.find((x) => x.id === me)?.augs.find((o) => o.uid === a.uid)?.id;
|
||||
let bestUse: { a: A; v: number } | null = null;
|
||||
const consider = (a: A, v: number) => {
|
||||
|
||||
@@ -772,11 +772,28 @@ describe('증강 윷놀이: 이 사이트 추가 증강', () => {
|
||||
const s = make();
|
||||
give(s, 0, 'freeze');
|
||||
put(s, 1, 0, 9);
|
||||
const t = act(s, 'A', { type: 'AUG_USE', uid: uidOf(s, 0, 'freeze'), target: 1, node: 9 });
|
||||
const t = act(s, 'A', { type: 'AUG_USE', uid: uidOf(s, 0, 'freeze'), target: 1, node: 9, targetPiece: 0 });
|
||||
expect(t.sides[1]!.pieces[0]!.frozenUntil).toBe(t.aug!.round + 2);
|
||||
expect(yut.view(t, 'B').stacks.find((st) => st.side === 1)).toMatchObject({ node: 9, frozen: true });
|
||||
});
|
||||
|
||||
test('얼음! and 뒤로 돌아 hit only the chosen stack when two stand apart on one node', () => {
|
||||
const s = make(2, { stacking: 'choose' });
|
||||
give(s, 0, 'freeze');
|
||||
give(s, 0, 'pushback');
|
||||
put(s, 1, 0, 9, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
put(s, 1, 1, 9, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
s.sides[1]!.pieces[1]!.group = 1; // standing apart from piece 0
|
||||
const v = yut.view(s, 'A').aug!.uses;
|
||||
expect(v.filter((u) => u.id === 'freeze').map((u) => u.action.targetPiece)).toEqual([0, 1]);
|
||||
expect(v.filter((u) => u.id === 'pushback').map((u) => u.action.targetPiece)).toEqual([0, 1]);
|
||||
let t = act(s, 'A', { type: 'AUG_USE', uid: uidOf(s, 0, 'freeze'), target: 1, node: 9, targetPiece: 1 });
|
||||
expect(t.sides[1]!.pieces[0]!.frozenUntil).toBeUndefined();
|
||||
expect(t.sides[1]!.pieces[1]!.frozenUntil).toBe(t.aug!.round + 2);
|
||||
t = act(s, 'A', { type: 'AUG_USE', uid: uidOf(s, 0, 'pushback'), target: 1, node: 9, targetPiece: 1 });
|
||||
expect(nodesOf(t, 1).slice(0, 2)).toEqual([9, 6]);
|
||||
});
|
||||
|
||||
test('자석 catches the enemy pieces next to my stack', () => {
|
||||
const s = make();
|
||||
give(s, 0, 'magnet');
|
||||
@@ -798,7 +815,7 @@ describe('증강 윷놀이: 이 사이트 추가 증강', () => {
|
||||
put(s, 0, 0, 6);
|
||||
const opts = yut.view(s, 'A').aug!.uses.filter((u) => u.id === 'pushback');
|
||||
expect(opts.map((u) => u.action.node)).toEqual([9]);
|
||||
const t = act(s, 'A', { type: 'AUG_USE', uid: uidOf(s, 0, 'pushback'), target: 1, node: 9 });
|
||||
const t = act(s, 'A', { type: 'AUG_USE', uid: uidOf(s, 0, 'pushback'), target: 1, node: 9, targetPiece: 0 });
|
||||
expect(nodesOf(t, 1)[0]).toBe(6);
|
||||
expect(nodesOf(t, 0)[0]).toBe('home');
|
||||
});
|
||||
|
||||
@@ -181,6 +181,8 @@ export type AugUse = {
|
||||
node?: number;
|
||||
node2?: number;
|
||||
target?: number;
|
||||
/** A piece in the other player's target stack (several stacks may share a node). */
|
||||
targetPiece?: number;
|
||||
result?: Throw;
|
||||
angle?: number;
|
||||
power?: number;
|
||||
@@ -2467,7 +2469,7 @@ export function useOptions(s: YutState, side: SideId): AugUseOption[] {
|
||||
for (const g of stacks)
|
||||
for (const y of s.sides) {
|
||||
if (y.id === side || !sideActive(y)) continue;
|
||||
for (const h of stacksAug(y)) if (h.node !== g.node) add({ piece: g.ids[0]!, target: y.id, node: h.node }, `${pieceLabel(s, side, g.ps)} ↔ ${nm(y.id)} ${nodeKo(h.node)}`);
|
||||
for (const h of stacksAug(y)) if (h.node !== g.node) add({ piece: g.ids[0]!, target: y.id, node: h.node, targetPiece: h.ids[0]! }, `${pieceLabel(s, side, g.ps)} ↔ ${nm(y.id)} ${pieceLabel(s, y.id, y.pieces.filter((p) => h.ids.includes(p.id)))}`);
|
||||
}
|
||||
break;
|
||||
case 'reroll':
|
||||
@@ -2486,17 +2488,14 @@ export function useOptions(s: YutState, side: SideId): AugUseOption[] {
|
||||
case 'pushback':
|
||||
for (const y of s.sides) {
|
||||
if (y.id === side || !sideActive(y)) continue;
|
||||
const seen = new Set<NodeId>();
|
||||
for (const h of stacksAug(y)) {
|
||||
if (seen.has(h.node)) continue;
|
||||
seen.add(h.node);
|
||||
const ps = y.pieces.filter((p) => h.ids.includes(p.id));
|
||||
if (o.id === 'freeze') {
|
||||
if (!ps.every((p) => frozen(s, p))) add({ target: y.id, node: h.node }, `${nm(y.id)} ${pieceLabel(s, y.id, ps)}`);
|
||||
if (!ps.every((p) => frozen(s, p))) add({ target: y.id, node: h.node, targetPiece: h.ids[0]! }, `${nm(y.id)} ${pieceLabel(s, y.id, ps)}`);
|
||||
} else {
|
||||
const b = walkBack(s, y.id, h.node, ps[0]!.trail, 3);
|
||||
// never past 참먹이 (that would put the stack next to the finish)
|
||||
if (b.to !== GOAL && !b.path.includes(0)) add({ target: y.id, node: h.node }, `${nm(y.id)} ${pieceLabel(s, y.id, ps)} → ${nodeKo(b.to)}`, previewKills(s, y.id, b.to, h.ids, true));
|
||||
if (b.to !== GOAL && !b.path.includes(0)) add({ target: y.id, node: h.node, targetPiece: h.ids[0]! }, `${nm(y.id)} ${pieceLabel(s, y.id, ps)} → ${nodeKo(b.to)}`, previewKills(s, y.id, b.to, h.ids, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2517,7 +2516,7 @@ export function useOptions(s: YutState, side: SideId): AugUseOption[] {
|
||||
}
|
||||
|
||||
function sameUse(a: Omit<AugUse, 'type'>, b: Omit<AugUse, 'type'>): boolean {
|
||||
const keys: (keyof AugUse)[] = ['uid', 'piece', 'node', 'node2', 'target', 'result'];
|
||||
const keys: (keyof AugUse)[] = ['uid', 'piece', 'node', 'node2', 'target', 'targetPiece', 'result'];
|
||||
return keys.every((k) => a[k as keyof typeof a] === b[k as keyof typeof b]);
|
||||
}
|
||||
|
||||
@@ -2724,8 +2723,7 @@ function applyUse(s: YutState, ctx: Ctx, side: SideId, act: AugUse): void {
|
||||
case 'swap': {
|
||||
const mine = stackOf(act.piece!);
|
||||
const y = s.sides[act.target!]!;
|
||||
const g = stacksAug(y).find((h) => h.node === act.node!)!;
|
||||
const theirs = y.pieces.filter((p) => g.ids.includes(p.id));
|
||||
const theirs = stackOfPiece(y, act.targetPiece!);
|
||||
const myNode = mine[0]!.node!;
|
||||
for (const p of mine) relocate(p, act.node!);
|
||||
for (const p of theirs) relocate(p, myNode);
|
||||
@@ -2763,14 +2761,13 @@ function applyUse(s: YutState, ctx: Ctx, side: SideId, act: AugUse): void {
|
||||
break;
|
||||
case 'freeze': {
|
||||
const y = s.sides[act.target!]!;
|
||||
for (const p of y.pieces) if (p.status === 'board' && p.node === act.node) p.frozenUntil = Math.max(p.frozenUntil ?? 0, a.round + 2);
|
||||
for (const p of stackOfPiece(y, act.targetPiece!)) p.frozenUntil = Math.max(p.frozenUntil ?? 0, a.round + 2);
|
||||
say(`얼음! ${nm(y.id)}의 ${nodeKo(act.node!)} 말이 2라운드 동안 얼었어요`);
|
||||
break;
|
||||
}
|
||||
case 'pushback': {
|
||||
const y = s.sides[act.target!]!;
|
||||
const g = stacksAug(y).find((h) => h.node === act.node!)!;
|
||||
const ps = y.pieces.filter((p) => g.ids.includes(p.id));
|
||||
const ps = stackOfPiece(y, act.targetPiece!);
|
||||
const b = walkBack(s, y.id, act.node!, ps[0]!.trail, 3);
|
||||
say(`뒤로 돌아: ${nm(y.id)}의 ${nodeKo(act.node!)} 말이 ${nodeKo(b.to as NodeId)}까지 밀려났어요`);
|
||||
shiftStack(s, ctx, y.id, ps, b.to, b.trail);
|
||||
|
||||
@@ -146,6 +146,8 @@ export const yutActionSchema = z.discriminatedUnion('type', [
|
||||
node: NODE_NO.optional(),
|
||||
node2: NODE_NO.optional(),
|
||||
target: z.number().int().min(0).max(7).optional(),
|
||||
/** Another player's stack (any piece id in it): 얼음!, 뒤로 돌아, 자리 바꾸기. */
|
||||
targetPiece: PIECE_NO.optional(),
|
||||
result: z.enum(THROW_IDS).optional(),
|
||||
angle: z.number().int().min(0).max(359).optional(),
|
||||
power: z.number().int().min(1).max(100).optional(),
|
||||
|
||||
Reference in New Issue
Block a user