gigachess 0.3.0 → 0.4.0
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/README.md +102 -125
- package/dist/attacks.d.ts +3 -3
- package/dist/attacks.d.ts.map +1 -1
- package/dist/attacks.js +1 -1
- package/dist/board.d.ts +99 -44
- package/dist/board.d.ts.map +1 -1
- package/dist/board.js +726 -15
- package/dist/castling.d.ts +11 -1
- package/dist/castling.d.ts.map +1 -1
- package/dist/castling.js +122 -0
- package/dist/chess.d.ts +11 -23
- package/dist/chess.d.ts.map +1 -1
- package/dist/chess.js +81 -178
- package/dist/chess960.d.ts +1 -1
- package/dist/chess960.d.ts.map +1 -1
- package/dist/chess960.js +2 -2
- package/dist/chessjs.d.ts +13 -0
- package/dist/chessjs.d.ts.map +1 -0
- package/dist/chessjs.js +23 -0
- package/dist/chessops/board.d.ts +1 -1
- package/dist/chessops/board.d.ts.map +1 -1
- package/dist/chessops/chess.js +1 -1
- package/dist/chessops/convert.d.ts +1 -1
- package/dist/chessops/convert.d.ts.map +1 -1
- package/dist/chessops/fenInternal.d.ts +1 -1
- package/dist/chessops/fenInternal.d.ts.map +1 -1
- package/dist/chessops/fenInternal.js +2 -2
- package/dist/chessops/index.js +2 -2
- package/dist/chessops/setup.js +1 -1
- package/dist/chessops/types.js +1 -1
- package/dist/chesstree.d.ts +1 -1
- package/dist/chesstree.d.ts.map +1 -1
- package/dist/chesstree.js +5 -5
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2 -2
- package/dist/fen.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -6
- package/dist/packedMove.js +1 -1
- package/dist/squareSet.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/zobrist.d.ts +22 -0
- package/dist/zobrist.d.ts.map +1 -1
- package/dist/zobrist.js +89 -33
- package/dist/zobristBlob.js +1 -1
- package/package.json +5 -5
package/dist/chess.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/chess.ts — core chess rules, Position/Setup, dests, isLegal, isCheck, perft etc
|
|
2
|
-
// MIT
|
|
2
|
+
// MIT gigachess, clean-room from specs + FIDE notes (no G P L)
|
|
3
3
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
4
4
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
5
5
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -11,13 +11,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
12
12
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
13
13
|
};
|
|
14
|
-
var _Chess_instances, _Chess_startFen, _Chess_history,
|
|
14
|
+
var _Chess_instances, _Chess_board, _Chess_startFen, _Chess_history, _Chess_movetext, _Chess_positions, _Chess_describe, _Chess_fenOf;
|
|
15
15
|
import * as sq from "./squareSet.js";
|
|
16
16
|
import * as board from "./board.js";
|
|
17
|
+
import { Board } from "./board.js";
|
|
17
18
|
import * as attacks from "./attacks.js";
|
|
18
19
|
import { Color, Role } from "./types.js";
|
|
19
20
|
import { opposite, squareFile, squareRank, parseSquare, squareName } from "./util.js";
|
|
20
|
-
import { zobristTablesLoaded, zobristAfterMove
|
|
21
|
+
import { zobristTablesLoaded, zobristAfterMove } from "./zobrist.js";
|
|
21
22
|
import { parseFen, makeFen } from "./fen.js";
|
|
22
23
|
import { parseSan, makeSan, parseUci, makeUci } from "./san.js";
|
|
23
24
|
import { packOf, packedToMoves, PROMO_NONE, PROMO_KNIGHT, PROMO_BISHOP, PROMO_ROOK, PROMO_QUEEN, } from "./packedMove.js";
|
|
@@ -133,125 +134,22 @@ function positionsEqualForRepetition(a, b) {
|
|
|
133
134
|
return false;
|
|
134
135
|
return true;
|
|
135
136
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (p.rookFrom === to || p.kingTo === to)
|
|
153
|
-
return p;
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Single source of truth for castling detection, shared by makeMove, isLegal,
|
|
159
|
-
* makeSan, destsFast and genLegalMoves (design D2). Accepts both input
|
|
160
|
-
* representations:
|
|
161
|
-
* - king→own-rook square (baseline / 960 input, e1h1), and
|
|
162
|
-
* - king→normalized landing square (e1g1; a two-file king step),
|
|
163
|
-
* provided the corresponding castling right exists and the rook is actually
|
|
164
|
-
* on its origin square. Returns null for every non-castling move — in
|
|
165
|
-
* particular for an ordinary one-square king step to g1/c1/g8/c8, which the
|
|
166
|
-
* previous per-call-site heuristics misclassified when ANY color (even the
|
|
167
|
-
* opponent) held castling rights (root cause of the perft parity defect).
|
|
168
|
-
*/
|
|
169
|
-
export function detectCastling(pos, from, to) {
|
|
170
|
-
if (!pos.isChess960) {
|
|
171
|
-
const mask = pos.castlingMask ?? getCastlingMask(pos);
|
|
172
|
-
if (mask === 0)
|
|
173
|
-
return null;
|
|
174
|
-
if (pos.turn === Color.White) {
|
|
175
|
-
if ((mask & (CASTLE_WK | CASTLE_WQ)) === 0 || from !== 4)
|
|
176
|
-
return null;
|
|
177
|
-
if (to === 7 || to === 6) {
|
|
178
|
-
if ((mask & CASTLE_WK) === 0)
|
|
179
|
-
return null;
|
|
180
|
-
if (to === 6 && board.pieceAt(pos.board, 6))
|
|
181
|
-
return null;
|
|
182
|
-
const rp = board.pieceAt(pos.board, 7);
|
|
183
|
-
if (rp && rp.color === Color.White && rp.role === Role.Rook)
|
|
184
|
-
return PLAN_WHITE_K;
|
|
185
|
-
}
|
|
186
|
-
else if (to === 0 || to === 2) {
|
|
187
|
-
if ((mask & CASTLE_WQ) === 0)
|
|
188
|
-
return null;
|
|
189
|
-
if (to === 2 && board.pieceAt(pos.board, 2))
|
|
190
|
-
return null;
|
|
191
|
-
const rp = board.pieceAt(pos.board, 0);
|
|
192
|
-
if (rp && rp.color === Color.White && rp.role === Role.Rook)
|
|
193
|
-
return PLAN_WHITE_Q;
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
if ((mask & (CASTLE_BK | CASTLE_BQ)) === 0 || from !== 60)
|
|
199
|
-
return null;
|
|
200
|
-
if (to === 63 || to === 62) {
|
|
201
|
-
if ((mask & CASTLE_BK) === 0)
|
|
202
|
-
return null;
|
|
203
|
-
if (to === 62 && board.pieceAt(pos.board, 62))
|
|
204
|
-
return null;
|
|
205
|
-
const rp = board.pieceAt(pos.board, 63);
|
|
206
|
-
if (rp && rp.color === Color.Black && rp.role === Role.Rook)
|
|
207
|
-
return PLAN_BLACK_K;
|
|
208
|
-
}
|
|
209
|
-
else if (to === 56 || to === 58) {
|
|
210
|
-
if ((mask & CASTLE_BQ) === 0)
|
|
211
|
-
return null;
|
|
212
|
-
if (to === 58 && board.pieceAt(pos.board, 58))
|
|
213
|
-
return null;
|
|
214
|
-
const rp = board.pieceAt(pos.board, 56);
|
|
215
|
-
if (rp && rp.color === Color.Black && rp.role === Role.Rook)
|
|
216
|
-
return PLAN_BLACK_Q;
|
|
217
|
-
}
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
// Chess960 fallback
|
|
222
|
-
if (pos.castling.white.size === 0 && pos.castling.black.size === 0)
|
|
223
|
-
return null;
|
|
224
|
-
const piece = board.pieceAt(pos.board, from);
|
|
225
|
-
if (!piece || piece.role !== Role.King || piece.color !== pos.turn)
|
|
226
|
-
return null;
|
|
227
|
-
const rights = piece.color === Color.White ? pos.castling.white : pos.castling.black;
|
|
228
|
-
if (rights.size === 0)
|
|
229
|
-
return null;
|
|
230
|
-
const rank = squareRank(from);
|
|
231
|
-
// Input form 1: king captures own rook on its origin square (baseline/960).
|
|
232
|
-
if (rights.has(to) && squareRank(to) === rank) {
|
|
233
|
-
const target = board.pieceAt(pos.board, to);
|
|
234
|
-
if (target && target.color === piece.color && target.role === Role.Rook) {
|
|
235
|
-
return castlingPlanFor(piece.color, from, to);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
// Input form 2: normalized landing square — a two-file step on the same rank.
|
|
239
|
-
if (squareRank(to) === rank && Math.abs(squareFile(to) - squareFile(from)) === 2) {
|
|
240
|
-
// The landing square must be empty for castling.
|
|
241
|
-
if (!board.pieceAt(pos.board, to)) {
|
|
242
|
-
for (const rs of rights) {
|
|
243
|
-
const plan = castlingPlanFor(piece.color, from, rs);
|
|
244
|
-
if (plan.kingTo !== to)
|
|
245
|
-
continue;
|
|
246
|
-
// The right's rook must actually be present on its origin square.
|
|
247
|
-
const rp = board.pieceAt(pos.board, rs);
|
|
248
|
-
if (rp && rp.color === piece.color && rp.role === Role.Rook)
|
|
249
|
-
return plan;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
137
|
+
// ---------- castling: one detect/apply path (ADR-013 as amended) ----------
|
|
138
|
+
// ADR-013 bake-off result (change purechess-gates-green, task 1.1): the
|
|
139
|
+
// baseline-style king-captures-rook representation (e1h1) is the single
|
|
140
|
+
// canonical OUTPUT encoding used by dests/allDests/genLegalMoves (and hence
|
|
141
|
+
// makeUci). It measured equal-or-faster than the normalized-landing encoding
|
|
142
|
+
// (perft d3 11.26 vs 11.42 ms median; makeMove walk 425 vs 430 ms; allDests
|
|
143
|
+
// 6.27 vs 6.39 ms — see bench/castling-bakeoff.mjs) and deletes the
|
|
144
|
+
// canonicalization layer: standard-chess and Chess960 handling converge and
|
|
145
|
+
// dests are byte-identical to baseline. Both INPUT forms are still accepted
|
|
146
|
+
// by detectCastling (king→rook square e1h1, and king→landing e1g1 as a
|
|
147
|
+
// two-file step) so `parseUci("e1g1")` in standard chess and 960 `e1h1`
|
|
148
|
+
// input keep working (UCI protocol boundary documented in ADR-013: engines
|
|
149
|
+
// are sent e1g1 for standard castling; conversion belongs to the engine
|
|
150
|
+
// boundary, not to makeUci).
|
|
151
|
+
import { detectCastling, castlingPlanFor, planForDest, } from "./castling.js";
|
|
152
|
+
export { detectCastling, castlingPlanFor, planForDest, };
|
|
255
153
|
// ---------- move execution (play) ----------
|
|
256
154
|
/**
|
|
257
155
|
* Shared board-edit sequence used by BOTH the pure `makeMove` and the
|
|
@@ -1448,6 +1346,7 @@ const PROMO_ORDER = [4, 3, 2, 1]; // Role.Queen, Role.Rook, Role.Bishop, Role.Kn
|
|
|
1448
1346
|
function colorName(turn) {
|
|
1449
1347
|
return turn === Color.White ? "w" : "b";
|
|
1450
1348
|
}
|
|
1349
|
+
export { Board };
|
|
1451
1350
|
/** Expands pawn back-rank destinations into the four promotions. */
|
|
1452
1351
|
function buildMoves(pos, role, from, to) {
|
|
1453
1352
|
const toRank = to >> 3;
|
|
@@ -1494,31 +1393,23 @@ function hasLegalEpCapture(pos) {
|
|
|
1494
1393
|
* over the immutable engine core, extended with the high-performance
|
|
1495
1394
|
* bitboard surface, zero-alloc Zobrist hashing and 16-bit packed moves2, and
|
|
1496
1395
|
* native tree navigation. Lives at the ROOT entrypoint so the tree-shakeable
|
|
1497
|
-
* `
|
|
1396
|
+
* `gigachess/core` graph stays free of FEN/PGN/tree facade code.
|
|
1498
1397
|
*/
|
|
1499
1398
|
export class Chess {
|
|
1500
1399
|
constructor(fen = INITIAL_FEN) {
|
|
1501
1400
|
_Chess_instances.add(this);
|
|
1401
|
+
_Chess_board.set(this, void 0);
|
|
1502
1402
|
_Chess_startFen.set(this, void 0);
|
|
1503
1403
|
_Chess_history.set(this, []);
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
const r = parseFen(fen);
|
|
1507
|
-
if (!r.ok)
|
|
1508
|
-
throw new Error(`Invalid FEN: ${fen}`);
|
|
1509
|
-
__classPrivateFieldSet(this, _Chess_pos, r.value, "f");
|
|
1510
|
-
}
|
|
1511
|
-
else {
|
|
1512
|
-
__classPrivateFieldSet(this, _Chess_pos, fen, "f");
|
|
1513
|
-
}
|
|
1514
|
-
__classPrivateFieldSet(this, _Chess_startFen, __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, __classPrivateFieldGet(this, _Chess_pos, "f")), "f");
|
|
1404
|
+
__classPrivateFieldSet(this, _Chess_board, new Board(fen), "f");
|
|
1405
|
+
__classPrivateFieldSet(this, _Chess_startFen, __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, __classPrivateFieldGet(this, _Chess_board, "f").pos), "f");
|
|
1515
1406
|
}
|
|
1516
1407
|
/** Replaces the current position (throws on an invalid FEN). */
|
|
1517
1408
|
load(fen) {
|
|
1518
1409
|
const r = parseFen(fen);
|
|
1519
1410
|
if (!r.ok)
|
|
1520
1411
|
throw new Error(`Invalid FEN: ${fen}`);
|
|
1521
|
-
__classPrivateFieldSet(this,
|
|
1412
|
+
__classPrivateFieldSet(this, _Chess_board, new Board(r.value), "f");
|
|
1522
1413
|
__classPrivateFieldSet(this, _Chess_startFen, __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, r.value), "f");
|
|
1523
1414
|
__classPrivateFieldSet(this, _Chess_history, [], "f");
|
|
1524
1415
|
}
|
|
@@ -1528,15 +1419,15 @@ export class Chess {
|
|
|
1528
1419
|
}
|
|
1529
1420
|
/** Current FEN (byte-identical to the engine's makeFen modulo ep filtering). */
|
|
1530
1421
|
fen() {
|
|
1531
|
-
return __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, __classPrivateFieldGet(this,
|
|
1422
|
+
return __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, __classPrivateFieldGet(this, _Chess_board, "f").pos);
|
|
1532
1423
|
}
|
|
1533
1424
|
/** Side to move: "w" | "b". */
|
|
1534
1425
|
turn() {
|
|
1535
|
-
return colorName(__classPrivateFieldGet(this,
|
|
1426
|
+
return colorName(__classPrivateFieldGet(this, _Chess_board, "f").turn);
|
|
1536
1427
|
}
|
|
1537
1428
|
/** Current fullmove number (starts at 1). */
|
|
1538
1429
|
moveNumber() {
|
|
1539
|
-
return __classPrivateFieldGet(this,
|
|
1430
|
+
return __classPrivateFieldGet(this, _Chess_board, "f").fullmoves;
|
|
1540
1431
|
}
|
|
1541
1432
|
/**
|
|
1542
1433
|
* Plays a move given as SAN (tolerant: `+`/`#` suffixes, `x` on quiet moves,
|
|
@@ -1544,24 +1435,28 @@ export class Chess {
|
|
|
1544
1435
|
* object. Returns the verbose move, or null when the move is illegal.
|
|
1545
1436
|
*/
|
|
1546
1437
|
move(input) {
|
|
1547
|
-
const pos = __classPrivateFieldGet(this,
|
|
1438
|
+
const pos = __classPrivateFieldGet(this, _Chess_board, "f").pos;
|
|
1548
1439
|
let mv = null;
|
|
1440
|
+
let moveWord = null;
|
|
1549
1441
|
if (typeof input === "string") {
|
|
1550
1442
|
const sanRes = parseSan(input, pos);
|
|
1551
1443
|
if (sanRes.ok) {
|
|
1552
1444
|
mv = sanRes.value;
|
|
1445
|
+
moveWord = packOf(mv);
|
|
1553
1446
|
}
|
|
1554
1447
|
else {
|
|
1555
1448
|
const uciRes = parseUci(input);
|
|
1556
|
-
if (uciRes.ok && isLegal(pos, uciRes.value))
|
|
1449
|
+
if (uciRes.ok && isLegal(pos, uciRes.value)) {
|
|
1557
1450
|
mv = uciRes.value;
|
|
1451
|
+
moveWord = packOf(mv);
|
|
1452
|
+
}
|
|
1558
1453
|
}
|
|
1559
1454
|
}
|
|
1560
1455
|
else {
|
|
1561
1456
|
const from = parseSquare(input.from);
|
|
1562
1457
|
const to = parseSquare(input.to);
|
|
1563
1458
|
if (from !== undefined && to !== undefined) {
|
|
1564
|
-
const piece = pieceAt(
|
|
1459
|
+
const piece = pieceAt(__classPrivateFieldGet(this, _Chess_board, "f").board, from);
|
|
1565
1460
|
const promotion = input.promotion
|
|
1566
1461
|
? { q: 4, r: 3, b: 2, n: 1 }[input.promotion.toLowerCase()]
|
|
1567
1462
|
: undefined;
|
|
@@ -1570,31 +1465,34 @@ export class Chess {
|
|
|
1570
1465
|
continue;
|
|
1571
1466
|
if (isLegal(pos, cand)) {
|
|
1572
1467
|
mv = cand;
|
|
1468
|
+
moveWord = packOf(mv);
|
|
1573
1469
|
break;
|
|
1574
1470
|
}
|
|
1575
1471
|
}
|
|
1576
1472
|
}
|
|
1577
1473
|
}
|
|
1578
|
-
if (!mv)
|
|
1474
|
+
if (!mv || moveWord === null)
|
|
1579
1475
|
return null;
|
|
1580
|
-
const
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1476
|
+
const before = __classPrivateFieldGet(this, _Chess_board, "f").toPosition();
|
|
1477
|
+
const san = makeSan(mv, before);
|
|
1478
|
+
const boardUndo = __classPrivateFieldGet(this, _Chess_board, "f").makeMove(moveWord);
|
|
1479
|
+
const after = __classPrivateFieldGet(this, _Chess_board, "f").toPosition();
|
|
1583
1480
|
__classPrivateFieldGet(this, _Chess_history, "f").push({
|
|
1584
|
-
before
|
|
1481
|
+
before,
|
|
1585
1482
|
after,
|
|
1586
1483
|
move: mv,
|
|
1587
1484
|
san,
|
|
1588
|
-
|
|
1589
|
-
|
|
1485
|
+
boardUndo,
|
|
1486
|
+
prev_checkers: before.checkers,
|
|
1487
|
+
prev_zobrist: before.zobristLo !== undefined && before.zobristHi !== undefined ? { lo: before.zobristLo, hi: before.zobristHi } : undefined,
|
|
1590
1488
|
});
|
|
1591
|
-
return __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_describe).call(this,
|
|
1489
|
+
return __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_describe).call(this, before, mv, after, san);
|
|
1592
1490
|
}
|
|
1593
1491
|
moves(options) {
|
|
1594
|
-
const pos = __classPrivateFieldGet(this,
|
|
1492
|
+
const pos = __classPrivateFieldGet(this, _Chess_board, "f").pos;
|
|
1595
1493
|
const out = [];
|
|
1596
1494
|
const emit = (from, set) => {
|
|
1597
|
-
const piece = pieceAt(
|
|
1495
|
+
const piece = pieceAt(__classPrivateFieldGet(this, _Chess_board, "f").board, from);
|
|
1598
1496
|
if (!piece)
|
|
1599
1497
|
return;
|
|
1600
1498
|
sq.forEachSquare(set, (to) => {
|
|
@@ -1630,27 +1528,32 @@ export class Chess {
|
|
|
1630
1528
|
const last = __classPrivateFieldGet(this, _Chess_history, "f").pop();
|
|
1631
1529
|
if (!last)
|
|
1632
1530
|
return null;
|
|
1633
|
-
|
|
1531
|
+
if (last.boardUndo) {
|
|
1532
|
+
__classPrivateFieldGet(this, _Chess_board, "f").unmakeMove(last.boardUndo);
|
|
1533
|
+
}
|
|
1534
|
+
else {
|
|
1535
|
+
__classPrivateFieldSet(this, _Chess_board, new Board(last.before), "f");
|
|
1536
|
+
}
|
|
1634
1537
|
return __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_describe).call(this, last.before, last.move, last.after, last.san);
|
|
1635
1538
|
}
|
|
1636
|
-
isCheck() { return
|
|
1637
|
-
inCheck() { return
|
|
1638
|
-
isCheckmate() { return isCheckmate(__classPrivateFieldGet(this,
|
|
1639
|
-
isStalemate() { return isStalemate(__classPrivateFieldGet(this,
|
|
1539
|
+
isCheck() { return __classPrivateFieldGet(this, _Chess_board, "f").inCheck(); }
|
|
1540
|
+
inCheck() { return __classPrivateFieldGet(this, _Chess_board, "f").inCheck(); }
|
|
1541
|
+
isCheckmate() { return isCheckmate(__classPrivateFieldGet(this, _Chess_board, "f").pos); }
|
|
1542
|
+
isStalemate() { return isStalemate(__classPrivateFieldGet(this, _Chess_board, "f").pos); }
|
|
1640
1543
|
/** Draw by insufficient material, the fifty-move rule, or threefold repetition. */
|
|
1641
1544
|
isDraw() {
|
|
1642
|
-
if (isInsufficientMaterial(__classPrivateFieldGet(this,
|
|
1545
|
+
if (isInsufficientMaterial(__classPrivateFieldGet(this, _Chess_board, "f").pos))
|
|
1643
1546
|
return true;
|
|
1644
|
-
if (isFiftyMoveDraw(__classPrivateFieldGet(this,
|
|
1547
|
+
if (isFiftyMoveDraw(__classPrivateFieldGet(this, _Chess_board, "f").pos))
|
|
1645
1548
|
return true;
|
|
1646
1549
|
if (isThreefoldRepetition(__classPrivateFieldGet(this, _Chess_instances, "m", _Chess_positions).call(this)))
|
|
1647
1550
|
return true;
|
|
1648
1551
|
return false;
|
|
1649
1552
|
}
|
|
1650
1553
|
/** Draw by the fifty-move rule. */
|
|
1651
|
-
isDrawByFiftyMoves() { return isFiftyMoveDraw(__classPrivateFieldGet(this,
|
|
1554
|
+
isDrawByFiftyMoves() { return isFiftyMoveDraw(__classPrivateFieldGet(this, _Chess_board, "f").pos); }
|
|
1652
1555
|
/** Draw by insufficient material. */
|
|
1653
|
-
isInsufficientMaterial() { return isInsufficientMaterial(__classPrivateFieldGet(this,
|
|
1556
|
+
isInsufficientMaterial() { return isInsufficientMaterial(__classPrivateFieldGet(this, _Chess_board, "f").pos); }
|
|
1654
1557
|
/** Draw by threefold repetition over the game's position history. */
|
|
1655
1558
|
isThreefoldRepetition() { return isThreefoldRepetition(__classPrivateFieldGet(this, _Chess_instances, "m", _Chess_positions).call(this)); }
|
|
1656
1559
|
/** Game over: checkmate, stalemate, or draw. */
|
|
@@ -1660,7 +1563,7 @@ export class Chess {
|
|
|
1660
1563
|
const sqIdx = parseSquare(square);
|
|
1661
1564
|
if (sqIdx === undefined)
|
|
1662
1565
|
return undefined;
|
|
1663
|
-
const p = pieceAt(__classPrivateFieldGet(this,
|
|
1566
|
+
const p = pieceAt(__classPrivateFieldGet(this, _Chess_board, "f").board, sqIdx);
|
|
1664
1567
|
if (!p)
|
|
1665
1568
|
return undefined;
|
|
1666
1569
|
return { type: ROLE_CHARS[p.role], color: colorName(p.color) };
|
|
@@ -1672,7 +1575,7 @@ export class Chess {
|
|
|
1672
1575
|
const row = [];
|
|
1673
1576
|
for (let file = 0; file < 8; file++) {
|
|
1674
1577
|
const sqIdx = rank * 8 + file;
|
|
1675
|
-
const p = pieceAt(__classPrivateFieldGet(this,
|
|
1578
|
+
const p = pieceAt(__classPrivateFieldGet(this, _Chess_board, "f").board, sqIdx);
|
|
1676
1579
|
row.push(p ? { square: squareName(sqIdx), type: ROLE_CHARS[p.role], color: colorName(p.color) } : null);
|
|
1677
1580
|
}
|
|
1678
1581
|
rows.push(row);
|
|
@@ -1714,25 +1617,27 @@ export class Chess {
|
|
|
1714
1617
|
const sqIdx = typeof square === "number" ? square : parseSquare(square);
|
|
1715
1618
|
if (sqIdx === undefined)
|
|
1716
1619
|
return { lo: 0, hi: 0 };
|
|
1717
|
-
return dests(__classPrivateFieldGet(this,
|
|
1620
|
+
return dests(__classPrivateFieldGet(this, _Chess_board, "f").pos, sqIdx);
|
|
1718
1621
|
}
|
|
1719
1622
|
/** Legal destinations for every piece of the side to move. */
|
|
1720
|
-
allDests() { return allDests(__classPrivateFieldGet(this,
|
|
1623
|
+
allDests() { return allDests(__classPrivateFieldGet(this, _Chess_board, "f").pos); }
|
|
1721
1624
|
/** True when `move` is legal in the current position. */
|
|
1722
|
-
isLegal(move) { return isLegal(__classPrivateFieldGet(this,
|
|
1625
|
+
isLegal(move) { return isLegal(__classPrivateFieldGet(this, _Chess_board, "f").pos, move); }
|
|
1723
1626
|
/** Genuine recursive perft node count (no shortcuts). */
|
|
1724
|
-
perft(depth) { return
|
|
1627
|
+
perft(depth) { return __classPrivateFieldGet(this, _Chess_board, "f").perft(depth); }
|
|
1725
1628
|
/** Applies an engine move in place (immutable core stays pure underneath). */
|
|
1726
1629
|
play(move) {
|
|
1727
|
-
const before = __classPrivateFieldGet(this,
|
|
1630
|
+
const before = __classPrivateFieldGet(this, _Chess_board, "f").toPosition();
|
|
1728
1631
|
const san = makeSan(move, before);
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1632
|
+
const moveWord = packOf(move);
|
|
1633
|
+
const boardUndo = __classPrivateFieldGet(this, _Chess_board, "f").makeMove(moveWord);
|
|
1634
|
+
const after = __classPrivateFieldGet(this, _Chess_board, "f").toPosition();
|
|
1731
1635
|
__classPrivateFieldGet(this, _Chess_history, "f").push({
|
|
1732
1636
|
before,
|
|
1733
1637
|
after,
|
|
1734
1638
|
move,
|
|
1735
1639
|
san,
|
|
1640
|
+
boardUndo,
|
|
1736
1641
|
prev_checkers: before.checkers,
|
|
1737
1642
|
prev_zobrist: before.zobristLo !== undefined && before.zobristHi !== undefined ? { lo: before.zobristLo, hi: before.zobristHi } : undefined,
|
|
1738
1643
|
});
|
|
@@ -1740,13 +1645,10 @@ export class Chess {
|
|
|
1740
1645
|
}
|
|
1741
1646
|
/** Current 64-bit Zobrist key (zero-BigInt {lo, hi} halves). */
|
|
1742
1647
|
zobrist() {
|
|
1743
|
-
|
|
1744
|
-
return { lo: __classPrivateFieldGet(this, _Chess_pos, "f").zobristLo >>> 0, hi: __classPrivateFieldGet(this, _Chess_pos, "f").zobristHi >>> 0 };
|
|
1745
|
-
}
|
|
1746
|
-
return calculateZobrist(__classPrivateFieldGet(this, _Chess_pos, "f"));
|
|
1648
|
+
return __classPrivateFieldGet(this, _Chess_board, "f").zobrist();
|
|
1747
1649
|
}
|
|
1748
1650
|
/** Current Zobrist key as 16 zero-padded hex digits (hi first). */
|
|
1749
|
-
zobristHex() { return
|
|
1651
|
+
zobristHex() { return __classPrivateFieldGet(this, _Chess_board, "f").zobristHex(); }
|
|
1750
1652
|
/** Packs the game's move history into a 16-bit moves2 stream. */
|
|
1751
1653
|
toMoves2() {
|
|
1752
1654
|
const words = new Uint16Array(__classPrivateFieldGet(this, _Chess_history, "f").length);
|
|
@@ -1759,7 +1661,7 @@ export class Chess {
|
|
|
1759
1661
|
this.load(startFen);
|
|
1760
1662
|
__classPrivateFieldSet(this, _Chess_startFen, startFen, "f");
|
|
1761
1663
|
for (const mv of packedToMoves(buffer)) {
|
|
1762
|
-
if (!isLegal(__classPrivateFieldGet(this,
|
|
1664
|
+
if (!isLegal(__classPrivateFieldGet(this, _Chess_board, "f").pos, mv))
|
|
1763
1665
|
throw new Error(`moves2 replay: illegal move ${mv.from}->${mv.to}`);
|
|
1764
1666
|
this.play(mv);
|
|
1765
1667
|
}
|
|
@@ -1781,8 +1683,9 @@ export class Chess {
|
|
|
1781
1683
|
/** FEN the game started from (for tree roots / PGN headers). */
|
|
1782
1684
|
get startFen() { return __classPrivateFieldGet(this, _Chess_startFen, "f"); }
|
|
1783
1685
|
/** Live engine position (read-only view over the internal state). */
|
|
1784
|
-
get pos() { return __classPrivateFieldGet(this,
|
|
1785
|
-
get _pos() { return __classPrivateFieldGet(this,
|
|
1686
|
+
get pos() { return __classPrivateFieldGet(this, _Chess_board, "f").pos; }
|
|
1687
|
+
get _pos() { return __classPrivateFieldGet(this, _Chess_board, "f").pos; }
|
|
1688
|
+
get boardInstance() { return __classPrivateFieldGet(this, _Chess_board, "f"); }
|
|
1786
1689
|
/** Internal history log (read-only view; used by toTree). */
|
|
1787
1690
|
get historyEntries() { return __classPrivateFieldGet(this, _Chess_history, "f"); }
|
|
1788
1691
|
/**
|
|
@@ -1830,7 +1733,7 @@ export class Chess {
|
|
|
1830
1733
|
return buildTreeWrapper(root ?? { id: "", ply: 0, fen: INITIAL_FEN, uci: "", children: [] });
|
|
1831
1734
|
}
|
|
1832
1735
|
}
|
|
1833
|
-
|
|
1736
|
+
_Chess_board = new WeakMap(), _Chess_startFen = new WeakMap(), _Chess_history = new WeakMap(), _Chess_instances = new WeakSet(), _Chess_movetext = function _Chess_movetext() {
|
|
1834
1737
|
const sans = __classPrivateFieldGet(this, _Chess_history, "f").map((h) => h.san);
|
|
1835
1738
|
let fullmove = parseFullmove(__classPrivateFieldGet(this, _Chess_startFen, "f"));
|
|
1836
1739
|
const blackToStart = __classPrivateFieldGet(this, _Chess_startFen, "f").split(/\s+/)[1] === "b";
|
package/dist/chess960.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as chess from "./chess.js";
|
|
2
2
|
import type { Setup } from "./types.js";
|
|
3
|
-
export {
|
|
3
|
+
export { dests, allDests, isCheck, isCheckmate, isStalemate, perft, makeMove } from "./chess.js";
|
|
4
4
|
export declare class Chess960 extends chess.Chess {
|
|
5
5
|
static fromSetup(setup: Setup): Chess960;
|
|
6
6
|
}
|
package/dist/chess960.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chess960.d.ts","sourceRoot":"","sources":["../src/chess960.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chess960.d.ts","sourceRoot":"","sources":["../src/chess960.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKjG,qBAAa,QAAS,SAAQ,KAAK,CAAC,KAAK;IAGvC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ;CAGzC;AAGD,eAAO,MAAM,UAAU,sBAAgB,CAAC;AACxC,eAAO,MAAM,cAAc,0BAAoB,CAAC;AAChD,eAAO,MAAM,QAAQ,oBAAc,CAAC"}
|
package/dist/chess960.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/chess960.ts — Chess960 (Fischer Random) support, X-FEN/Shredder dual
|
|
2
|
-
// MIT
|
|
2
|
+
// MIT gigachess, clean-room from specs + FIDE notes (no G P L)
|
|
3
3
|
// Re-uses core chess.ts logic which already handles 960 castling via generic rook sets
|
|
4
4
|
import * as chess from "./chess.js";
|
|
5
|
-
export {
|
|
5
|
+
export { dests, allDests, isCheck, isCheckmate, isStalemate, perft, makeMove } from "./chess.js";
|
|
6
6
|
// Chess960 position is same as Setup but with chess960 flag handling for FEN
|
|
7
7
|
// Provide helper to create Chess960 position with 960 castling parsing already done via fen.ts
|
|
8
8
|
export class Chess960 extends chess.Chess {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Chess, INITIAL_FEN, type ColorName, type PieceChar, type VerboseMove, type HistoryEntry, } from "./chess.js";
|
|
2
|
+
export { Chess960 } from "./chess960.js";
|
|
3
|
+
export declare const WHITE = "w";
|
|
4
|
+
export declare const BLACK = "b";
|
|
5
|
+
export declare const PAWN = "p";
|
|
6
|
+
export declare const KNIGHT = "n";
|
|
7
|
+
export declare const BISHOP = "b";
|
|
8
|
+
export declare const ROOK = "r";
|
|
9
|
+
export declare const QUEEN = "q";
|
|
10
|
+
export declare const KING = "k";
|
|
11
|
+
export declare const DEFAULT_POSITION = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
|
12
|
+
export declare const SQUARES: readonly ["a8", "b8", "c8", "d8", "e8", "f8", "g8", "h8", "a7", "b7", "c7", "d7", "e7", "f7", "g7", "h7", "a6", "b6", "c6", "d6", "e6", "f6", "g6", "h6", "a5", "b5", "c5", "d5", "e5", "f5", "g5", "h5", "a4", "b4", "c4", "d4", "e4", "f4", "g4", "h4", "a3", "b3", "c3", "d3", "e3", "f3", "g3", "h3", "a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2", "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1"];
|
|
13
|
+
//# sourceMappingURL=chessjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chessjs.d.ts","sourceRoot":"","sources":["../src/chessjs.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,eAAO,MAAM,KAAK,MAAM,CAAC;AACzB,eAAO,MAAM,KAAK,MAAM,CAAC;AAEzB,eAAO,MAAM,IAAI,MAAM,CAAC;AACxB,eAAO,MAAM,MAAM,MAAM,CAAC;AAC1B,eAAO,MAAM,MAAM,MAAM,CAAC;AAC1B,eAAO,MAAM,IAAI,MAAM,CAAC;AACxB,eAAO,MAAM,KAAK,MAAM,CAAC;AACzB,eAAO,MAAM,IAAI,MAAM,CAAC;AAExB,eAAO,MAAM,gBAAgB,6DAA6D,CAAC;AAE3F,eAAO,MAAM,OAAO,2YASV,CAAC"}
|
package/dist/chessjs.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/chessjs.ts — chess.js-compatible wrapper API for GigaChess
|
|
2
|
+
// Optional drop-in wrapper mirroring chess.js API ergonomics over the native Board engine.
|
|
3
|
+
export { Chess, INITIAL_FEN, } from "./chess.js";
|
|
4
|
+
export { Chess960 } from "./chess960.js";
|
|
5
|
+
export const WHITE = "w";
|
|
6
|
+
export const BLACK = "b";
|
|
7
|
+
export const PAWN = "p";
|
|
8
|
+
export const KNIGHT = "n";
|
|
9
|
+
export const BISHOP = "b";
|
|
10
|
+
export const ROOK = "r";
|
|
11
|
+
export const QUEEN = "q";
|
|
12
|
+
export const KING = "k";
|
|
13
|
+
export const DEFAULT_POSITION = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
|
14
|
+
export const SQUARES = [
|
|
15
|
+
"a8", "b8", "c8", "d8", "e8", "f8", "g8", "h8",
|
|
16
|
+
"a7", "b7", "c7", "d7", "e7", "f7", "g7", "h7",
|
|
17
|
+
"a6", "b6", "c6", "d6", "e6", "f6", "g6", "h6",
|
|
18
|
+
"a5", "b5", "c5", "d5", "e5", "f5", "g5", "h5",
|
|
19
|
+
"a4", "b4", "c4", "d4", "e4", "f4", "g4", "h4",
|
|
20
|
+
"a3", "b3", "c3", "d3", "e3", "f3", "g3", "h3",
|
|
21
|
+
"a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2",
|
|
22
|
+
"a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1",
|
|
23
|
+
];
|
package/dist/chessops/board.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { SquareSet } from "./squareSet.js";
|
|
|
3
3
|
import type { ByColor, ByRole, Color, Piece, Role, Square } from "./types.js";
|
|
4
4
|
export declare class Board implements Iterable<[Square, Piece]>, ByRole<SquareSet>, ByColor<SquareSet> {
|
|
5
5
|
/** Internal engine (immutable) board. Mutating methods replace it wholesale. */
|
|
6
|
-
_b: engine.
|
|
6
|
+
_b: engine.BoardLike;
|
|
7
7
|
private constructor();
|
|
8
8
|
static empty(): Board;
|
|
9
9
|
static default(): Board;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../../src/chessops/board.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAK9E,qBAAa,KAAM,YAAW,QAAQ,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;IAC5F,gFAAgF;IAChF,EAAE,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../../src/chessops/board.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAK9E,qBAAa,KAAM,YAAW,QAAQ,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;IAC5F,gFAAgF;IAChF,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC;IAErB,OAAO;IAIP,MAAM,CAAC,KAAK,IAAI,KAAK;IAGrB,MAAM,CAAC,OAAO,IAAI,KAAK;IAGvB,KAAK,IAAI,IAAI;IAGb,KAAK,IAAI,IAAI;IAGb,KAAK,IAAI,KAAK;IAId,IAAI,QAAQ,IAAI,SAAS,CAExB;IACD,IAAI,QAAQ,IAAI,SAAS,CAExB;IACD,IAAI,KAAK,IAAI,SAAS,CAErB;IACD,IAAI,KAAK,IAAI,SAAS,CAErB;IACD,IAAI,IAAI,IAAI,SAAS,CAEpB;IACD,IAAI,MAAM,IAAI,SAAS,CAEtB;IACD,IAAI,MAAM,IAAI,SAAS,CAEtB;IACD,IAAI,IAAI,IAAI,SAAS,CAEpB;IACD,IAAI,KAAK,IAAI,SAAS,CAErB;IACD,IAAI,IAAI,IAAI,SAAS,CAEpB;IAGD,OAAO,CAAC,OAAO;IAIf,IAAI,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAkC;IAC3D,IAAI,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAkC;IAC3D,IAAI,KAAK,CAAC,CAAC,EAAE,SAAS,EAA+B;IACrD,IAAI,KAAK,CAAC,CAAC,EAAE,SAAS,EAA+B;IACrD,IAAI,IAAI,CAAC,CAAC,EAAE,SAAS,EAA8B;IACnD,IAAI,MAAM,CAAC,CAAC,EAAE,SAAS,EAAgC;IACvD,IAAI,MAAM,CAAC,CAAC,EAAE,SAAS,EAAgC;IACvD,IAAI,IAAI,CAAC,CAAC,EAAE,SAAS,EAA8B;IACnD,IAAI,KAAK,CAAC,CAAC,EAAE,SAAS,EAA+B;IACrD,IAAI,IAAI,CAAC,CAAC,EAAE,SAAS,EAA8B;IAEnD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAI3C,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIzC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAItC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAMvC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS;IAQpD,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAG3B,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAO/C,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,SAAS;IAK3C,cAAc,IAAI,SAAS;IAG3B,gBAAgB,IAAI,SAAS;IAG7B,QAAQ,IAAI,SAAS;IAGrB,OAAO,IAAI,SAAS;IAGpB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS;CAMzC;AAED,eAAO,MAAM,WAAW,GAAI,MAAM,KAAK,EAAE,OAAO,KAAK,KAAG,OACjB,CAAC"}
|
package/dist/chessops/chess.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/baseline/chess.ts — baseline-exact Position/Chess/Castles classes (ADR-014).
|
|
2
2
|
// The facade keeps the baseline mutable-instance semantics (play() mutates the
|
|
3
3
|
// position, exactly like baseline) while delegating all rules to the immutable
|
|
4
|
-
//
|
|
4
|
+
// gigachess engine. Caller-provided values (Setup, Move) are never mutated.
|
|
5
5
|
import { Result } from "@badrap/result";
|
|
6
6
|
import * as engine from "../chess.js";
|
|
7
7
|
import * as engineAttacks from "../attacks.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BoardLike as EngineBoard } from "../board.js";
|
|
2
2
|
import type { Move as EngineMove, Position as EnginePosition } from "../types.js";
|
|
3
3
|
import { Role as ERole, Color as EColor } from "../types.js";
|
|
4
4
|
import type { CastlingRights as EngineCastlingRights } from "../types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/chessops/convert.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/chessops/convert.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,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,WAExC,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BoardLike as EngineBoard } from "../board.js";
|
|
2
2
|
export declare const INITIAL_BOARD_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
|
|
3
3
|
export declare const INITIAL_EPD = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -";
|
|
4
4
|
export declare const INITIAL_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fenInternal.d.ts","sourceRoot":"","sources":["../../src/chessops/fenInternal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fenInternal.d.ts","sourceRoot":"","sources":["../../src/chessops/fenInternal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAI5D,eAAO,MAAM,iBAAiB,gDAAgD,CAAC;AAC/E,eAAO,MAAM,WAAW,yDAAyD,CAAC;AAClF,eAAO,MAAM,WAAW,6DAA6D,CAAC;AACtF,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,SAAS,0BAA0B,CAAC;AACjD,eAAO,MAAM,SAAS,8BAA8B,CAAC;AAErD;gCACgC;AAChC,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAIvE;AAWD;;kCAEkC;AAClC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAU9D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/baseline/fenInternal.ts — engine bridge shared by the baseline-compatible
|
|
2
2
|
// facade modules (ADR-014). Not part of the public API. Single-sourced FEN
|
|
3
|
-
// constants + placement codecs (
|
|
4
|
-
// `
|
|
3
|
+
// constants + placement codecs (gigachess-adopt task 3.2; formerly
|
|
4
|
+
// `gigachess`, ADR-015).
|
|
5
5
|
import { parseFen as engineParseFen, makeFen as engineMakeFen } from "../fen.js";
|
|
6
6
|
import { Color } from "../types.js";
|
|
7
7
|
export const INITIAL_BOARD_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
|
package/dist/chessops/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/baseline/index.ts — baseline-compatible public API (ADR-014).
|
|
2
2
|
// Mirrors the baseline root module layout: `import { Chess, parseFen, ... }
|
|
3
|
-
// from "
|
|
3
|
+
// from "gigachess/chessops" (formerly gigachess/baseline, ADR-015)`. Backed by the immutable gigachess engine.
|
|
4
4
|
export * from "./types.js";
|
|
5
5
|
export * from "./squareSet.js";
|
|
6
6
|
export * from "./board.js";
|
|
@@ -10,7 +10,7 @@ export * from "./fen.js";
|
|
|
10
10
|
export * from "./san.js";
|
|
11
11
|
export * from "./util.js";
|
|
12
12
|
export * from "./debug.js";
|
|
13
|
-
// Integrated tree analysis (change
|
|
13
|
+
// Integrated tree analysis (change gigachess-unified-api-and-perf, task 3.3):
|
|
14
14
|
// the workstation consumes chessops + chesstree from ONE package. Re-exports
|
|
15
15
|
// the clean-room chesstree layer (buildTree / pgnImport / pgnExport /
|
|
16
16
|
// TreeWrapper) alongside the chessops-shaped API.
|
package/dist/chessops/setup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/baseline/setup.ts — baseline-exact Setup interface and helpers (ADR-014).
|
|
2
|
-
// Pockets/remainingChecks are always undefined:
|
|
2
|
+
// Pockets/remainingChecks are always undefined: gigachess implements standard
|
|
3
3
|
// chess only (no Crazyhouse/3check — variants are out of project scope).
|
|
4
4
|
import { Board } from "./board.js";
|
|
5
5
|
import { SquareSet } from "./squareSet.js";
|