gigachess 0.6.0 → 0.7.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.
Files changed (87) hide show
  1. package/README.md +82 -49
  2. package/dist/attacks.d.ts +7 -4
  3. package/dist/attacks.d.ts.map +1 -1
  4. package/dist/attacks.js +36 -15
  5. package/dist/chess960.d.ts +2 -9
  6. package/dist/chess960.d.ts.map +1 -1
  7. package/dist/chess960.js +2 -18
  8. package/dist/chessjs.d.ts +1 -1
  9. package/dist/chessjs.d.ts.map +1 -1
  10. package/dist/chessjs.js +1 -1
  11. package/dist/chessops/board.d.ts +1 -1
  12. package/dist/chessops/board.d.ts.map +1 -1
  13. package/dist/chessops/board.js +1 -1
  14. package/dist/chessops/chess.d.ts +6 -10
  15. package/dist/chessops/chess.d.ts.map +1 -1
  16. package/dist/chessops/chess.js +73 -97
  17. package/dist/chessops/convert.d.ts +1 -1
  18. package/dist/chessops/convert.d.ts.map +1 -1
  19. package/dist/chessops/convert.js +1 -1
  20. package/dist/chessops/debug.d.ts.map +1 -1
  21. package/dist/chessops/debug.js +7 -0
  22. package/dist/chessops/fen.d.ts.map +1 -1
  23. package/dist/chessops/fen.js +13 -2
  24. package/dist/chessops/fenInternal.d.ts +1 -1
  25. package/dist/chessops/fenInternal.d.ts.map +1 -1
  26. package/dist/chessops/fenInternal.js +1 -1
  27. package/dist/chessops/nativeBridge.d.ts +14 -0
  28. package/dist/chessops/nativeBridge.d.ts.map +1 -0
  29. package/dist/chessops/nativeBridge.js +87 -0
  30. package/dist/chessops/san.d.ts.map +1 -1
  31. package/dist/chessops/san.js +12 -10
  32. package/dist/chesstree.d.ts.map +1 -1
  33. package/dist/chesstree.js +23 -62
  34. package/dist/core.d.ts +6 -8
  35. package/dist/core.d.ts.map +1 -1
  36. package/dist/core.js +5 -10
  37. package/dist/fast/index.js +1 -1
  38. package/dist/fast.d.ts +1 -11
  39. package/dist/fast.d.ts.map +1 -1
  40. package/dist/fast.js +2 -11
  41. package/dist/index.d.ts +1 -14
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +2 -19
  44. package/dist/native96.d.ts +16 -0
  45. package/dist/native96.d.ts.map +1 -0
  46. package/dist/native96.js +6 -0
  47. package/dist/nativeBoard96.d.ts +118 -0
  48. package/dist/nativeBoard96.d.ts.map +1 -0
  49. package/dist/nativeBoard96.js +1077 -0
  50. package/dist/nativeChess.d.ts +97 -0
  51. package/dist/nativeChess.d.ts.map +1 -0
  52. package/dist/nativeChess.js +201 -0
  53. package/dist/nativeMovegen96.d.ts +2 -0
  54. package/dist/nativeMovegen96.d.ts.map +1 -0
  55. package/dist/{standardMovegen.js → nativeMovegen96.js} +77 -48
  56. package/dist/nativePublicTypes.d.ts +3 -0
  57. package/dist/nativePublicTypes.d.ts.map +1 -0
  58. package/dist/nativePublicTypes.js +1 -0
  59. package/dist/perftCompact.d.ts +7 -0
  60. package/dist/perftCompact.d.ts.map +1 -1
  61. package/dist/perftCompact.js +124 -62
  62. package/dist/pgn.d.ts +2 -3
  63. package/dist/pgn.d.ts.map +1 -1
  64. package/dist/pgn.js +2 -5
  65. package/dist/setupBoard.d.ts +54 -0
  66. package/dist/setupBoard.d.ts.map +1 -0
  67. package/dist/setupBoard.js +249 -0
  68. package/dist/{fen.d.ts → setupFen.d.ts} +1 -1
  69. package/dist/setupFen.d.ts.map +1 -0
  70. package/dist/{fen.js → setupFen.js} +1 -1
  71. package/dist/types.d.ts +1 -1
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/zobrist.d.ts +2 -2
  74. package/dist/zobrist.d.ts.map +1 -1
  75. package/package.json +10 -7
  76. package/dist/board.d.ts +0 -242
  77. package/dist/board.d.ts.map +0 -1
  78. package/dist/board.js +0 -1403
  79. package/dist/chess.d.ts +0 -259
  80. package/dist/chess.d.ts.map +0 -1
  81. package/dist/chess.js +0 -2314
  82. package/dist/fen.d.ts.map +0 -1
  83. package/dist/san.d.ts +0 -38
  84. package/dist/san.d.ts.map +0 -1
  85. package/dist/san.js +0 -523
  86. package/dist/standardMovegen.d.ts +0 -3
  87. package/dist/standardMovegen.d.ts.map +0 -1
package/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  <h1 align="center">GigaChess</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>A correctness-tested, high-performance pure TypeScript chess rules library.</strong>
9
- <br>Pure JS/TS, no Rust or WebAssembly in the runtime. Perft and game-replay benchmarks are tracked separately.<br>
10
- Built for high-performance web applications, interactive chessboards, and analysis engines.
8
+ <strong>Benchmark-leading pure JavaScript/TypeScript chess library.</strong>
9
+ <br>Published 0.6.0: up to 164× the perft throughput of chess.js and 13× that of chessops.<br>
10
+ Full chess rules. Zero runtime dependencies. No WebAssembly.
11
11
  </p>
12
12
 
13
13
  <p align="center">
@@ -20,14 +20,46 @@
20
20
 
21
21
  ---
22
22
 
23
- ## Highlights
23
+ ## Built to be the fastest
24
24
 
25
- - **2.33–3.73× faster direct legal move generation than drumevp 1.3.2** across five tested Linux/Windows configurations.
26
- - Wins all ten supported real-game benchmark lanes against the tested external pure-JS competitors.
27
- - Zero runtime dependencies, no native binaries or WASM. Synchronous move generation before optional table loading.
28
- - Standard chess and Chess960, compact 16-bit moves, checked replay, FEN/SAN/UCI, PGN and study trees.
29
- - Incremental Polyglot-compatible Zobrist hashing and FIDE repetition keys.
30
- - MIT license; compatibility entry points for chess.js and chessops.
25
+ The published GigaChess 0.6.0 leads every supported pure-JS workload in our independent
26
+ Linux and Windows benchmark matrix, including move generation, notation,
27
+ FEN, game replay and perft. It is built for chess applications, interactive
28
+ boards, analysis tools and high-throughput game databases.
29
+
30
+ | Benchmark | vs chess.js | vs chessops |
31
+ |---|---:|---:|
32
+ | Mixed-position perft | **132–164×** | **7.8–9.9×** |
33
+ | Starting-position perft (depth 5) | **80–104×** | **9.6–13.4×** |
34
+ | SAN move lists | **7.4–8.1×** | **2.7–3.1×** |
35
+ | FEN round trip | **4.3–6.3×** | **3.0–3.8×** |
36
+
37
+ Throughput ratios across five tested Node.js configurations; higher is better.
38
+ Perft measures legal move-tree traversal, not AI search strength.
39
+ [Full results, all competitors and methodology](#performance-comparisons-060).
40
+
41
+ - **Pure TypeScript, zero runtime dependencies:** no WASM, native binaries or compilation step to begin playing.
42
+ - **Complete chess rules:** standard chess, Chess960, SAN, UCI, FEN, PGN and annotated study trees.
43
+ - **Developer-friendly:** chess.js and chessops-style interfaces over the same engine, plus a high-throughput stateful Board API.
44
+ - **Compact and correct:** independent packed 16-bit moves, checked replay, incremental Polyglot hashes, FIDE repetition keys and reversible moves.
45
+ - **MIT licensed:** use in open-source or commercial projects.
46
+
47
+ ### GigaChess 0.7.0 — shared native Board96
48
+
49
+ Version 0.7.0 replaces the old native API with a single directly
50
+ operated **96-byte Board96** payload matching GigaChess Rust 0.3.0's
51
+ little-endian interchange format. JavaScript object overhead is additional.
52
+ There is no legacy playable fallback. The chess.js and chessops-style
53
+ interfaces also use Board96 for play.
54
+
55
+ Across ten independently tested Node 22/24 configurations (Linux and
56
+ Windows x64/ARM64, macOS ARM64), 0.7.0 improves median throughput
57
+ versus npm 0.6.0 by 1.84× for checked replay, 1.67× for trusted replay,
58
+ 2.08× for SAN and 1.29× for make/undo. FEN parsing and some clone/perft
59
+ lanes remain slower; see the full ranges, not just the wins.
60
+
61
+ [0.7.0 benchmark and correctness evidence](bench/results/native-board96-round4/REPORT.md) ·
62
+ [Migration guide](docs/MIGRATION-v0.7.0.md)
31
63
 
32
64
  ### Optimized pure-JavaScript Board
33
65
 
@@ -38,7 +70,7 @@ and hash tables for peak throughput:
38
70
  ~~~ts
39
71
  import { Board, ensureMagicTablesLoaded, ensureZobristLoaded } from "gigachess/fast";
40
72
  await Promise.all([ensureMagicTablesLoaded(), ensureZobristLoaded()]);
41
- const board = new Board();
73
+ const board = Board.fromFen();
42
74
  ~~~
43
75
 
44
76
  Import the table-loading hooks from the SAME /fast entry: the ordinary
@@ -61,11 +93,13 @@ npm install gigachess
61
93
  import { Board } from "gigachess";
62
94
 
63
95
  // Initialize starting position
64
- const board = new Board();
96
+ const board = Board.fromFen();
65
97
 
66
98
  // Parse SAN and execute a legal move
67
99
  const move = board.parseSan("e4");
68
- const undo = board.makeMove(move);
100
+ if (move === null) throw new Error("Illegal move");
101
+ const undo = board.clone();
102
+ board.makeMove(move, undo);
69
103
 
70
104
  console.log(board.toFen()); // 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1'
71
105
  console.log(board.inCheck()); // false
@@ -81,30 +115,29 @@ console.log(board.toFen()); // startpos restored
81
115
 
82
116
  ![GigaChess benchmark comparison](./assets/benchmark-comparison.png)
83
117
 
84
- Minimum GigaChess throughput advantage over each competitor across five Linux/Windows Node.js configurations. See the [full benchmark report](docs/BENCHMARKS.md) for ranges, source drumevp, the exact workload, pinned versions and raw measurements.
85
-
86
- | Workload | drumevp 1.3.2 | chessops 0.15.1 | chess.js 1.4.0 | GigaChess 0.5.0 |
87
- |---|---:|---:|---:|---:|
88
- | Native move list | 2.83× | 5.09× | 1,706.09× | 3.45× |
89
- | Normalized UCI list | 1.43× | 1.69× | 309.80× | 1.49× |
90
- | SAN list | — | 2.72× | 7.44× | 1.28× |
91
- | FEN round trip | 1.56× | 3.00× | 4.34× | 1.51× |
92
- | Validated UCI replay | 5.22× | 3.70× | 358.57× | 4.71× |
93
- | Start perft d5 | 1.80× | 9.57× | 79.75× | 4.26× |
94
- | Kiwipete perft d4 | 1.76× | 9.11× | 103.78× | 4.75× |
95
- | Endgame perft d5 | 1.35× | 7.60× | 45.86× | 4.79× |
96
- | Promotion perft d4 | 1.64× | 8.71× | 90.96× | 4.39× |
97
- | Mixed perft d3 | 1.66× | 7.83× | 132.10× | 3.57× |
118
+ Minimum GigaChess throughput advantage over each competitor across five Linux/Windows Node.js configurations. The strongest tested pure-JS competitor, drumevp, is also included: GigaChess is 2.33–3.73× faster in the separate direct move-generation comparison. See the [full benchmark report](docs/BENCHMARKS.md) for ranges, exact workloads, pinned versions and raw measurements.
119
+
120
+ | Workload | chess.js 1.4.0 | chessops 0.15.1 | drumevp 1.3.2 | drumevp source | GigaChess 0.5.0 |
121
+ |---|---:|---:|---:|---:|---:|
122
+ | Native move list | 1,706.09× | 5.09× | 2.83× | 2.79× | 3.45× |
123
+ | Normalized UCI list | 309.80× | 1.69× | 1.43× | 1.35× | 1.49× |
124
+ | SAN list | 7.44× | 2.72× | — | — | 1.28× |
125
+ | FEN round trip | 4.34× | 3.00× | 1.56× | — | 1.51× |
126
+ | Validated UCI replay | 358.57× | 3.70× | 5.22× | — | 4.71× |
127
+ | Start perft d5 | 79.75× | 9.57× | 1.80× | 1.81× | 4.26× |
128
+ | Kiwipete perft d4 | 103.78× | 9.11× | 1.76× | 1.75× | 4.75× |
129
+ | Endgame perft d5 | 45.86× | 7.60× | 1.35× | 1.37× | 4.79× |
130
+ | Promotion perft d4 | 90.96× | 8.71× | 1.64× | 1.65× | 4.39× |
131
+ | Mixed perft d3 | 132.10× | 7.83× | 1.66× | 1.63× | 3.57× |
98
132
 
99
133
  The native list workload uses each library's public return type (chess.js produces verbose move objects); normalized UCI and SAN are separate. — means unsupported/not measured. 20,000 positions, 300 validated games, exact move-set and SAN parity. Final Apple Silicon/browser performance remains unverified.
100
134
 
101
- ### UltraChess: warm Rust/WASM vs first-use latency
102
-
103
- UltraChess 1.4.0 is faster in warm perft and move-list workloads; GigaChess is faster in validated UCI replay on these runs. WASM is not part of the pure-JS ranking. GigaChess can generate legal moves synchronously before table loading, with no WASM compile/instantiation step.
104
-
105
- ![First-use latency, local Node 24.19](./assets/cold-start.png)
135
+ ### WebAssembly comparison
106
136
 
107
- On one Linux x64 host, median import-to-first-list latency was **16.9 ms** for GigaChess with synchronous fallback, **80.9 ms** with sliding/hash tables ready, and **592.0 ms** for UltraChess default WASM (599.8 ms inline). 15 fresh processes per entry, process launch excluded; not a universal startup claim. [Warm WASM results, methodology and samples](docs/BENCHMARKS.md).
137
+ UltraChess (Rust/WASM) is a separate runtime category, not part of the
138
+ pure-JS ranking. Its warm perft throughput is higher, while GigaChess leads
139
+ validated replay and offers synchronous first-use without WASM initialization.
140
+ See the [separate warm and cold-start comparisons](docs/BENCHMARKS.md#ultrachess-rustwebassembly-separate-category).
108
141
 
109
142
  ---
110
143
 
@@ -132,38 +165,38 @@ console.log(chess.history()); // ['e4', 'e5']
132
165
  ```ts
133
166
  import { Board } from "gigachess";
134
167
 
135
- const board = new Board();
168
+ const board = Board.fromFen();
136
169
 
137
- // Iterate without array allocation:
170
+ // Visit an independently owned list (callbacks may reenter):
138
171
  board.forEachLegalMove((move) => {
139
172
  console.log(board.toSan(move));
140
173
  });
141
174
 
142
- // Or write into a reusable caller-owned buffer:
175
+ // Or write into a reusable caller-owned buffer without list allocation:
143
176
  const buffer = new Uint16Array(256);
144
- const count = board.legalMoves(buffer);
177
+ const count = board.legalMovesInto(buffer);
145
178
  ```
146
179
 
147
180
  ### 2. Game State & Terminal Checks
148
181
  ```ts
149
- const board = new Board();
182
+ const board = Board.fromFen();
150
183
 
151
184
  board.inCheck(); // false
152
185
  board.isCheckmate(); // false
153
186
  board.isStalemate(); // false
154
- board.isDraw(); // false
187
+ board.isSeventyFiveMoveDraw(); // false
155
188
  board.isInsufficientMaterial();// false
156
- board.turn; // 0 = White, 1 = Black
189
+ board.turn; // 0 = Black, 1 = White
157
190
  ```
158
191
 
159
192
  ### 3. Incremental Polyglot Zobrist Hashing
160
193
  ```ts
161
- import { Board, ensureZobristLoaded, repetitionKey } from "gigachess";
194
+ import { Board, ensureZobristLoaded } from "gigachess";
162
195
 
163
196
  // The compact Zobrist data is loaded on demand; no wait is needed for normal
164
197
  // movegen, but await readiness before asking for a meaningful position key.
165
198
  await ensureZobristLoaded();
166
- const board = new Board();
199
+ const board = Board.fromFen();
167
200
 
168
201
  // Fast 64-bit Polyglot key updated in O(1) during moves:
169
202
  const hash = board.zobrist(); // { lo: number, hi: number }
@@ -172,7 +205,7 @@ console.log(board.zobristHex()); // "463b96181691fc9c"
172
205
  // FIDE repetition equivalence ignores en-passant when the capture is illegal.
173
206
  // Polyglot hashing intentionally retains its pseudo-legal EP rule; don't
174
207
  // substitute the repetition key in opening-book or interoperable database keys.
175
- const fideKey = repetitionKey(board.pos);
208
+ const fideKey = board.repetitionKeyHex();
176
209
  ```
177
210
 
178
211
  ### 4. Chess960 (Fischer Random)
@@ -180,7 +213,7 @@ const fideKey = repetitionKey(board.pos);
180
213
  import { Board } from "gigachess";
181
214
 
182
215
  // Load any of the 960 starting positions:
183
- const board = Board.fromFen("rnqbbknr/pppppppp/8/8/8/8/PPPPPPPP/RNQBBKNR w KQkq - 0 1", { chess960: true });
216
+ const board = Board.fromFen("rnqbbknr/pppppppp/8/8/8/8/PPPPPPPP/RNQBBKNR w KQkq - 0 1", true);
184
217
  console.log(board.toFen());
185
218
  ```
186
219
 
@@ -190,7 +223,7 @@ import { Board } from "gigachess";
190
223
 
191
224
  // Replay full games from compact 16-bit buffers:
192
225
  const moves = new Uint16Array([ /* packed 16-bit moves */ ]);
193
- const board = Board.fromMoves2(moves); // trusted, already-validated data
226
+ const board = Board.fromMoves2Trusted(moves); // trusted, already-validated data
194
227
 
195
228
  // Files, network input and imported bytes should use the checked API:
196
229
  const safeBoard = Board.fromMoves2Checked(moves);
@@ -203,7 +236,7 @@ const safeBoard = Board.fromMoves2Checked(moves);
203
236
 
204
237
  ## 🔬 Under the Hood: Why GigaChess is Fast
205
238
 
206
- 1. **In-Place Bitboard Mutation**: Unlike engines that clone full state on every move, `Board` mutates bitboards in-place and returns a compact `Undo` for instant $O(1)$ rollback.
239
+ 1. **In-Place Bitboard Mutation**: Unlike engines that clone full state on every move, `Board` mutates bitboards in-place and uses a caller-owned Board96 snapshot for instant $O(1)$ rollback.
207
240
  2. **32-bit integer pairs**: Bitboards use unsigned low/high words and typed lookup tables, avoiding BigInt arithmetic in hot move-generation loops.
208
241
  3. **Stockfish Single-Pass Pin Analysis (`CheckContext`)**: Checkers and pin lines are computed once per position, turning legal move validation into fast bitwise intersections.
209
242
  4. **Compact packed moves**: Independent Uint16Array results and caller-owned buffer APIs reduce allocation; no internal move-list cache.
@@ -222,12 +255,12 @@ MIT © [Itshak](https://github.com/itshak) & [GigaChess Contributors](https://gi
222
255
 
223
256
  The pure-TypeScript engine and [gigachess-rs](https://github.com/itshak/gigachess-rs)
224
257
  are separate implementations. JavaScript has **no WebAssembly startup or
225
- runtime dependency**. Both share the canonical 16-bit moves2, king-to-rook
258
+ runtime dependency**. Both share the canonical 96-byte Board96 v1 binary format and 16-bit moves2, king-to-rook
226
259
  castling, null sentinel `0xffff`, Polyglot vectors and Chess960 rook-file hash
227
- seed. See the [mirrored core contract](openspec/changes/dual-engine-hardening-20261123/specs/mirrored-core-contract/spec.md)
260
+ seed. See the [mirrored core contract](openspec/changes/compact-core-rust-parity-v0.7.0/specs/mirrored-core-contract/spec.md)
228
261
  and the shared `tests/position-keys-v1.tsv` / `tests/moves2-v1.tsv` fixtures.
229
262
 
230
263
  Benchmark numbers above describe specific workloads on specific hardware; they
231
264
  are not a universal ranking across every JavaScript/WASM chess engine. For an
232
265
  apples-to-apples pure TypeScript comparison and planned performance experiments,
233
- see the [maintenance research](openspec/changes/dual-engine-hardening-20261123/research.md).
266
+ see the [maintenance research](docs/research/superseded-openspec/dual-engine-hardening-20261123/research.md).
package/dist/attacks.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as sq from "./squareSet.js";
1
2
  import type { SquareSet } from "./squareSet.js";
2
3
  import { Color } from "./types.js";
3
4
  export declare function knightAttacks(sqIdx: number): SquareSet;
@@ -28,14 +29,16 @@ export declare function between(from: number, to: number): SquareSet;
28
29
  export declare const LINE_RAY_LO: Uint32Array<ArrayBuffer>;
29
30
  export declare const LINE_RAY_HI: Uint32Array<ArrayBuffer>;
30
31
  export declare function lineRay(from: number, to: number): SquareSet;
32
+ export declare const emptyRookRays: sq.SquareSet[];
33
+ export declare const emptyBishopRays: sq.SquareSet[];
31
34
  /**
32
35
  * All pieces of `attacker` color attacking `square`. `occ` overrides the
33
36
  * occupancy used for slider rays (hot-loop variant: king-safety masks
34
37
  * evaluate attackedness with the moving king removed from the occupancy so
35
38
  * that sliders x-raying the king stay "attacking" through its old square).
36
39
  */
37
- export declare function attackersTo(board: import("./board.js").BoardLike, square: number, attacker: Color, occ?: SquareSet): SquareSet;
38
- export declare function isAttacked(board: import("./board.js").BoardLike, square: number, attacker: Color): boolean;
40
+ export declare function attackersTo(board: import("./setupBoard.js").BoardLike, square: number, attacker: Color, occ?: SquareSet): SquareSet;
41
+ export declare function isAttacked(board: import("./setupBoard.js").BoardLike, square: number, attacker: Color): boolean;
39
42
  /**
40
43
  * Union of enemy attacks with a supplied occupancy. Most callers need to
41
44
  * ask only about the eight king destinations. Unlike eight independent
@@ -43,8 +46,8 @@ export declare function isAttacked(board: import("./board.js").BoardLike, square
43
46
  * sliding attack once. Includes pinned enemy attacks per FIDE king safety.
44
47
  * This function only reads board state; all accumulators are local.
45
48
  */
46
- export declare function attackedSquares(board: import("./board.js").BoardLike, attacker: Color, occ?: SquareSet): SquareSet;
47
- export declare function kingAttackers(board: import("./board.js").BoardLike, kingColor: Color): SquareSet;
49
+ export declare function attackedSquares(board: import("./setupBoard.js").BoardLike, attacker: Color, occ?: SquareSet): SquareSet;
50
+ export declare function kingAttackers(board: import("./setupBoard.js").BoardLike, kingColor: Color): SquareSet;
48
51
  export declare function rookAttacksForTest(sqIdx: number, occ: SquareSet): SquareSet;
49
52
  export declare function bishopAttacksForTest(sqIdx: number, occ: SquareSet): SquareSet;
50
53
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"attacks.d.ts","sourceRoot":"","sources":["../src/attacks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAiFnC,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEtD;AACD,wBAAgB,WAAW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C,QAAQ,EAAE,KAAK,EACf,GAAG,GAAE,SAA0B,GAC9B,SAAS,CAmEX;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,SAAS,CASrG;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,SAAS,CAE3E;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,SAAS,CAE7E"}
package/dist/attacks.js CHANGED
@@ -352,6 +352,10 @@ export function lineRay(from, to) {
352
352
  const idx = ((from & 63) << 6) | (to & 63);
353
353
  return { lo: LINE_RAY_LO[idx], hi: LINE_RAY_HI[idx] };
354
354
  }
355
+ // Empty-board rays are immutable and valid both before and after lazy
356
+ // magic tables load. Share with the standard perft and replay kernels.
357
+ export const emptyRookRays = Array.from({ length: 64 }, (_, s) => rookAttacks(s, { lo: 0, hi: 0 }));
358
+ export const emptyBishopRays = Array.from({ length: 64 }, (_, s) => bishopAttacks(s, { lo: 0, hi: 0 }));
355
359
  // ---------- isAttacked / kingAttackers ----------
356
360
  /**
357
361
  * All pieces of `attacker` color attacking `square`. `occ` overrides the
@@ -375,14 +379,22 @@ export function attackersTo(board, square, attacker, occ = board.occupied) {
375
379
  hi = (hi | (aHi & board.knight.hi & nAtt.hi)) >>> 0;
376
380
  const bqLo = (board.bishop.lo | board.queen.lo) >>> 0;
377
381
  const bqHi = (board.bishop.hi | board.queen.hi) >>> 0;
378
- const bAtt = bishopAttacks(square, occ);
379
- lo = (lo | (aLo & bqLo & bAtt.lo)) >>> 0;
380
- hi = (hi | (aHi & bqHi & bAtt.hi)) >>> 0;
382
+ const bl = aLo & bqLo, bh = aHi & bqHi;
383
+ const br = emptyBishopRays[square];
384
+ if ((bl & br.lo) | (bh & br.hi)) {
385
+ const bAtt = bishopAttacks(square, occ);
386
+ lo = (lo | (bl & bAtt.lo)) >>> 0;
387
+ hi = (hi | (bh & bAtt.hi)) >>> 0;
388
+ }
381
389
  const rqLo = (board.rook.lo | board.queen.lo) >>> 0;
382
390
  const rqHi = (board.rook.hi | board.queen.hi) >>> 0;
383
- const rAtt = rookAttacks(square, occ);
384
- lo = (lo | (aLo & rqLo & rAtt.lo)) >>> 0;
385
- hi = (hi | (aHi & rqHi & rAtt.hi)) >>> 0;
391
+ const rl = aLo & rqLo, rh = aHi & rqHi;
392
+ const rr = emptyRookRays[square];
393
+ if ((rl & rr.lo) | (rh & rr.hi)) {
394
+ const rAtt = rookAttacks(square, occ);
395
+ lo = (lo | (rl & rAtt.lo)) >>> 0;
396
+ hi = (hi | (rh & rAtt.hi)) >>> 0;
397
+ }
386
398
  const kAtt = kingAttacks(square);
387
399
  lo = (lo | (aLo & board.king.lo & kAtt.lo)) >>> 0;
388
400
  hi = (hi | (aHi & board.king.hi & kAtt.hi)) >>> 0;
@@ -404,14 +416,22 @@ export function isAttacked(board, square, attacker) {
404
416
  const occ = board.occupied;
405
417
  const bqLo = (board.bishop.lo | board.queen.lo) >>> 0;
406
418
  const bqHi = (board.bishop.hi | board.queen.hi) >>> 0;
407
- const bAtt = bishopAttacks(square, occ);
408
- if ((((aLo & bqLo & bAtt.lo) | (aHi & bqHi & bAtt.hi)) >>> 0) !== 0)
409
- return true;
419
+ const bl = aLo & bqLo, bh = aHi & bqHi;
420
+ const br = emptyBishopRays[square];
421
+ if ((bl & br.lo) | (bh & br.hi)) {
422
+ const bAtt = bishopAttacks(square, occ);
423
+ if ((bl & bAtt.lo) | (bh & bAtt.hi))
424
+ return true;
425
+ }
410
426
  const rqLo = (board.rook.lo | board.queen.lo) >>> 0;
411
427
  const rqHi = (board.rook.hi | board.queen.hi) >>> 0;
412
- const rAtt = rookAttacks(square, occ);
413
- if ((((aLo & rqLo & rAtt.lo) | (aHi & rqHi & rAtt.hi)) >>> 0) !== 0)
414
- return true;
428
+ const rl = aLo & rqLo, rh = aHi & rqHi;
429
+ const rr = emptyRookRays[square];
430
+ if ((rl & rr.lo) | (rh & rr.hi)) {
431
+ const rAtt = rookAttacks(square, occ);
432
+ if ((rl & rAtt.lo) | (rh & rAtt.hi))
433
+ return true;
434
+ }
415
435
  const kAtt = kingAttacks(square);
416
436
  if ((((aLo & board.king.lo & kAtt.lo) | (aHi & board.king.hi & kAtt.hi)) >>> 0) !== 0)
417
437
  return true;
@@ -502,10 +522,11 @@ export function attackedSquares(board, attacker, occ = board.occupied) {
502
522
  return { lo: lo >>> 0, hi: hi >>> 0 };
503
523
  }
504
524
  export function kingAttackers(board, kingColor) {
505
- const ks = kingColor === Color.White ? sq.and(board.white, board.king) : sq.and(board.black, board.king);
506
- const ksq = sq.first(ks);
507
- if (ksq === undefined)
525
+ const co = kingColor === Color.White ? board.white : board.black;
526
+ const l = co.lo & board.king.lo, h = co.hi & board.king.hi;
527
+ if (!(l | h))
508
528
  return sq.empty();
529
+ const ksq = l ? 31 - Math.clz32(l & -l) : 63 - Math.clz32(h & -h);
509
530
  const attacker = kingColor === Color.White ? Color.Black : Color.White;
510
531
  // Inlined delegation: the attacker-set composition is exactly attackersTo
511
532
  // over the full occupancy (no intermediate SquareSet allocations here).
@@ -1,10 +1,3 @@
1
- import * as chess from "./chess.js";
2
- import type { Setup } from "./types.js";
3
- export { dests, allDests, isCheck, isCheckmate, isStalemate, perft, makeMove } from "./chess.js";
4
- export declare class Chess960 extends chess.Chess {
5
- static fromSetup(setup: Setup): Chess960;
6
- }
7
- export declare const isCheck960: typeof chess.isCheck;
8
- export declare const isCheckmate960: typeof chess.isCheckmate;
9
- export declare const perft960: typeof chess.perft;
1
+ export * from "./native96.js";
2
+ export { Chess as Chess960 } from "./nativeChess.js";
10
3
  //# sourceMappingURL=chess960.d.ts.map
@@ -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,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"}
1
+ {"version":3,"file":"chess960.d.ts","sourceRoot":"","sources":["../src/chess960.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/chess960.js CHANGED
@@ -1,18 +1,2 @@
1
- // src/chess960.ts — Chess960 (Fischer Random) support, X-FEN/Shredder dual
2
- // MIT gigachess, clean-room from specs + FIDE notes (no G P L)
3
- // Re-uses core chess.ts logic which already handles 960 castling via generic rook sets
4
- import * as chess from "./chess.js";
5
- export { dests, allDests, isCheck, isCheckmate, isStalemate, perft, makeMove } from "./chess.js";
6
- // Chess960 position is same as Setup but with chess960 flag handling for FEN
7
- // Provide helper to create Chess960 position with 960 castling parsing already done via fen.ts
8
- export class Chess960 extends chess.Chess {
9
- // Inherits all; ensure castling handling uses 960 rook sets already
10
- // Additional helper for 960-specific perft that matches python-chess with chess960=True
11
- static fromSetup(setup) {
12
- return new Chess960(setup);
13
- }
14
- }
15
- // Re-export isCheck etc with same semantics
16
- export const isCheck960 = chess.isCheck;
17
- export const isCheckmate960 = chess.isCheckmate;
18
- export const perft960 = chess.perft;
1
+ export * from "./native96.js";
2
+ export { Chess as Chess960 } from "./nativeChess.js";
package/dist/chessjs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Chess, INITIAL_FEN, type ColorName, type PieceChar, type VerboseMove, type HistoryEntry, } from "./chess.js";
1
+ export { Chess, INITIAL_FEN, type ColorName, type PieceChar, type VerboseMove, type HistoryEntry, } from "./nativeChess.js";
2
2
  export { Chess960 } from "./chess960.js";
3
3
  export declare const WHITE = "w";
4
4
  export declare const BLACK = "b";
@@ -1 +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"}
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,kBAAkB,CAAC;AAE1B,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/chessjs.ts — chess.js-compatible wrapper API for GigaChess
2
2
  // Optional drop-in wrapper mirroring chess.js API ergonomics over the native Board engine.
3
- export { Chess, INITIAL_FEN, } from "./chess.js";
3
+ export { Chess, INITIAL_FEN, } from "./nativeChess.js";
4
4
  export { Chess960 } from "./chess960.js";
5
5
  export const WHITE = "w";
6
6
  export const BLACK = "b";
@@ -1,4 +1,4 @@
1
- import * as engine from "../board.js";
1
+ import * as engine from "../setupBoard.js";
2
2
  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> {
@@ -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,SAAS,CAAC;IAErB,OAAO;IAIP,MAAM,CAA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AG,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"}
@@ -2,7 +2,7 @@
2
2
  // matches baseline (set/take/clear/reset mutate this instance); the wrapper
3
3
  // delegates to the immutable engine board, so caller-provided boards are
4
4
  // never mutated by engine operations.
5
- import * as engine from "../board.js";
5
+ import * as engine from "../setupBoard.js";
6
6
  import { Color as EColor } from "../types.js";
7
7
  import { INITIAL_FEN, engineBoardFromPlacement } from "./fenInternal.js";
8
8
  import { SquareSet } from "./squareSet.js";
@@ -1,9 +1,10 @@
1
1
  import { Result } from "./result.js";
2
- import type { Position as EnginePosition } from "../types.js";
3
2
  import { Board } from "./board.js";
4
3
  import { SquareSet } from "./squareSet.js";
5
4
  import type { Setup } from "./setup.js";
6
5
  import type { ByCastlingSide, ByColor, CastlingSide, Color, Move, Rules, Square } from "./types.js";
6
+ import type { Board96 } from "../nativeBoard96.js";
7
+ import { nativePosition } from "./nativeBridge.js";
7
8
  export declare enum IllegalSetup {
8
9
  Empty = "ERR_EMPTY",
9
10
  OppositeCheck = "ERR_OPPOSITE_CHECK",
@@ -42,19 +43,17 @@ export declare abstract class Position {
42
43
  remainingChecks: undefined;
43
44
  halfmoves: number;
44
45
  fullmoves: number;
45
- private _epos;
46
+ private _native;
46
47
  protected constructor(rules: Rules);
47
48
  reset(): void;
48
49
  protected setupUnchecked(setup: Setup): void;
49
- /** Lazily rebuilt engine position (rebuilt after every mutation). Built
50
- * directly from the raw fields — NOT via toSetup(), whose legalEpSquare
51
- * filter would recurse. The raw ep square is what baseline keeps on the
52
- * position too; the legal-ep filter only applies to toSetup(). */
53
- private epos;
54
50
  /** baseline keeps the RAW ep square on the position (toSetup() applies the
55
51
  * legalEpSquare filter); this internal view mirrors that. */
56
52
  private toSetupRaw;
57
53
  private invalidate;
54
+ /** Internal playable native projection. Public facade setters replace
55
+ * board._b; metadata identities/values invalidate the projection too. */
56
+ [nativePosition](): Board96 | null;
58
57
  toSetup(): Setup;
59
58
  /** baseline legalEpSquare: the ep square survives into a Setup only when a
60
59
  * legal ep capture exists. */
@@ -65,8 +64,6 @@ export declare abstract class Position {
65
64
  protected copyInto(target: Position): void;
66
65
  /** Internal: drop the cached engine position after any mutation. */
67
66
  dropCache(): void;
68
- /** Internal: engine position for sibling facade modules (san/fen/debug). */
69
- eposInternal(): EnginePosition;
70
67
  dropDests(_ctx?: Context): SquareSet;
71
68
  dests(square: Square, _ctx?: Context): SquareSet;
72
69
  isVariantEnd(): boolean;
@@ -86,7 +83,6 @@ export declare abstract class Position {
86
83
  } | undefined;
87
84
  allDests(_ctx?: Context): Map<Square, SquareSet>;
88
85
  play(move: Move): void;
89
- private castlesFromSets;
90
86
  }
91
87
  export declare class Chess extends Position {
92
88
  private constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"chess.d.ts","sourceRoot":"","sources":["../../src/chessops/chess.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAe,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO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