gigachess 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/dist/attacks.d.ts +40 -0
- package/dist/attacks.d.ts.map +1 -0
- package/dist/attacks.js +389 -0
- package/dist/bishopMagicBlob.d.ts +2 -0
- package/dist/bishopMagicBlob.d.ts.map +1 -0
- package/dist/bishopMagicBlob.js +11 -0
- package/dist/board.d.ts +73 -0
- package/dist/board.d.ts.map +1 -0
- package/dist/board.js +237 -0
- package/dist/chess.d.ts +215 -0
- package/dist/chess.d.ts.map +1 -0
- package/dist/chess.js +1453 -0
- package/dist/chess960.d.ts +10 -0
- package/dist/chess960.d.ts.map +1 -0
- package/dist/chess960.js +18 -0
- package/dist/chessops/board.d.ts +49 -0
- package/dist/chessops/board.d.ts.map +1 -0
- package/dist/chessops/board.js +138 -0
- package/dist/chessops/chess.d.ts +104 -0
- package/dist/chessops/chess.d.ts.map +1 -0
- package/dist/chessops/chess.js +435 -0
- package/dist/chessops/compat.d.ts +19 -0
- package/dist/chessops/compat.d.ts.map +1 -0
- package/dist/chessops/compat.js +25 -0
- package/dist/chessops/convert.d.ts +42 -0
- package/dist/chessops/convert.d.ts.map +1 -0
- package/dist/chessops/convert.js +114 -0
- package/dist/chessops/debug.d.ts +17 -0
- package/dist/chessops/debug.d.ts.map +1 -0
- package/dist/chessops/debug.js +67 -0
- package/dist/chessops/fen.d.ts +28 -0
- package/dist/chessops/fen.d.ts.map +1 -0
- package/dist/chessops/fen.js +74 -0
- package/dist/chessops/fenInternal.d.ts +15 -0
- package/dist/chessops/fenInternal.d.ts.map +1 -0
- package/dist/chessops/fenInternal.js +42 -0
- package/dist/chessops/index.d.ts +12 -0
- package/dist/chessops/index.d.ts.map +1 -0
- package/dist/chessops/index.js +17 -0
- package/dist/chessops/san.d.ts +7 -0
- package/dist/chessops/san.d.ts.map +1 -0
- package/dist/chessops/san.js +33 -0
- package/dist/chessops/setup.d.ts +64 -0
- package/dist/chessops/setup.d.ts.map +1 -0
- package/dist/chessops/setup.js +158 -0
- package/dist/chessops/squareSet.d.ts +48 -0
- package/dist/chessops/squareSet.d.ts.map +1 -0
- package/dist/chessops/squareSet.js +192 -0
- package/dist/chessops/transform.d.ts +12 -0
- package/dist/chessops/transform.d.ts.map +1 -0
- package/dist/chessops/transform.js +53 -0
- package/dist/chessops/types.d.ts +47 -0
- package/dist/chessops/types.d.ts.map +1 -0
- package/dist/chessops/types.js +12 -0
- package/dist/chessops/util.d.ts +19 -0
- package/dist/chessops/util.d.ts.map +1 -0
- package/dist/chessops/util.js +52 -0
- package/dist/chesstree.d.ts +143 -0
- package/dist/chesstree.d.ts.map +1 -0
- package/dist/chesstree.js +514 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +11 -0
- package/dist/fen.d.ts +10 -0
- package/dist/fen.d.ts.map +1 -0
- package/dist/fen.js +600 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/packedMove.d.ts +31 -0
- package/dist/packedMove.d.ts.map +1 -0
- package/dist/packedMove.js +88 -0
- package/dist/pgn.d.ts +24 -0
- package/dist/pgn.d.ts.map +1 -0
- package/dist/pgn.js +361 -0
- package/dist/rookMagicBlob.d.ts +2 -0
- package/dist/rookMagicBlob.d.ts.map +1 -0
- package/dist/rookMagicBlob.js +11 -0
- package/dist/san.d.ts +6 -0
- package/dist/san.d.ts.map +1 -0
- package/dist/san.js +484 -0
- package/dist/squareSet.d.ts +48 -0
- package/dist/squareSet.d.ts.map +1 -0
- package/dist/squareSet.js +154 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +88 -0
- package/dist/util.d.ts +11 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +59 -0
- package/dist/zobrist.d.ts +45 -0
- package/dist/zobrist.d.ts.map +1 -0
- package/dist/zobrist.js +271 -0
- package/dist/zobristBlob.d.ts +2 -0
- package/dist/zobristBlob.d.ts.map +1 -0
- package/dist/zobristBlob.js +11 -0
- package/package.json +135 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
// src/baseline/chess.ts — baseline-exact Position/Chess/Castles classes (ADR-014).
|
|
2
|
+
// The facade keeps the baseline mutable-instance semantics (play() mutates the
|
|
3
|
+
// position, exactly like baseline) while delegating all rules to the immutable
|
|
4
|
+
// turbochess engine. Caller-provided values (Setup, Move) are never mutated.
|
|
5
|
+
import { Result } from "@badrap/result";
|
|
6
|
+
import * as engine from "../chess.js";
|
|
7
|
+
import * as engineAttacks from "../attacks.js";
|
|
8
|
+
import { Board, boardEquals } from "./board.js";
|
|
9
|
+
import { SquareSet } from "./squareSet.js";
|
|
10
|
+
import { moveFromFacade, setupToEngine, boardToEngine } from "./convert.js";
|
|
11
|
+
import { isDrop } from "./types.js";
|
|
12
|
+
import { makeFen as makeFenInternal, parseFen as parseFenInternal } from "./fen.js";
|
|
13
|
+
import { INITIAL_FEN } from "./fenInternal.js";
|
|
14
|
+
export var IllegalSetup;
|
|
15
|
+
(function (IllegalSetup) {
|
|
16
|
+
IllegalSetup["Empty"] = "ERR_EMPTY";
|
|
17
|
+
IllegalSetup["OppositeCheck"] = "ERR_OPPOSITE_CHECK";
|
|
18
|
+
IllegalSetup["PawnsOnBackrank"] = "ERR_PAWNS_ON_BACKRANK";
|
|
19
|
+
IllegalSetup["Kings"] = "ERR_KINGS";
|
|
20
|
+
IllegalSetup["Variant"] = "ERR_VARIANT";
|
|
21
|
+
})(IllegalSetup || (IllegalSetup = {}));
|
|
22
|
+
export class PositionError extends Error {
|
|
23
|
+
}
|
|
24
|
+
const between = (a, b) => {
|
|
25
|
+
const r = engineAttacks.between(a, b);
|
|
26
|
+
return new SquareSet(r.lo, r.hi);
|
|
27
|
+
};
|
|
28
|
+
const toFacadeSet = (s) => new SquareSet(s.lo | 0, s.hi | 0);
|
|
29
|
+
export class Castles {
|
|
30
|
+
constructor(castlingRights) {
|
|
31
|
+
this.castlingRights = castlingRights;
|
|
32
|
+
this.path = {
|
|
33
|
+
white: { a: SquareSet.empty(), h: SquareSet.empty() },
|
|
34
|
+
black: { a: SquareSet.empty(), h: SquareSet.empty() },
|
|
35
|
+
};
|
|
36
|
+
this.rook = {
|
|
37
|
+
white: { a: undefined, h: undefined },
|
|
38
|
+
black: { a: undefined, h: undefined },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static default() {
|
|
42
|
+
const c = new Castles(new SquareSet(0x81, 0x81000000)); // a1, h1, a8, h8
|
|
43
|
+
c.rook = { white: { a: 0, h: 7 }, black: { a: 56, h: 63 } };
|
|
44
|
+
c.path = {
|
|
45
|
+
white: { a: between(4, 0), h: between(4, 7) }, // b1c1d1 / f1g1
|
|
46
|
+
black: { a: between(60, 56), h: between(60, 63) }, // b8c8d8 / f8g8
|
|
47
|
+
};
|
|
48
|
+
return c;
|
|
49
|
+
}
|
|
50
|
+
static empty() {
|
|
51
|
+
return new Castles(SquareSet.empty());
|
|
52
|
+
}
|
|
53
|
+
clone() {
|
|
54
|
+
const c = new Castles(this.castlingRights);
|
|
55
|
+
c.rook = {
|
|
56
|
+
white: { a: this.rook.white.a, h: this.rook.white.h },
|
|
57
|
+
black: { a: this.rook.black.a, h: this.rook.black.h },
|
|
58
|
+
};
|
|
59
|
+
c.path = {
|
|
60
|
+
white: { a: this.path.white.a, h: this.path.white.h },
|
|
61
|
+
black: { a: this.path.black.a, h: this.path.black.h },
|
|
62
|
+
};
|
|
63
|
+
return c;
|
|
64
|
+
}
|
|
65
|
+
static fromSetup(setup) {
|
|
66
|
+
const c = new Castles(setup.castlingRights);
|
|
67
|
+
for (const color of ["white", "black"]) {
|
|
68
|
+
const king = setup.board.kingOf(color);
|
|
69
|
+
for (const square of setup.castlingRights) {
|
|
70
|
+
const piece = setup.board.get(square);
|
|
71
|
+
if (!piece || piece.role !== "rook" || piece.color !== color)
|
|
72
|
+
continue;
|
|
73
|
+
const side = king !== undefined && (square & 7) > (king & 7) ? "h" : "a";
|
|
74
|
+
c.rook[color][side] = square;
|
|
75
|
+
c.path[color][side] = king === undefined ? SquareSet.empty() : between(king, square);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return c;
|
|
79
|
+
}
|
|
80
|
+
discardRook(square) {
|
|
81
|
+
this.castlingRights = this.castlingRights.without(square);
|
|
82
|
+
for (const color of ["white", "black"]) {
|
|
83
|
+
for (const side of ["a", "h"]) {
|
|
84
|
+
if (this.rook[color][side] === square)
|
|
85
|
+
this.rook[color][side] = undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
discardColor(color) {
|
|
90
|
+
for (const side of ["a", "h"]) {
|
|
91
|
+
const rook = this.rook[color][side];
|
|
92
|
+
if (rook !== undefined)
|
|
93
|
+
this.castlingRights = this.castlingRights.without(rook);
|
|
94
|
+
this.rook[color][side] = undefined;
|
|
95
|
+
this.path[color][side] = SquareSet.empty();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export class Position {
|
|
100
|
+
constructor(rules) {
|
|
101
|
+
this._epos = null;
|
|
102
|
+
this.rules = rules;
|
|
103
|
+
this.board = Board.empty();
|
|
104
|
+
this.pockets = undefined;
|
|
105
|
+
this.turn = "white";
|
|
106
|
+
this.castles = Castles.empty();
|
|
107
|
+
this.epSquare = undefined;
|
|
108
|
+
this.remainingChecks = undefined;
|
|
109
|
+
this.halfmoves = 0;
|
|
110
|
+
this.fullmoves = 1;
|
|
111
|
+
}
|
|
112
|
+
reset() {
|
|
113
|
+
const d = Chess.default();
|
|
114
|
+
this.board = d.board.clone();
|
|
115
|
+
this.turn = d.turn;
|
|
116
|
+
this.castles = d.castles.clone();
|
|
117
|
+
this.epSquare = d.epSquare;
|
|
118
|
+
this.halfmoves = d.halfmoves;
|
|
119
|
+
this.fullmoves = d.fullmoves;
|
|
120
|
+
this.invalidate();
|
|
121
|
+
}
|
|
122
|
+
setupUnchecked(setup) {
|
|
123
|
+
this.board = setup.board.clone();
|
|
124
|
+
this.turn = setup.turn;
|
|
125
|
+
this.castles = Castles.fromSetup(setup);
|
|
126
|
+
this.epSquare = setup.epSquare;
|
|
127
|
+
this.halfmoves = setup.halfmoves;
|
|
128
|
+
this.fullmoves = setup.fullmoves;
|
|
129
|
+
this.invalidate();
|
|
130
|
+
}
|
|
131
|
+
/** Lazily rebuilt engine position (rebuilt after every mutation). Built
|
|
132
|
+
* directly from the raw fields — NOT via toSetup(), whose legalEpSquare
|
|
133
|
+
* filter would recurse. The raw ep square is what baseline keeps on the
|
|
134
|
+
* position too; the legal-ep filter only applies to toSetup(). */
|
|
135
|
+
epos() {
|
|
136
|
+
if (this._epos === null) {
|
|
137
|
+
const sets = { white: new Set(), black: new Set() };
|
|
138
|
+
for (const s of this.castles.castlingRights) {
|
|
139
|
+
const p = this.board.get(s);
|
|
140
|
+
if (p && p.role === "rook")
|
|
141
|
+
(p.color === "white" ? sets.white : sets.black).add(s);
|
|
142
|
+
}
|
|
143
|
+
this._epos = setupToEngine(this.toSetupRaw());
|
|
144
|
+
}
|
|
145
|
+
return this._epos;
|
|
146
|
+
}
|
|
147
|
+
/** baseline keeps the RAW ep square on the position (toSetup() applies the
|
|
148
|
+
* legalEpSquare filter); this internal view mirrors that. */
|
|
149
|
+
toSetupRaw() {
|
|
150
|
+
return {
|
|
151
|
+
board: this.board,
|
|
152
|
+
pockets: undefined,
|
|
153
|
+
turn: this.turn,
|
|
154
|
+
castlingRights: this.castles.castlingRights,
|
|
155
|
+
epSquare: this.epSquare,
|
|
156
|
+
remainingChecks: undefined,
|
|
157
|
+
halfmoves: this.halfmoves,
|
|
158
|
+
fullmoves: this.fullmoves,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
invalidate() {
|
|
162
|
+
this._epos = null;
|
|
163
|
+
}
|
|
164
|
+
toSetup() {
|
|
165
|
+
return {
|
|
166
|
+
board: this.board.clone(),
|
|
167
|
+
pockets: undefined,
|
|
168
|
+
turn: this.turn,
|
|
169
|
+
castlingRights: this.castles.castlingRights,
|
|
170
|
+
epSquare: this.legalEpSquare(),
|
|
171
|
+
remainingChecks: undefined,
|
|
172
|
+
halfmoves: Math.min(this.halfmoves, 150),
|
|
173
|
+
fullmoves: Math.min(Math.max(this.fullmoves, 1), 9999),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** baseline legalEpSquare: the ep square survives into a Setup only when a
|
|
177
|
+
* legal ep capture exists. */
|
|
178
|
+
legalEpSquare() {
|
|
179
|
+
if (this.epSquare === undefined)
|
|
180
|
+
return undefined;
|
|
181
|
+
const epos = this.epos();
|
|
182
|
+
const them = this.turn === "white" ? "black" : "white";
|
|
183
|
+
const themColor = them === "white" ? 0 : 1;
|
|
184
|
+
const attackers = engineAttacks.pawnAttacks(themColor, this.epSquare);
|
|
185
|
+
const ourPawns = this.board.pieces(this.turn, "pawn");
|
|
186
|
+
const candidates = toFacadeSet({ lo: attackers.lo & ourPawns.lo, hi: attackers.hi & ourPawns.hi });
|
|
187
|
+
for (const from of candidates) {
|
|
188
|
+
const d = engine.dests(epos, from);
|
|
189
|
+
const has = this.epSquare < 32
|
|
190
|
+
? ((d.lo >>> this.epSquare) & 1) === 1
|
|
191
|
+
: ((d.hi >>> (this.epSquare - 32)) & 1) === 1;
|
|
192
|
+
if (has)
|
|
193
|
+
return this.epSquare;
|
|
194
|
+
}
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
kingAttackers(square, attacker, occupied) {
|
|
198
|
+
const r = engineAttacks.attackersTo(boardToEngine(this.board), square, attacker === "white" ? 0 : 1, { lo: occupied.lo >>> 0, hi: occupied.hi >>> 0 });
|
|
199
|
+
return toFacadeSet(r);
|
|
200
|
+
}
|
|
201
|
+
ctx() {
|
|
202
|
+
const us = this.turn;
|
|
203
|
+
const them = us === "white" ? "black" : "white";
|
|
204
|
+
const king = this.board.kingOf(us);
|
|
205
|
+
const occupied = this.board.occupied;
|
|
206
|
+
let checkers = SquareSet.empty();
|
|
207
|
+
let blockers = SquareSet.empty();
|
|
208
|
+
if (king !== undefined) {
|
|
209
|
+
checkers = this.kingAttackers(king, them, occupied);
|
|
210
|
+
// pinned own pieces: enemy sliders x-raying our king with exactly one
|
|
211
|
+
// blocker between (same definition as the engine's pin analysis)
|
|
212
|
+
const occWithoutKing = occupied.without(king);
|
|
213
|
+
const themRQ = this.board.rooksAndQueens().intersect(this.board[them]);
|
|
214
|
+
const themBQ = this.board.bishopsAndQueens().intersect(this.board[them]);
|
|
215
|
+
const snipers = toFacadeSet(engineAttacks.rookAttacks(king, occWithoutKing))
|
|
216
|
+
.intersect(themRQ)
|
|
217
|
+
.union(toFacadeSet(engineAttacks.bishopAttacks(king, occWithoutKing)).intersect(themBQ));
|
|
218
|
+
for (const sniper of snipers) {
|
|
219
|
+
const btwn = between(king, sniper).intersect(occupied);
|
|
220
|
+
if (btwn.size() === 1 && btwn.intersect(this.board[us]).nonEmpty()) {
|
|
221
|
+
blockers = blockers.union(btwn);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return { king, blockers, checkers, variantEnd: false, mustCapture: false };
|
|
226
|
+
}
|
|
227
|
+
clone() {
|
|
228
|
+
const c = Object.create(Object.getPrototypeOf(this));
|
|
229
|
+
this.copyInto(c);
|
|
230
|
+
return c;
|
|
231
|
+
}
|
|
232
|
+
copyInto(target) {
|
|
233
|
+
target.board = this.board.clone();
|
|
234
|
+
target.turn = this.turn;
|
|
235
|
+
target.castles = this.castles.clone();
|
|
236
|
+
target.epSquare = this.epSquare;
|
|
237
|
+
target.halfmoves = this.halfmoves;
|
|
238
|
+
target.fullmoves = this.fullmoves;
|
|
239
|
+
target.dropCache();
|
|
240
|
+
}
|
|
241
|
+
/** Internal: drop the cached engine position after any mutation. */
|
|
242
|
+
dropCache() {
|
|
243
|
+
this._epos = null;
|
|
244
|
+
}
|
|
245
|
+
/** Internal: engine position for sibling facade modules (san/fen/debug). */
|
|
246
|
+
eposInternal() {
|
|
247
|
+
return this.epos();
|
|
248
|
+
}
|
|
249
|
+
dropDests(_ctx) {
|
|
250
|
+
return SquareSet.empty();
|
|
251
|
+
}
|
|
252
|
+
dests(square, _ctx) {
|
|
253
|
+
return toFacadeSet(engine.dests(this.epos(), square));
|
|
254
|
+
}
|
|
255
|
+
isVariantEnd() {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
variantOutcome(_ctx) {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
hasInsufficientMaterial(color) {
|
|
262
|
+
const own = (r) => this.board.pieces(color, r);
|
|
263
|
+
if (own("pawn").nonEmpty() || own("rook").nonEmpty() || own("queen").nonEmpty())
|
|
264
|
+
return false;
|
|
265
|
+
const knights = own("knight");
|
|
266
|
+
const bishops = own("bishop");
|
|
267
|
+
if (knights.isEmpty() && bishops.isEmpty())
|
|
268
|
+
return true; // bare king
|
|
269
|
+
if (knights.size() + bishops.size() === 1)
|
|
270
|
+
return true; // single minor
|
|
271
|
+
if (bishops.isEmpty())
|
|
272
|
+
return false; // knights can mate with cooperation
|
|
273
|
+
// only bishops: insufficient unless they cover both square colors
|
|
274
|
+
let dark = false;
|
|
275
|
+
let light = false;
|
|
276
|
+
for (const s of bishops) {
|
|
277
|
+
if (((s >> 3) + (s & 7)) % 2 === 1)
|
|
278
|
+
dark = true;
|
|
279
|
+
else
|
|
280
|
+
light = true;
|
|
281
|
+
}
|
|
282
|
+
return !(dark && light);
|
|
283
|
+
}
|
|
284
|
+
isInsufficientMaterial() {
|
|
285
|
+
return engine.isInsufficientMaterial(this.epos());
|
|
286
|
+
}
|
|
287
|
+
hasDests(_ctx) {
|
|
288
|
+
const epos = this.epos();
|
|
289
|
+
for (const [s, piece] of this.board) {
|
|
290
|
+
if (piece.color !== this.turn)
|
|
291
|
+
continue;
|
|
292
|
+
const d = engine.dests(epos, s);
|
|
293
|
+
if (d.lo !== 0 || d.hi !== 0)
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
isLegal(move, _ctx) {
|
|
299
|
+
if (isDrop(move))
|
|
300
|
+
return false;
|
|
301
|
+
const piece = this.board.get(move.from);
|
|
302
|
+
if (!piece || piece.color !== this.turn)
|
|
303
|
+
return false;
|
|
304
|
+
if (!this.dests(move.from).has(move.to))
|
|
305
|
+
return false;
|
|
306
|
+
if (piece.role === "pawn" && (move.to >= 56 || move.to < 8) && !move.promotion)
|
|
307
|
+
return false;
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
isCheck() {
|
|
311
|
+
return engine.isCheck(this.epos());
|
|
312
|
+
}
|
|
313
|
+
isEnd(_ctx) {
|
|
314
|
+
return this.isVariantEnd() || this.isCheckmate() || this.isStalemate();
|
|
315
|
+
}
|
|
316
|
+
isCheckmate(_ctx) {
|
|
317
|
+
return engine.isCheckmate(this.epos());
|
|
318
|
+
}
|
|
319
|
+
isStalemate(_ctx) {
|
|
320
|
+
return engine.isStalemate(this.epos());
|
|
321
|
+
}
|
|
322
|
+
outcome(_ctx) {
|
|
323
|
+
if (this.isVariantEnd())
|
|
324
|
+
return this.variantOutcome();
|
|
325
|
+
if (this.isCheckmate())
|
|
326
|
+
return { winner: this.turn === "white" ? "black" : "white" };
|
|
327
|
+
if (this.isStalemate() || this.isInsufficientMaterial())
|
|
328
|
+
return { winner: undefined };
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
allDests(_ctx) {
|
|
332
|
+
// baseline-exact: one entry per OWN piece, including empty dests for
|
|
333
|
+
// pieces with no legal moves (e.g. the black backrank after 1.d4).
|
|
334
|
+
const epos = this.epos();
|
|
335
|
+
const out = new Map();
|
|
336
|
+
for (const [s, piece] of this.board) {
|
|
337
|
+
if (piece.color !== this.turn)
|
|
338
|
+
continue;
|
|
339
|
+
out.set(s, toFacadeSet(engine.dests(epos, s)));
|
|
340
|
+
}
|
|
341
|
+
return out;
|
|
342
|
+
}
|
|
343
|
+
play(move) {
|
|
344
|
+
if (isDrop(move))
|
|
345
|
+
throw new Error("Drops are not supported in standard chess");
|
|
346
|
+
const epos = this.epos();
|
|
347
|
+
const emove = moveFromFacade(epos, move);
|
|
348
|
+
const next = engine.makeMove(epos, emove);
|
|
349
|
+
this.board._b = next.board;
|
|
350
|
+
this.turn = next.turn === 0 ? "white" : "black";
|
|
351
|
+
this.castles = this.castlesFromSets(next.castling);
|
|
352
|
+
this.epSquare = next.epSquare === null ? undefined : next.epSquare;
|
|
353
|
+
this.halfmoves = next.halfmoves ?? 0;
|
|
354
|
+
this.fullmoves = next.fullmoves ?? 1;
|
|
355
|
+
this.invalidate();
|
|
356
|
+
}
|
|
357
|
+
castlesFromSets(castling) {
|
|
358
|
+
const rights = new SquareSet([...castling.white].reduce((a, s) => a | (1 << s), 0) >>> 0, [...castling.black].reduce((a, s) => a | (1 << (s - 32)), 0) >>> 0);
|
|
359
|
+
return Castles.fromSetup({
|
|
360
|
+
board: this.board,
|
|
361
|
+
pockets: undefined,
|
|
362
|
+
turn: this.turn,
|
|
363
|
+
castlingRights: rights,
|
|
364
|
+
epSquare: undefined,
|
|
365
|
+
remainingChecks: undefined,
|
|
366
|
+
halfmoves: 0,
|
|
367
|
+
fullmoves: 1,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
export class Chess extends Position {
|
|
372
|
+
constructor() {
|
|
373
|
+
super("chess");
|
|
374
|
+
}
|
|
375
|
+
static default() {
|
|
376
|
+
const parsed = parseFenInternal(INITIAL_FEN);
|
|
377
|
+
if (parsed.isErr)
|
|
378
|
+
throw new PositionError(parsed.error.message);
|
|
379
|
+
return Chess.fromSetupUnchecked(parsed.unwrap());
|
|
380
|
+
}
|
|
381
|
+
static fromSetup(setup) {
|
|
382
|
+
const pos = new Chess();
|
|
383
|
+
pos.setupUnchecked(setup);
|
|
384
|
+
// validate via the engine's FEN round-trip (single source of truth for
|
|
385
|
+
// the position legality rules: kings, pawns on backrank, opposite check)
|
|
386
|
+
const r = parseFenInternal(makeFenInternal(pos.toSetup()));
|
|
387
|
+
if (r.isErr)
|
|
388
|
+
return Result.err(new PositionError(r.error.message));
|
|
389
|
+
return Result.ok(pos);
|
|
390
|
+
}
|
|
391
|
+
static fromSetupUnchecked(setup) {
|
|
392
|
+
const pos = new Chess();
|
|
393
|
+
pos.setupUnchecked(setup);
|
|
394
|
+
return pos;
|
|
395
|
+
}
|
|
396
|
+
clone() {
|
|
397
|
+
const c = Object.create(Object.getPrototypeOf(this));
|
|
398
|
+
this.copyInto(c);
|
|
399
|
+
return c;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
export const pseudoDests = (pos, square, _ctx) => pos.dests(square);
|
|
403
|
+
export const equalsIgnoreMoves = (left, right) => boardEquals(left.board, right.board) &&
|
|
404
|
+
left.turn === right.turn &&
|
|
405
|
+
left.castles.castlingRights.equals(right.castles.castlingRights) &&
|
|
406
|
+
left.epSquare === right.epSquare;
|
|
407
|
+
export const castlingSide = (pos, move) => {
|
|
408
|
+
if (isDrop(move))
|
|
409
|
+
return undefined;
|
|
410
|
+
const piece = pos.board.get(move.from);
|
|
411
|
+
if (!piece || piece.role !== "king")
|
|
412
|
+
return undefined;
|
|
413
|
+
const df = (move.to & 7) - (move.from & 7);
|
|
414
|
+
if (Math.abs(df) < 2)
|
|
415
|
+
return undefined;
|
|
416
|
+
return df > 0 ? "h" : "a";
|
|
417
|
+
};
|
|
418
|
+
export const normalizeMove = (pos, move) => {
|
|
419
|
+
if (isDrop(move))
|
|
420
|
+
return move;
|
|
421
|
+
const side = castlingSide(pos, move);
|
|
422
|
+
if (side) {
|
|
423
|
+
const rook = pos.castles.rook[pos.turn][side];
|
|
424
|
+
if (rook !== undefined)
|
|
425
|
+
return { from: move.from, to: rook, promotion: move.promotion };
|
|
426
|
+
}
|
|
427
|
+
return move;
|
|
428
|
+
};
|
|
429
|
+
export const isStandardMaterialSide = (board, color) => board.pieces(color, "pawn").isEmpty() &&
|
|
430
|
+
board.pieces(color, "knight").isEmpty() &&
|
|
431
|
+
board.pieces(color, "bishop").isEmpty() &&
|
|
432
|
+
board.pieces(color, "rook").size() === 2 &&
|
|
433
|
+
board.pieces(color, "queen").size() === 1 &&
|
|
434
|
+
board.kingOf(color) !== undefined;
|
|
435
|
+
export const isStandardMaterial = (pos) => isStandardMaterialSide(pos.board, "white") && isStandardMaterialSide(pos.board, "black");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Position } from "./chess.js";
|
|
2
|
+
/** Algebraic square key, e.g. "e2" (board-renderer Key). */
|
|
3
|
+
export type Key = string;
|
|
4
|
+
/** Board-renderer `Dests`: from-key -> list of to-keys. */
|
|
5
|
+
export type Dests = Map<Key, Key[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Converts `pos.allDests()` (one entry per own piece, including empty dest
|
|
8
|
+
* sets) into `Dests`. Byte-identical mapping: from-keys in allDests iteration
|
|
9
|
+
* order, to-keys in SquareSet ascending-bit order.
|
|
10
|
+
*/
|
|
11
|
+
export declare function chessToDests(pos: Position): Dests;
|
|
12
|
+
/** Number of legal destination squares across all own pieces. */
|
|
13
|
+
export declare function destsSize(pos: Position): number;
|
|
14
|
+
/** Convenience bundle — `import { compat }` from the package's baseline entry. */
|
|
15
|
+
export declare const compat: {
|
|
16
|
+
chessToDests: typeof chessToDests;
|
|
17
|
+
destsSize: typeof destsSize;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/chessops/compat.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,4DAA4D;AAC5D,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,2DAA2D;AAC3D,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAEpC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,KAAK,CAQjD;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAI/C;AAED,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;CAA8B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { makeSquare } from "./util.js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts `pos.allDests()` (one entry per own piece, including empty dest
|
|
4
|
+
* sets) into `Dests`. Byte-identical mapping: from-keys in allDests iteration
|
|
5
|
+
* order, to-keys in SquareSet ascending-bit order.
|
|
6
|
+
*/
|
|
7
|
+
export function chessToDests(pos) {
|
|
8
|
+
const out = new Map();
|
|
9
|
+
for (const [from, set] of pos.allDests()) {
|
|
10
|
+
const tos = [];
|
|
11
|
+
for (const to of set)
|
|
12
|
+
tos.push(makeSquare(to));
|
|
13
|
+
out.set(makeSquare(from), tos);
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
/** Number of legal destination squares across all own pieces. */
|
|
18
|
+
export function destsSize(pos) {
|
|
19
|
+
let n = 0;
|
|
20
|
+
for (const set of pos.allDests().values())
|
|
21
|
+
n += set.size();
|
|
22
|
+
return n;
|
|
23
|
+
}
|
|
24
|
+
/** Convenience bundle — `import { compat }` from the package's baseline entry. */
|
|
25
|
+
export const compat = { chessToDests, destsSize };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Board as EngineBoard } from "../board.js";
|
|
2
|
+
import type { Move as EngineMove, Position as EnginePosition } from "../types.js";
|
|
3
|
+
import { Role as ERole, Color as EColor } from "../types.js";
|
|
4
|
+
import type { CastlingRights as EngineCastlingRights } from "../types.js";
|
|
5
|
+
import { Color as FColor, Role as FRole } from "./types.js";
|
|
6
|
+
import type { Move as FacadeMove, NormalMove as FacadeNormalMove, Piece } from "./types.js";
|
|
7
|
+
import { Board } from "./board.js";
|
|
8
|
+
import type { Setup } from "./setup.js";
|
|
9
|
+
import { SquareSet } from "./squareSet.js";
|
|
10
|
+
export declare const toEngineColor: (c: FColor) => EColor;
|
|
11
|
+
export declare const fromEngineColor: (c: EColor) => FColor;
|
|
12
|
+
export declare const toEngineRole: (r: FRole) => ERole;
|
|
13
|
+
export declare const fromEngineRole: (r: ERole) => FRole;
|
|
14
|
+
export declare const pieceFromEngine: (p: {
|
|
15
|
+
color: EColor;
|
|
16
|
+
role: ERole;
|
|
17
|
+
}) => Piece;
|
|
18
|
+
/** Facade Board -> engine board, normalized to unsigned bit patterns. */
|
|
19
|
+
export declare const boardToEngine: (b: Board) => EngineBoard;
|
|
20
|
+
export declare const boardFromEngine: (b: EngineBoard) => Board;
|
|
21
|
+
/** castlingRights SquareSet + board -> engine per-color rook-origin sets. */
|
|
22
|
+
export declare function castlingSetsFromRights(rights: SquareSet, board: Board): {
|
|
23
|
+
white: Set<number>;
|
|
24
|
+
black: Set<number>;
|
|
25
|
+
};
|
|
26
|
+
export declare function engineCastling(sets: {
|
|
27
|
+
white: Set<number>;
|
|
28
|
+
black: Set<number>;
|
|
29
|
+
}): EngineCastlingRights;
|
|
30
|
+
/** baseline Setup -> engine Position. */
|
|
31
|
+
export declare function setupToEngine(setup: Setup): EnginePosition;
|
|
32
|
+
/** engine Position -> baseline Setup. */
|
|
33
|
+
export declare function setupFromEngine(pos: EnginePosition): Setup;
|
|
34
|
+
/**
|
|
35
|
+
* Facade move -> engine move, deriving the engine's special-move flags from
|
|
36
|
+
* the position (ep: pawn capturing diagonally onto the ep square; castling
|
|
37
|
+
* and legality are detected inside the engine's shared detectCastling path).
|
|
38
|
+
* Callers' move objects are never mutated.
|
|
39
|
+
*/
|
|
40
|
+
export declare function moveFromFacade(pos: EnginePosition, move: FacadeMove): EngineMove;
|
|
41
|
+
export declare function moveToFacade(m: EngineMove): FacadeNormalMove;
|
|
42
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/chessops/convert.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,UAAU,IAAI,gBAAgB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,KAAG,MAAuD,CAAC;AAClG,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM,KAAG,MAAkD,CAAC;AAC/F,eAAO,MAAM,YAAY,GAAI,GAAG,KAAK,KAAG,KAA6C,CAAC;AACtF,eAAO,MAAM,cAAc,GAAI,GAAG,KAAK,KAAG,KAAiB,CAAC;AAE5D,eAAO,MAAM,eAAe,GAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,KAAG,KAGlE,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,aAAa,GAAI,GAAG,KAAK,KAAG,WAOxC,CAAC;AACF,eAAO,MAAM,eAAe,GAAI,GAAG,WAAW,KAAG,KAIhD,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAUlH;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG,oBAAoB,CASrG;AAED,yCAAyC;AACzC,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAU1D;AAED,yCAAyC;AACzC,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,KAAK,CAiB1D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAoBhF;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,gBAAgB,CAI5D"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/baseline/convert.ts — internal engine <-> facade converters (ADR-014).
|
|
2
|
+
// Not part of the public API. The facade never mutates caller-provided values;
|
|
3
|
+
// conversions produce fresh engine positions (the engine itself is immutable).
|
|
4
|
+
import * as engineBoardMod from "../board.js";
|
|
5
|
+
import { Role as ERole, Color as EColor } from "../types.js";
|
|
6
|
+
import { Board } from "./board.js";
|
|
7
|
+
import { SquareSet } from "./squareSet.js";
|
|
8
|
+
const COLORS = ["white", "black"];
|
|
9
|
+
const ROLES = ["pawn", "knight", "bishop", "rook", "queen", "king"];
|
|
10
|
+
export const toEngineColor = (c) => (c === "white" ? EColor.White : EColor.Black);
|
|
11
|
+
export const fromEngineColor = (c) => (c === EColor.White ? "white" : "black");
|
|
12
|
+
export const toEngineRole = (r) => ROLES.indexOf(r);
|
|
13
|
+
export const fromEngineRole = (r) => ROLES[r];
|
|
14
|
+
export const pieceFromEngine = (p) => ({
|
|
15
|
+
color: fromEngineColor(p.color),
|
|
16
|
+
role: fromEngineRole(p.role),
|
|
17
|
+
});
|
|
18
|
+
/** Facade Board -> engine board, normalized to unsigned bit patterns. */
|
|
19
|
+
export const boardToEngine = (b) => {
|
|
20
|
+
const src = b._b;
|
|
21
|
+
const out = {};
|
|
22
|
+
for (const k of Object.keys(src)) {
|
|
23
|
+
out[k] = { lo: src[k].lo >>> 0, hi: src[k].hi >>> 0 };
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
};
|
|
27
|
+
export const boardFromEngine = (b) => {
|
|
28
|
+
const facade = Board.empty();
|
|
29
|
+
facade._b = b; // engine boards are already unsigned-normalized
|
|
30
|
+
return facade;
|
|
31
|
+
};
|
|
32
|
+
/** castlingRights SquareSet + board -> engine per-color rook-origin sets. */
|
|
33
|
+
export function castlingSetsFromRights(rights, board) {
|
|
34
|
+
const white = new Set();
|
|
35
|
+
const black = new Set();
|
|
36
|
+
for (const square of rights) {
|
|
37
|
+
const piece = board.get(square);
|
|
38
|
+
if (piece && piece.role === "rook") {
|
|
39
|
+
(piece.color === "white" ? white : black).add(square);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { white, black };
|
|
43
|
+
}
|
|
44
|
+
export function engineCastling(sets) {
|
|
45
|
+
return {
|
|
46
|
+
white: sets.white,
|
|
47
|
+
black: sets.black,
|
|
48
|
+
whiteKing: sets.white.has(7),
|
|
49
|
+
whiteQueen: sets.white.has(0),
|
|
50
|
+
blackKing: sets.black.has(63),
|
|
51
|
+
blackQueen: sets.black.has(56),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** baseline Setup -> engine Position. */
|
|
55
|
+
export function setupToEngine(setup) {
|
|
56
|
+
const sets = castlingSetsFromRights(setup.castlingRights, setup.board);
|
|
57
|
+
return {
|
|
58
|
+
board: boardToEngine(setup.board),
|
|
59
|
+
turn: toEngineColor(setup.turn),
|
|
60
|
+
castling: engineCastling(sets),
|
|
61
|
+
epSquare: setup.epSquare === undefined ? null : setup.epSquare,
|
|
62
|
+
halfmoves: setup.halfmoves,
|
|
63
|
+
fullmoves: setup.fullmoves,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** engine Position -> baseline Setup. */
|
|
67
|
+
export function setupFromEngine(pos) {
|
|
68
|
+
const board = boardFromEngine(pos.board);
|
|
69
|
+
// baseline stores set bits as signed int32 — mirror that on the facade side
|
|
70
|
+
const rights = new SquareSet([...pos.castling.white].reduce((a, s) => a | (1 << s), 0) | 0, [...pos.castling.black].reduce((a, s) => a | (1 << (s - 32)), 0) | 0);
|
|
71
|
+
return {
|
|
72
|
+
board,
|
|
73
|
+
pockets: undefined,
|
|
74
|
+
turn: fromEngineColor(pos.turn),
|
|
75
|
+
castlingRights: rights,
|
|
76
|
+
epSquare: pos.epSquare === null ? undefined : pos.epSquare,
|
|
77
|
+
remainingChecks: undefined,
|
|
78
|
+
halfmoves: pos.halfmoves ?? 0,
|
|
79
|
+
fullmoves: pos.fullmoves ?? 1,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Facade move -> engine move, deriving the engine's special-move flags from
|
|
84
|
+
* the position (ep: pawn capturing diagonally onto the ep square; castling
|
|
85
|
+
* and legality are detected inside the engine's shared detectCastling path).
|
|
86
|
+
* Callers' move objects are never mutated.
|
|
87
|
+
*/
|
|
88
|
+
export function moveFromFacade(pos, move) {
|
|
89
|
+
if (!("from" in move))
|
|
90
|
+
throw new Error("DropMove is not supported in standard chess");
|
|
91
|
+
const from = move.from;
|
|
92
|
+
const to = move.to;
|
|
93
|
+
const piece = engineBoardMod.pieceAt(pos.board, from);
|
|
94
|
+
const isEnPassant = !!piece &&
|
|
95
|
+
piece.role === ERole.Pawn &&
|
|
96
|
+
pos.epSquare !== null &&
|
|
97
|
+
to === pos.epSquare &&
|
|
98
|
+
(from & 7) !== (to & 7);
|
|
99
|
+
const promotion = move.promotion === undefined ? null : toEngineRole(move.promotion);
|
|
100
|
+
return {
|
|
101
|
+
from,
|
|
102
|
+
to,
|
|
103
|
+
promotion,
|
|
104
|
+
isPromotion: move.promotion !== undefined,
|
|
105
|
+
isEnPassant,
|
|
106
|
+
isCastling: false,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export function moveToFacade(m) {
|
|
110
|
+
const out = { from: m.from, to: m.to };
|
|
111
|
+
if (m.promotion !== null && m.promotion !== undefined)
|
|
112
|
+
out.promotion = fromEngineRole(m.promotion);
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Position } from "./chess.js";
|
|
2
|
+
import type { Board } from "./board.js";
|
|
3
|
+
import type { SquareSet } from "./squareSet.js";
|
|
4
|
+
import type { Piece, Square } from "./types.js";
|
|
5
|
+
export declare const squareSet: (squares: SquareSet) => string;
|
|
6
|
+
export declare const piece: (p: Piece) => string;
|
|
7
|
+
export declare const board: (b: Board) => string;
|
|
8
|
+
export declare const square: (sq: Square) => string;
|
|
9
|
+
/**
|
|
10
|
+
* ASCII position dump (pure oracle): eight whitespace-separated piece rows,
|
|
11
|
+
* rank 8 first — byte-identical (modulo whitespace) to the baseline debug
|
|
12
|
+
* board dump on the same position.
|
|
13
|
+
*/
|
|
14
|
+
export declare const debugBoard: (pos: Position) => string;
|
|
15
|
+
export declare const dests: (d: Map<Square, SquareSet>) => string;
|
|
16
|
+
export declare const perft: (pos: Position, depth: number, log?: boolean) => number;
|
|
17
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/chessops/debug.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAQ,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGtD,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,KAAG,MAAiD,CAAC;AAEjG,eAAO,MAAM,KAAK,GAAI,GAAG,KAAK,KAAG,MAAgC,CAAC;AAElE,eAAO,MAAM,KAAK,GAAI,GAAG,KAAK,KAAG,MAWhC,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,KAAG,MAAwB,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,QAAQ,KAAG,MAW1C,CAAC;AAGF,eAAO,MAAM,KAAK,GAAI,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,KAAG,MAC8D,CAAC;AAEjH,eAAO,MAAM,KAAK,GAAI,KAAK,QAAQ,EAAE,OAAO,MAAM,EAAE,aAAW,KAAG,MA+BjE,CAAC"}
|