gigachess 0.2.1 → 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.
Files changed (53) hide show
  1. package/README.md +103 -108
  2. package/dist/attacks.d.ts +6 -3
  3. package/dist/attacks.d.ts.map +1 -1
  4. package/dist/attacks.js +45 -1
  5. package/dist/board.d.ts +111 -45
  6. package/dist/board.d.ts.map +1 -1
  7. package/dist/board.js +747 -14
  8. package/dist/castling.d.ts +41 -0
  9. package/dist/castling.d.ts.map +1 -0
  10. package/dist/castling.js +267 -0
  11. package/dist/chess.d.ts +30 -28
  12. package/dist/chess.d.ts.map +1 -1
  13. package/dist/chess.js +835 -458
  14. package/dist/chess960.d.ts +1 -1
  15. package/dist/chess960.d.ts.map +1 -1
  16. package/dist/chess960.js +2 -2
  17. package/dist/chessjs.d.ts +13 -0
  18. package/dist/chessjs.d.ts.map +1 -0
  19. package/dist/chessjs.js +23 -0
  20. package/dist/chessops/board.d.ts +1 -1
  21. package/dist/chessops/board.d.ts.map +1 -1
  22. package/dist/chessops/chess.js +1 -1
  23. package/dist/chessops/convert.d.ts +1 -1
  24. package/dist/chessops/convert.d.ts.map +1 -1
  25. package/dist/chessops/convert.js +1 -6
  26. package/dist/chessops/fenInternal.d.ts +1 -1
  27. package/dist/chessops/fenInternal.d.ts.map +1 -1
  28. package/dist/chessops/fenInternal.js +2 -2
  29. package/dist/chessops/index.js +2 -2
  30. package/dist/chessops/setup.js +1 -1
  31. package/dist/chessops/types.js +1 -1
  32. package/dist/chesstree.d.ts +1 -1
  33. package/dist/chesstree.d.ts.map +1 -1
  34. package/dist/chesstree.js +5 -5
  35. package/dist/core.d.ts +1 -1
  36. package/dist/core.d.ts.map +1 -1
  37. package/dist/core.js +2 -2
  38. package/dist/fen.d.ts.map +1 -1
  39. package/dist/fen.js +84 -48
  40. package/dist/index.d.ts +4 -3
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +7 -8
  43. package/dist/packedMove.js +2 -2
  44. package/dist/san.d.ts.map +1 -1
  45. package/dist/san.js +148 -172
  46. package/dist/squareSet.js +1 -1
  47. package/dist/types.d.ts +6 -1
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/zobrist.d.ts +22 -0
  50. package/dist/zobrist.d.ts.map +1 -1
  51. package/dist/zobrist.js +107 -36
  52. package/dist/zobristBlob.js +1 -1
  53. package/package.json +8 -6
package/README.md CHANGED
@@ -5,9 +5,8 @@
5
5
  <h1 align="center">GigaChess</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>The fastest chess engine in JavaScript.</strong><br>
9
- A 1-line drop-in upgrade for <code>chess.js</code> and <code>chessops</code> delivering 3.5x faster move validation,
10
- 120,000 games/sec PGN parsing, and interactive variation trees.
8
+ <strong>The fastest chess library and engine in TypeScript.</strong><br>
9
+ Built for high-performance web applications, interactive chessboards, and analysis engines.
11
10
  </p>
12
11
 
13
12
  <p align="center">
@@ -20,44 +19,24 @@
20
19
 
21
20
  ---
22
21
 
23
- ## ⚡ Why GigaChess?
22
+ ## ⚡ Highlights
24
23
 
25
- Until today, chess developers had to choose between two compromises:
26
- 1. **`chess.js`**: Intuitive API, but slow (array-based board scans, string allocations on every move, no bitboards, no variation trees).
27
- 2. **`chessops`**: Fast bitboards, but restrictive GPL licensing, functional-only syntax with no single class, and lack of variation trees or transposition hashing.
28
-
29
- **GigaChess eliminates this compromise.** It gives you:
30
- - 🚀 **3.5x Faster than `chess.js`** across all standard operations.
31
- - ⚡ **Up to 3.3x Faster than `chessops`** on real-world workstation workloads.
32
- - 🔄 **1-Line Drop-in Replacement** for `chess.js` (`import { Chess } from 'gigachess'`) and `chessops` (`import * as chessops from 'gigachess/chessops'`).
33
- - 🌳 **Built-in `chesstree` Variation Trees** (`game.toTree()` and `Chess.loadTree(pgn)`).
34
- - 🔑 **Instant $O(1)$ 64-bit Polyglot Zobrist Hashing** (`game.zobrist()`).
35
- - 📦 **16-bit Binary Move Streams (`moves2`)** (25x smaller memory footprint per game).
36
- - 📜 **100% Permissive MIT License** — completely free for commercial and proprietary software.
24
+ * 🚀 **45x Faster Move Execution**: In-place stateful `Board` executes moves at **5.98M moves/sec** (167 ns/op).
25
+ * 🏎️ **18.7M nodes/s Perft**: Stockfish-grade bitboard throughput in pure TypeScript.
26
+ * 🛡️ **100% Permissive MIT License**: Completely free for commercial and proprietary applications.
27
+ * 🔄 **1-Line `chess.js` Upgrade**: Drop-in wrapper via `gigachess/chessjs` with zero code changes.
28
+ * ♟️ **Full Chess & Chess960**: Complete support for standard chess, Fischer Random (960), FEN, SAN, and UCI.
29
+ * 🌲 **Study Trees & Fast PGN**: Interactive variation trees, comments, glyphs, and 128k games/sec PGN streaming.
30
+ * 🔑 **Instant Polyglot Zobrist Hashing**: Zero-allocation $O(1)$ 64-bit incremental hash matching Polyglot startpos.
31
+ * 📦 **16-bit Packed Move Streams (`moves2`)**: Compact 2-byte binary serialization replaying at **4.8M plies/sec**.
37
32
 
38
33
  ---
39
34
 
40
- ## 📊 Benchmark Comparison
41
-
42
- | Metric / Workload | 🚀 **GigaChess** | ♟️ **`chessops`** (0.15.1) | 📦 **`chess.js`** (1.4.0) | GigaChess Advantage |
43
- |---|---|---|---|---|
44
- | **License** | ✅ **100% MIT** | ❌ **GPL-3.0** | ✅ **BSD-2-Clause** | **Free for commercial use** |
45
- | **Sliding Piece Attacks** | **35.5 MAttacks/s** | 10.6 MAttacks/s | N/A *(array scan)* | **3.36x faster (+236%)** vs chessops |
46
- | **Perft Movegen Throughput** | **15.6 Million nodes/s** | 10.0 Million nodes/s | ❌ *(No perft API)* | **+56.4% faster** vs chessops |
47
- | **Chessground UI Dests** | **200,424 pos/s** | 58,000 pos/s | N/A | **3.32x faster (+232%)** vs chessops |
48
- | **FEN Parse + Make** | **285,000 ops/s** | 111,500 ops/s | 90,800 ops/s | **2.45x vs chessops \| 3.14x vs chess.js** |
49
- | **SAN Make + Legal Dests** | **24,727 ops/s** | 18,200 ops/s | 6,947 ops/s | **+36% vs chessops \| 3.56x vs chess.js** |
50
- | **PGN Game Streaming** | **118,000 games/s** (82 MB/s) | 47,000 games/s (33 MB/s) | 1,665 games/s (1.2 MB/s) | **2.51x vs chessops \| 3.05x vs chess.js** |
51
- | **Repertoire Tree Build** | **33,000 lines/s** | 20,400 lines/s | ❌ *(No Tree API)* | **+65.3% faster** vs chessops |
52
- | **Polyglot Zobrist ($O(1)$)** | ✅ **Native (`{lo,hi}`)** | ❌ None | ❌ None | **Zero-allocation transposition match** |
53
- | **16-bit Packed Moves (`moves2`)** | ✅ **Native (`Uint16Array`)** | ❌ None | ❌ None | **25x smaller memory (160 B/game)** |
54
- | **Bundle Size (gzipped)** | **17.5 KB gz** | 28.0 KB gz *(full)* | **12.6 KB gz** | **Complete workstation in 17 KB** |
55
-
56
- *Benchmarks measured on Node.js v22 on Apple Silicon (M-series). Run locally via `npm run bench:real`.*
35
+ > 💡 **100% Pure TypeScript with Zero Dependencies**: GigaChess requires no native C++ binaries, node-gyp, or WebAssembly. It runs seamlessly in modern browsers, Node.js, Bun, Deno, and edge workers.
57
36
 
58
37
  ---
59
38
 
60
- ## 🛠️ Installation
39
+ ## 📦 Installation
61
40
 
62
41
  ```bash
63
42
  npm install gigachess
@@ -65,116 +44,132 @@ npm install gigachess
65
44
 
66
45
  ---
67
46
 
68
- ## 🏎️ 1-Line Drop-in Migrations
47
+ ## 🚀 Quick Start
69
48
 
70
- ### From `chess.js`
71
- Replace your import statement. Every method, property, and type signature works out of the box with an instant 3.5x speed boost:
72
49
  ```ts
73
- // Before:
74
- // import { Chess } from 'chess.js';
50
+ import { Board } from "gigachess";
75
51
 
76
- // After:
77
- import { Chess } from 'gigachess';
52
+ // Initialize starting position
53
+ const board = new Board();
78
54
 
79
- const chess = new Chess();
80
- chess.move('e4');
81
- chess.move('e5');
82
- console.log(chess.fen()); // 'rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2'
83
- console.log(chess.history()); // ['e4', 'e5']
84
- ```
55
+ // Parse SAN and execute move in 167 ns
56
+ const move = board.parseSan("e4");
57
+ const undo = board.makeMove(move);
85
58
 
86
- ### From `chessops`
87
- Import the high-performance compatibility module with exact API shape and 100% MIT license:
88
- ```ts
89
- // Before:
90
- // import { Chess } from 'chessops/chess';
91
- // import { parseFen } from 'chessops/fen';
59
+ console.log(board.toFen()); // 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1'
60
+ console.log(board.inCheck()); // false
92
61
 
93
- // After:
94
- import { Chess } from 'gigachess/chessops/chess';
95
- import { parseFen } from 'gigachess/chessops/fen';
62
+ // Instant O(1) reversible unmake
63
+ board.unmakeMove(undo);
64
+ console.log(board.toFen()); // startpos restored
96
65
  ```
97
66
 
98
67
  ---
99
68
 
100
- ## 💡 Quick Examples
69
+ ## 📊 GigaChess vs `chess.js`
70
+
71
+ Measured under Node.js v24 on Apple Silicon:
72
+
73
+ | Feature / Benchmark | 🚀 **GigaChess** | 📦 **`chess.js`** (1.4.0) | Advantage |
74
+ |---|---|---|---|
75
+ | **Move Execution (`make` + `unmake`)** | **5,986,400 ops/s** (167 ns) | 134,500 ops/s (7,434 ns) | **44.5x faster (+4,350%)** |
76
+ | **Legal Move Generation** | **541,200 pos/s** (1,848 ns) | 49,200 pos/s (20,341 ns) | **11.0x faster (+1,001%)** |
77
+ | **Perft Movegen (Depth Search)** | **18,678,516 nodes/s** | ~500,000 nodes/s | **37x faster** |
78
+ | **Game Stream Replay** | **4,803,000 plies/s** | 649,000 plies/s | **7.4x faster (+640%)** |
79
+ | **Check & Status Query (`inCheck`)** | **4.9 ns** (203M ops/s) | 26.3 ns (38M ops/s) | **5.3x faster (+434%)** |
80
+ | **PGN Parsing & Streaming** | **128,701 games/s** (89 MB/s) | 3,634 games/s (2.5 MB/s) | **35.4x faster (+3,440%)** |
81
+ | **SAN Move Validation & Make** | **49,444 ops/s** | 6,992 ops/s | **7.07x faster (+607%)** |
82
+ | **FEN Parsing & Setup** | **458,961 ops/s** | 91,214 ops/s | **5.03x faster (+403%)** |
83
+ | **Memory per 80-Ply Game** | **160 Bytes** (`Uint16Array`) | ~4,200 Bytes (Heap Objects) | **26x less memory** |
84
+ | **64-bit Polyglot Zobrist Hash** | ✅ **Built-in ($O(1)$ incremental)** | ❌ None | **Transposition & repetition** |
85
+ | **Variation Trees & Analysis** | ✅ **Built-in (`chesstree`)** | ❌ None | **Branching, comments, glyphs** |
86
+ | **Chess960 (Fischer Random)** | ✅ **Full 960 support** | ⚠️ Partial / legacy bugs | **Full standard & Chess960** |
101
87
 
102
- ### 1. Ultra-Fast Chessground UI Legal Moves
103
- Generate legal move dots for `@lichess-org/chessground` or any UI chessboard in microseconds:
104
- ```ts
105
- import { Chess } from 'gigachess';
88
+ ---
106
89
 
107
- const game = new Chess();
90
+ ## 🔄 Drop-in `chess.js` Compatibility
108
91
 
109
- // Legal destinations map for every piece on the board: Map<fromSquare, SquareSet>
110
- const allDests = game.allDests();
92
+ Existing `chess.js` code can be upgraded in 1 line with zero refactoring:
93
+
94
+ ```ts
95
+ // Simply replace your import:
96
+ // import { Chess } from "chess.js";
97
+ import { Chess } from "gigachess/chessjs";
111
98
 
112
- // Or for a single square:
113
- const e2Dests = game.dests('e2');
99
+ const chess = new Chess();
100
+ chess.move("e4");
101
+ chess.move("e5");
102
+ console.log(chess.fen()); // 'rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2'
103
+ console.log(chess.history()); // ['e4', 'e5']
114
104
  ```
115
105
 
116
- ### 2. Variation Trees & PGN Analysis (`toTree` & `loadTree`)
117
- Full recursive variation tree navigation and PGN export built right in:
106
+ ---
107
+
108
+ ## 💡 Common Recipes
109
+
110
+ ### 1. Legal Move Generation
118
111
  ```ts
119
- import { Chess } from 'gigachess';
112
+ import { Board } from "gigachess";
120
113
 
121
- // 1. Export live game to an interactive variation tree:
122
- const game = new Chess();
123
- game.move('e4');
124
- game.move('e5');
125
- game.move('Nf3');
114
+ const board = new Board();
126
115
 
127
- const tree = game.toTree();
128
- tree.setCommentAt([1], 'Open Game');
129
- console.log(tree.pgn());
116
+ // Iterate without array allocation:
117
+ board.forEachLegalMove((move) => {
118
+ console.log(board.toSan(move));
119
+ });
130
120
 
131
- // 2. Load annotated PGN with branching variations:
132
- const treeWrapper = Chess.loadTree(`1. e4 e5 (1... c5 2. Nf3) 2. Nf3 Nc6`);
133
- const root = treeWrapper.getRoot();
121
+ // Or write into a reusable buffer (541k pos/s):
122
+ const buffer = new Uint16Array(256);
123
+ const count = board.legalMoves(buffer);
134
124
  ```
135
125
 
136
- ### 3. $O(1)$ 64-bit Polyglot Zobrist Hashing
137
- Instant position fingerprinting for opening books, transpositions, and repetitions:
126
+ ### 2. Game State & Terminal Checks
138
127
  ```ts
139
- import { Chess } from 'gigachess';
128
+ const board = new Board();
129
+
130
+ board.inCheck(); // false
131
+ board.isCheckmate(); // false
132
+ board.isStalemate(); // false
133
+ board.isDraw(); // false
134
+ board.isInsufficientMaterial();// false
135
+ board.turn; // 0 = White, 1 = Black
136
+ ```
140
137
 
141
- const game = new Chess();
142
- game.move('e4');
138
+ ### 3. Incremental Polyglot Zobrist Hashing
139
+ ```ts
140
+ const board = new Board();
143
141
 
144
- const key = game.zobrist(); // { lo: 0x823c9b50, hi: 0xfd114196 }
145
- console.log(game.zobristHex()); // "823c9b50fd114196"
142
+ // Fast 64-bit Polyglot key updated in O(1) during moves:
143
+ const hash = board.zobrist(); // { lo: number, hi: number }
144
+ console.log(board.zobristHex()); // "463b96181691fc9c"
146
145
  ```
147
146
 
148
- ### 4. 16-bit Packed Move Streams (`moves2`)
149
- Compress entire game databases down to 2 bytes per ply:
147
+ ### 4. Chess960 (Fischer Random)
150
148
  ```ts
151
- import { Chess } from 'gigachess';
149
+ import { Board } from "gigachess";
152
150
 
153
- const game = new Chess();
154
- game.move('e4');
155
- game.move('c5');
156
- game.move('Nf3');
151
+ // Load any of the 960 starting positions:
152
+ const board = Board.fromFen("rnqbbknr/pppppppp/8/8/8/8/PPPPPPPP/RNQBBKNR w KQkq - 0 1");
153
+ console.log(board.toFen());
154
+ ```
157
155
 
158
- // Serialize history into raw Uint16Array (6 bytes total):
159
- const buffer = game.toMoves2();
156
+ ### 5. Binary Move Stream Replay (`moves2`)
157
+ ```ts
158
+ import { Board } from "gigachess";
160
159
 
161
- // Instant binary replay:
162
- const replayedGame = Chess.fromMoves2(buffer);
163
- console.log(replayedGame.fen() === game.fen()); // true
160
+ // Replay full games at 4.8M plies/s from compact 16-bit buffers:
161
+ const moves = new Uint16Array([ /* packed 16-bit moves */ ]);
162
+ const board = Board.fromMoves2(moves);
164
163
  ```
165
164
 
166
165
  ---
167
166
 
168
- ## 🔬 How is GigaChess so Fast?
169
-
170
- GigaChess incorporates the same hardware-efficient architectural principles found in Stockfish and modern master engines:
167
+ ## 🔬 Under the Hood: Why GigaChess is Fast
171
168
 
172
- 1. **Zero-BigInt 32-bit Pair Bitboards (`{ lo, hi }`)**: JavaScript V8 optimizes 32-bit unsigned integers into native CPU registers. BigInt forces heap boxing and garbage collector churn. All bitboards in GigaChess are split into low/high 32-bit unsigned integers.
173
- 2. **Precomputed $64 \times 64$ Flat Ray & Between Tables**: Single-cycle `Uint32Array(4096)` array index lookups replace dynamic loops during pin and check resolution.
174
- 3. **Stockfish `CheckContext` (Single-Pass Pin Analysis)**: Pins, check rays, and king-safe destination masks are analyzed **once per position**, turning move validation into fast bitwise intersections ($\text{Pseudo} \cap \text{CheckMask} \cap \text{PinRay}$).
175
- 4. **Black Magic Sliding Bitboards**: $O(1)$ Bishop, Rook, and Queen ray generation delivering over **35.5 Million attacks/sec**.
176
- 5. **Incremental Zobrist XORs**: Hashing updates in $O(1)$ per move rather than rescanning the 64 squares.
177
- 6. **Perft Leaf Popcounting**: Depth-1 node counting skips all JavaScript move object allocations.
169
+ 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.
170
+ 2. **Zero-BigInt 32-bit Integer Pairs**: 64-bit `BigInt` forces object allocation on the heap. GigaChess executes all bitboards as 32-bit unsigned integer pairs (`lo >>> 0`, `hi >>> 0`), running directly in CPU registers.
171
+ 3. **Stockfish Single-Pass Pin Analysis (`CheckContext`)**: Checkers and pin lines are computed once per position, turning legal move validation into fast bitwise intersections.
172
+ 4. **16-bit Unboxed Small Integers (Smis)**: Packed moves are stored as 16-bit integers, bypassing garbage collection pauses.
178
173
 
179
174
  ---
180
175
 
package/dist/attacks.d.ts CHANGED
@@ -25,15 +25,18 @@ export declare const _naive: {
25
25
  };
26
26
  export declare function ray(from: number, to: number): SquareSet;
27
27
  export declare function between(from: number, to: number): SquareSet;
28
+ export declare const LINE_RAY_LO: Uint32Array<ArrayBuffer>;
29
+ export declare const LINE_RAY_HI: Uint32Array<ArrayBuffer>;
30
+ export declare function lineRay(from: number, to: number): SquareSet;
28
31
  /**
29
32
  * All pieces of `attacker` color attacking `square`. `occ` overrides the
30
33
  * occupancy used for slider rays (hot-loop variant: king-safety masks
31
34
  * evaluate attackedness with the moving king removed from the occupancy so
32
35
  * that sliders x-raying the king stay "attacking" through its old square).
33
36
  */
34
- export declare function attackersTo(board: import("./board.js").Board, square: number, attacker: Color, occ?: SquareSet): SquareSet;
35
- export declare function isAttacked(board: import("./board.js").Board, square: number, attacker: Color): boolean;
36
- export declare function kingAttackers(board: import("./board.js").Board, kingColor: Color): SquareSet;
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;
39
+ export declare function kingAttackers(board: import("./board.js").BoardLike, kingColor: Color): SquareSet;
37
40
  export declare function rookAttacksForTest(sqIdx: number, occ: SquareSet): SquareSet;
38
41
  export declare function bishopAttacksForTest(sqIdx: number, occ: SquareSet): SquareSet;
39
42
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":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dist/attacks.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/attacks.ts — leaper tables + fancy per-square Black Magic sliding
2
2
  // (lazily loaded from generated base64 blobs) via bench/magic-tables
3
- // MIT turbochess, clean-room from specs + FIDE notes (no G P L)
3
+ // MIT gigachess, clean-room from specs + FIDE notes (no G P L)
4
4
  import * as sq from "./squareSet.js";
5
5
  import { Color } from "./types.js";
6
6
  import { squareFile, squareRank } from "./util.js";
@@ -305,6 +305,50 @@ export function between(from, to) {
305
305
  const idx = ((from & 63) << 6) | (to & 63);
306
306
  return { lo: BETWEEN_LO[idx], hi: BETWEEN_HI[idx] };
307
307
  }
308
+ export const LINE_RAY_LO = new Uint32Array(4096);
309
+ export const LINE_RAY_HI = new Uint32Array(4096);
310
+ for (let i = 0; i < 64; i++) {
311
+ const f1 = i & 7, r1 = i >> 3;
312
+ for (let j = 0; j < 64; j++) {
313
+ if (i === j)
314
+ continue;
315
+ const f2 = j & 7, r2 = j >> 3;
316
+ const df = f2 - f1, dr = r2 - r1;
317
+ if (df !== 0 && dr !== 0 && Math.abs(df) !== Math.abs(dr))
318
+ continue;
319
+ const stepF = df === 0 ? 0 : df > 0 ? 1 : -1;
320
+ const stepR = dr === 0 ? 0 : dr > 0 ? 1 : -1;
321
+ let lo = 0, hi = 0;
322
+ let f = f1, r = r1;
323
+ while (f >= 0 && f < 8 && r >= 0 && r < 8) {
324
+ const s = (r << 3) | f;
325
+ if (s < 32)
326
+ lo |= (1 << s) >>> 0;
327
+ else
328
+ hi |= (1 << (s - 32)) >>> 0;
329
+ f += stepF;
330
+ r += stepR;
331
+ }
332
+ f = f1 - stepF;
333
+ r = r1 - stepR;
334
+ while (f >= 0 && f < 8 && r >= 0 && r < 8) {
335
+ const s = (r << 3) | f;
336
+ if (s < 32)
337
+ lo |= (1 << s) >>> 0;
338
+ else
339
+ hi |= (1 << (s - 32)) >>> 0;
340
+ f -= stepF;
341
+ r -= stepR;
342
+ }
343
+ const idx = (i << 6) | j;
344
+ LINE_RAY_LO[idx] = lo >>> 0;
345
+ LINE_RAY_HI[idx] = hi >>> 0;
346
+ }
347
+ }
348
+ export function lineRay(from, to) {
349
+ const idx = ((from & 63) << 6) | (to & 63);
350
+ return { lo: LINE_RAY_LO[idx], hi: LINE_RAY_HI[idx] };
351
+ }
308
352
  // ---------- isAttacked / kingAttackers ----------
309
353
  /**
310
354
  * All pieces of `attacker` color attacking `square`. `occ` overrides the
package/dist/board.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import type { SquareSet } from "./squareSet.js";
1
+ import type { SquareSet, MutableSquareSet } from "./squareSet.js";
2
2
  import * as sq from "./squareSet.js";
3
3
  import { Color, Role } from "./types.js";
4
- export type Board = {
4
+ import type { Position, Move, CastlingRights } from "./types.js";
5
+ import type { ZobristKey } from "./zobrist.js";
6
+ import type { CastlingPlan } from "./castling.js";
7
+ export type BoardLike = {
5
8
  readonly white: SquareSet;
6
9
  readonly black: SquareSet;
7
10
  readonly pawn: SquareSet;
@@ -12,62 +15,125 @@ export type Board = {
12
15
  readonly king: SquareSet;
13
16
  readonly occupied: SquareSet;
14
17
  readonly promoted: SquareSet;
18
+ readonly kingSq?: readonly [number, number];
15
19
  };
16
- export declare function emptyBoard(): Board;
17
- export declare function cloneBoard(board: Board): Board;
18
- /**
19
- * Pure Board construction helpers.
20
- *
21
- * Contract (per purechess-board-movegen spec): Board is an immutable value —
22
- * every public op takes a Board and returns a NEW Board; the input is never
23
- * mutated. The *implementation* uses the spec-sanctioned clone→mutate-clone
24
- * technique via `WritableBoard` (see below), which keeps types honest without
25
- * `as any` casts.
26
- */
27
- /**
28
- * Writable view of a Board. HOT-LOOP-ONLY escape hatch, per the FP policy:
29
- * in-place board mutation is permitted exclusively inside leaf functions that
30
- * own a private scratch buffer (legality testing, move application) where
31
- * allocation churn dominates. Rules:
32
- * 1. A WritableBoard must NEVER escape the function that created/borrowed it.
33
- * 2. While a borrowed scratch is live, only leaf helpers may be called
34
- * (SquareSet ops, attacks lookups) — nothing that re-enters movegen.
35
- * 3. Public APIs must keep the observable pure contract: inputs unmodified.
36
- *
37
- * Unlike Board, a WritableBoard's field objects are MUTABLE bitfields
38
- * (MutableSquareSet): the owning scratch copies bits in place instead of
39
- * allocating fresh {lo,hi} objects per edit. This is sound because the scratch
40
- * objects never alias any Board's (immutable) field objects — see
41
- * newScratchBoard/copyBoardInto — and never escape rule 1.
42
- */
20
+ export type Undo = {
21
+ readonly move: number;
22
+ readonly movingRole: Role;
23
+ readonly capturedRole: Role | -1;
24
+ readonly capturedSq: number;
25
+ readonly castlingPlan: CastlingPlan | null;
26
+ readonly isEnPassant: boolean;
27
+ readonly promoRole: Role | null;
28
+ readonly epSquare: number | null;
29
+ readonly castling: CastlingRights;
30
+ readonly castlingMask?: number;
31
+ readonly halfmoves: number;
32
+ readonly fullmoves: number;
33
+ readonly kingSq: readonly [number, number];
34
+ readonly checkers: SquareSet;
35
+ readonly zobristLo: number;
36
+ readonly zobristHi: number;
37
+ };
38
+ export declare class Board implements BoardLike {
39
+ white: MutableSquareSet;
40
+ black: MutableSquareSet;
41
+ pawn: MutableSquareSet;
42
+ knight: MutableSquareSet;
43
+ bishop: MutableSquareSet;
44
+ rook: MutableSquareSet;
45
+ queen: MutableSquareSet;
46
+ king: MutableSquareSet;
47
+ occupied: MutableSquareSet;
48
+ promoted: MutableSquareSet;
49
+ kingSq: [number, number];
50
+ turn: Color;
51
+ castling: CastlingRights;
52
+ castlingMask?: number;
53
+ epSquare: number | null;
54
+ halfmoves: number;
55
+ fullmoves: number;
56
+ checkers: SquareSet;
57
+ isChess960: boolean;
58
+ _zobristLo: number;
59
+ _zobristHi: number;
60
+ constructor(input?: string | Position | Board | BoardLike);
61
+ static startpos(): Board;
62
+ static empty(): Board;
63
+ static fromFen(fen: string): Board;
64
+ static fromMoves2(buffer: Uint16Array | Uint8Array, startFen?: string, isChess960?: boolean): Board;
65
+ get board(): Board;
66
+ get pos(): Position;
67
+ toPosition(): Position;
68
+ get halfmove(): number;
69
+ get fullmove(): number;
70
+ get zobristLo(): number;
71
+ get zobristHi(): number;
72
+ zobrist(): ZobristKey;
73
+ zobristBigInt(): bigint;
74
+ zobristHex(): string;
75
+ inCheck(): boolean;
76
+ private refreshZobrist;
77
+ clear(): this;
78
+ loadFen(fen: string): void;
79
+ copyFrom(src: Position | Board | BoardLike): this;
80
+ clone(): Board;
81
+ roleAt(sqIdx: number): Role | undefined;
82
+ colorAt(sqIdx: number): Color | undefined;
83
+ pieceAt(sqIdx: number): {
84
+ color: Color;
85
+ role: Role;
86
+ } | undefined;
87
+ hasPiece(sqIdx: number): boolean;
88
+ kingSquare(color: Color): number | undefined;
89
+ private _clearSquare;
90
+ private _putPiece;
91
+ makeMove(moveWord: number | Move): Undo;
92
+ unmakeMove(undo: Undo): void;
93
+ legalMoves(outBuffer?: Uint16Array): Uint16Array;
94
+ forEachLegalMove(fn: (moveWord: number) => void): void;
95
+ toSan(moveWord: number): string;
96
+ toUci(moveWord: number): string;
97
+ toFen(): string;
98
+ parseSan(san: string): number | null;
99
+ parseUci(uci: string): number | null;
100
+ perft(depth: number): number;
101
+ }
43
102
  export type WritableBoard = {
44
- [K in keyof Board]: sq.MutableSquareSet;
103
+ white: sq.MutableSquareSet;
104
+ black: sq.MutableSquareSet;
105
+ pawn: sq.MutableSquareSet;
106
+ knight: sq.MutableSquareSet;
107
+ bishop: sq.MutableSquareSet;
108
+ rook: sq.MutableSquareSet;
109
+ queen: sq.MutableSquareSet;
110
+ king: sq.MutableSquareSet;
111
+ occupied: sq.MutableSquareSet;
112
+ promoted: sq.MutableSquareSet;
113
+ kingSq: [number, number];
45
114
  };
115
+ export declare function emptyBoard(): BoardLike;
116
+ export declare function cloneBoard(board: BoardLike): BoardLike;
46
117
  export declare function newScratchBoard(): WritableBoard;
47
- export declare function cloneAsWritable(board: Board): WritableBoard;
48
- /** Copy `src`'s ten fields into `dst`. Zero-allocation: the scratch owns its
49
- * field objects, so only the 64-bit values are assigned (no {lo,hi} churn). */
50
- export declare function copyBoardInto(dst: WritableBoard, src: Board): void;
51
- /** In-place: remove the piece (any color/role) at sqIdx. Hot-loop only.
52
- * Zero-allocation: raw bitmasks instead of sq.not/singleton/and objects. */
118
+ export declare function cloneAsWritable(board: BoardLike): WritableBoard;
119
+ export declare function copyBoardInto(dst: WritableBoard, src: BoardLike): void;
53
120
  export declare function clearSquareInPlace(b: WritableBoard, sqIdx: number): void;
54
- /** In-place: place a piece at sqIdx. Hot-loop only. Zero-allocation. */
55
121
  export declare function putPieceInPlace(b: WritableBoard, sqIdx: number, piece: {
56
122
  color: Color;
57
123
  role: Role;
58
124
  }): void;
59
- export declare function setPiece(board: Board, sqIdx: number, piece: {
125
+ export declare function setPiece(board: BoardLike, sqIdx: number, piece: {
60
126
  color: Color;
61
127
  role: Role;
62
128
  }): Board;
63
- export declare function removePiece(board: Board, sqIdx: number): Board;
64
- export declare function pieceAt(board: Board, sqIdx: number): {
129
+ export declare function removePiece(board: BoardLike, sqIdx: number): Board;
130
+ export declare function pieceAt(board: BoardLike, sqIdx: number): {
65
131
  color: Color;
66
132
  role: Role;
67
133
  } | undefined;
68
- export declare function hasPiece(board: Board, sqIdx: number): boolean;
69
- export declare function kingSquare(board: Board, color: Color): number | undefined;
70
- export declare function occupiedEqualsWhiteBlack(board: Board): boolean;
71
- export declare function rolePartitionEqualsOccupied(board: Board): boolean;
72
- export declare function boardEquals(a: Board, b: Board): boolean;
134
+ export declare function hasPiece(board: BoardLike, sqIdx: number): boolean;
135
+ export declare function kingSquare(board: BoardLike, color: Color): number | undefined;
136
+ export declare function occupiedEqualsWhiteBlack(board: BoardLike): boolean;
137
+ export declare function rolePartitionEqualsOccupied(board: BoardLike): boolean;
138
+ export declare function boardEquals(a: BoardLike, b: BoardLike): boolean;
73
139
  //# sourceMappingURL=board.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../src/board.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MA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