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.
Files changed (49) hide show
  1. package/README.md +102 -125
  2. package/dist/attacks.d.ts +3 -3
  3. package/dist/attacks.d.ts.map +1 -1
  4. package/dist/attacks.js +1 -1
  5. package/dist/board.d.ts +99 -44
  6. package/dist/board.d.ts.map +1 -1
  7. package/dist/board.js +726 -15
  8. package/dist/castling.d.ts +11 -1
  9. package/dist/castling.d.ts.map +1 -1
  10. package/dist/castling.js +122 -0
  11. package/dist/chess.d.ts +11 -23
  12. package/dist/chess.d.ts.map +1 -1
  13. package/dist/chess.js +81 -178
  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/fenInternal.d.ts +1 -1
  26. package/dist/chessops/fenInternal.d.ts.map +1 -1
  27. package/dist/chessops/fenInternal.js +2 -2
  28. package/dist/chessops/index.js +2 -2
  29. package/dist/chessops/setup.js +1 -1
  30. package/dist/chessops/types.js +1 -1
  31. package/dist/chesstree.d.ts +1 -1
  32. package/dist/chesstree.d.ts.map +1 -1
  33. package/dist/chesstree.js +5 -5
  34. package/dist/core.d.ts +1 -1
  35. package/dist/core.d.ts.map +1 -1
  36. package/dist/core.js +2 -2
  37. package/dist/fen.js +1 -1
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +4 -6
  41. package/dist/packedMove.js +1 -1
  42. package/dist/squareSet.js +1 -1
  43. package/dist/types.d.ts +1 -1
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/zobrist.d.ts +22 -0
  46. package/dist/zobrist.d.ts.map +1 -1
  47. package/dist/zobrist.js +89 -33
  48. package/dist/zobristBlob.js +1 -1
  49. package/package.json +5 -5
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 up to 7.4x faster move validation,
10
- 18.5M nodes/s perft throughput, 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,47 +19,24 @@
20
19
 
21
20
  ---
22
21
 
23
- > 🦀 **Looking for maximum native backend performance?** Check out [**`gigachess` (Rust)**](https://github.com/itshak/gigachess-rs) — the fastest chess move generator in Rust, featuring 540M nodes/sec perft throughput, hardware PEXT / Fancy Magic bitboards, 16-bit binary replay (1.4M games/sec), and zero heap allocations for database workstations and search engines. Available on [crates.io](https://crates.io/crates/gigachess).
22
+ ## ⚡ Highlights
24
23
 
25
- ## ⚡ Why GigaChess?
26
-
27
- Until today, chess developers had to choose between two compromises:
28
- 1. **`chess.js`**: Intuitive API, but slow (array-based board scans, string allocations on every move, no bitboards, no variation trees).
29
- 2. **`chessops`**: Fast bitboards, but restrictive GPL licensing, functional-only syntax with no single class, and lack of variation trees or transposition hashing.
30
-
31
- **GigaChess eliminates this compromise.** It gives you:
32
- - 🚀 **Up to 7.4x Faster than `chess.js`** on SAN move generation and 7.0x on PGN streaming.
33
- - ⚡ **Up to 3.8x Faster than `chessops`** on real-world workstation workloads (`chessground` dests).
34
- - 🏎️ **3.8x–5.3x Faster Movegen than Rust/WASM** (`ultrachess`) due to zero boundary serialization overhead.
35
- - 🔄 **1-Line Drop-in Replacement** for `chess.js` (`import { Chess } from 'gigachess'`) and `chessops` (`import * as chessops from 'gigachess/chessops'`).
36
- - 🌳 **Built-in `chesstree` Variation Trees** (`game.toTree()` and `Chess.loadTree(pgn)`).
37
- - 🔑 **Instant $O(1)$ 64-bit Polyglot Zobrist Hashing** (`game.zobrist()`).
38
- - 📦 **16-bit Binary Move Streams (`moves2`)** (25x smaller memory footprint per game).
39
- - 📜 **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**.
40
32
 
41
33
  ---
42
34
 
43
- ## 📊 Benchmark Comparison
44
-
45
- | Metric / Workload | 🚀 **GigaChess** | ♟️ **`chessops`** (0.15.1) | 📦 **`chess.js`** (1.4.0) | GigaChess Advantage |
46
- |---|---|---|---|---|
47
- | **License** | ✅ **100% MIT** | ❌ **GPL-3.0** | ✅ **BSD-2-Clause** | **Free for commercial use** |
48
- | **Sliding Piece Attacks** | **35.5 MAttacks/s** | 10.6 MAttacks/s | N/A *(array scan)* | **3.36x faster (+236%)** vs chessops |
49
- | **Perft Movegen Throughput** | **18.5 Million nodes/s** | 8.5 Million nodes/s | ❌ *(No perft API)* | **2.17x faster (+117%)** vs chessops |
50
- | **Chessground UI Dests** | **212,675 pos/s** | 56,000 pos/s | N/A | **3.80x faster (+280%)** vs chessops |
51
- | **FEN Parse + Make** | **285,000 ops/s** | 125,000 ops/s | 94,000 ops/s | **2.26x vs chessops \| 3.03x vs chess.js** |
52
- | **SAN Make + Legal Dests** | **51,700 ops/s** | 18,200 ops/s | 6,947 ops/s | **2.84x vs chessops \| 7.44x vs chess.js** |
53
- | **PGN Game Streaming** | **120,000 games/s** (84 MB/s) | 41,500 games/s (29 MB/s) | 1,710 games/s (1.2 MB/s) | **2.89x vs chessops \| 7.01x vs chess.js** |
54
- | **Repertoire Tree Build** | **37,200 lines/s** | 20,400 lines/s | ❌ *(No Tree API)* | **1.84x faster (+84%)** vs chessops |
55
- | **isCheck Detection** | **0.5 ns / op** (2.1B ops/s) | 14.5 ns / op | 85.0 ns / op | **29x vs chessops \| 170x vs chess.js** |
56
- | **Polyglot Zobrist ($O(1)$)** | ✅ **Native (`{lo,hi}`)** | ❌ None | ❌ None | **Zero-allocation transposition match** |
57
- | **16-bit Packed Moves (`moves2`)** | ✅ **Native (`Uint16Array`)** | ❌ None | ❌ None | **25x smaller memory (160 B/game)** |
58
-
59
- *Benchmarks measured on Node.js v24 on Apple Silicon. Run locally via `node --expose-gc bench/bench-real.mjs`.*
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.
60
36
 
61
37
  ---
62
38
 
63
- ## 🛠️ Installation
39
+ ## 📦 Installation
64
40
 
65
41
  ```bash
66
42
  npm install gigachess
@@ -68,131 +44,132 @@ npm install gigachess
68
44
 
69
45
  ---
70
46
 
71
- ## 🏎️ 1-Line Drop-in Migrations
47
+ ## 🚀 Quick Start
72
48
 
73
- ### From `chess.js`
74
- Replace your import statement. Every method, property, and type signature works out of the box with up to 7.4x faster move validation:
75
49
  ```ts
76
- // Before:
77
- // import { Chess } from 'chess.js';
50
+ import { Board } from "gigachess";
78
51
 
79
- // After:
80
- import { Chess } from 'gigachess';
52
+ // Initialize starting position
53
+ const board = new Board();
81
54
 
82
- const chess = new Chess();
83
- chess.move('e4');
84
- chess.move('e5');
85
- console.log(chess.fen()); // 'rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2'
86
- console.log(chess.history()); // ['e4', 'e5']
87
- ```
55
+ // Parse SAN and execute move in 167 ns
56
+ const move = board.parseSan("e4");
57
+ const undo = board.makeMove(move);
88
58
 
89
- ### From `chessops`
90
- Import the high-performance compatibility module with exact API shape and 100% MIT license:
91
- ```ts
92
- // Before:
93
- // import { Chess } from 'chessops/chess';
94
- // 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
95
61
 
96
- // After:
97
- import { Chess } from 'gigachess/chessops/chess';
98
- import { parseFen } from 'gigachess/chessops/fen';
62
+ // Instant O(1) reversible unmake
63
+ board.unmakeMove(undo);
64
+ console.log(board.toFen()); // startpos restored
99
65
  ```
100
66
 
101
67
  ---
102
68
 
103
- ## 💡 Quick Examples
69
+ ## 📊 GigaChess vs `chess.js`
104
70
 
105
- ### 1. Ultra-Fast Chessground UI Legal Moves
106
- Generate legal move dots for `@lichess-org/chessground` or any UI chessboard in microseconds:
107
- ```ts
108
- import { Chess } from 'gigachess';
71
+ Measured under Node.js v24 on Apple Silicon:
109
72
 
110
- const game = new Chess();
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** |
111
87
 
112
- // Legal destinations map for every piece on the board: Map<fromSquare, SquareSet>
113
- const allDests = game.allDests();
88
+ ---
114
89
 
115
- // Or for a single square:
116
- const e2Dests = game.dests('e2');
117
- ```
90
+ ## 🔄 Drop-in `chess.js` Compatibility
91
+
92
+ Existing `chess.js` code can be upgraded in 1 line with zero refactoring:
118
93
 
119
- ### 2. Variation Trees & PGN Analysis (`toTree` & `loadTree`)
120
- Full recursive variation tree navigation and PGN export built right in:
121
94
  ```ts
122
- import { Chess } from 'gigachess';
95
+ // Simply replace your import:
96
+ // import { Chess } from "chess.js";
97
+ import { Chess } from "gigachess/chessjs";
123
98
 
124
- // 1. Export live game to an interactive variation tree:
125
- const game = new Chess();
126
- game.move('e4');
127
- game.move('e5');
128
- game.move('Nf3');
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']
104
+ ```
129
105
 
130
- const tree = game.toTree();
131
- tree.setCommentAt([1], 'Open Game');
132
- console.log(tree.pgn());
106
+ ---
133
107
 
134
- // 2. Load annotated PGN with branching variations:
135
- const treeWrapper = Chess.loadTree(`1. e4 e5 (1... c5 2. Nf3) 2. Nf3 Nc6`);
136
- const root = treeWrapper.getRoot();
137
- ```
108
+ ## 💡 Common Recipes
138
109
 
139
- ### 3. $O(1)$ 64-bit Polyglot Zobrist Hashing
140
- Instant position fingerprinting for opening books, transpositions, and repetitions:
110
+ ### 1. Legal Move Generation
141
111
  ```ts
142
- import { Chess } from 'gigachess';
112
+ import { Board } from "gigachess";
113
+
114
+ const board = new Board();
143
115
 
144
- const game = new Chess();
145
- game.move('e4');
116
+ // Iterate without array allocation:
117
+ board.forEachLegalMove((move) => {
118
+ console.log(board.toSan(move));
119
+ });
146
120
 
147
- const key = game.zobrist(); // { lo: 0x823c9b50, hi: 0xfd114196 }
148
- console.log(game.zobristHex()); // "823c9b50fd114196"
121
+ // Or write into a reusable buffer (541k pos/s):
122
+ const buffer = new Uint16Array(256);
123
+ const count = board.legalMoves(buffer);
149
124
  ```
150
125
 
151
- ### 4. 16-bit Packed Move Streams (`moves2`)
152
- Compress entire game databases down to 2 bytes per ply:
126
+ ### 2. Game State & Terminal Checks
153
127
  ```ts
154
- import { Chess } from 'gigachess';
155
-
156
- const game = new Chess();
157
- game.move('e4');
158
- game.move('c5');
159
- game.move('Nf3');
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
+ ```
160
137
 
161
- // Serialize history into raw Uint16Array (6 bytes total):
162
- const buffer = game.toMoves2();
138
+ ### 3. Incremental Polyglot Zobrist Hashing
139
+ ```ts
140
+ const board = new Board();
163
141
 
164
- // Instant binary replay:
165
- const replayedGame = Chess.fromMoves2(buffer);
166
- console.log(replayedGame.fen() === game.fen()); // true
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"
167
145
  ```
168
146
 
169
- ---
147
+ ### 4. Chess960 (Fischer Random)
148
+ ```ts
149
+ import { Board } from "gigachess";
170
150
 
171
- ## 🔬 How is GigaChess so Fast?
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
+ ```
172
155
 
173
- GigaChess incorporates the same hardware-efficient architectural principles found in Stockfish and modern master engines:
156
+ ### 5. Binary Move Stream Replay (`moves2`)
157
+ ```ts
158
+ import { Board } from "gigachess";
174
159
 
175
- 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 with `>>> 0` bitwise arithmetic.
176
- 2. **Early Standard Chess Fast-Path Separation**: Standard Chess castling rights are stored as a 4-bit integer mask (`WK=1, WQ=2, BK=4, BQ=8`) with constant clearance bitmasks (`0x60`, `0x0E`), eliminating `Set<number>` allocations and dynamic loop overhead.
177
- 3. **Targeted Reverse-Attacker SAN Parser**: Querying destination attackers directly (`attackersTo & pieceRoleBB`) cuts SAN parse latency from ~6.5 µs down to **~493 ns/op** (>8x speedup).
178
- 4. **Branchless `isCheck` Detection**: Cached `checkers: SquareSet` reduces check detection to 2 bitwise operations (`(lo | hi) !== 0`), clocking in at **0.5 ns/op** (>2 Billion checks/sec).
179
- 5. **Precomputed $64 \times 64$ Flat Ray & Between Tables**: Single-cycle `Uint32Array(4096)` array index lookups replace dynamic loops during pin and check resolution.
180
- 6. **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}$).
181
- 7. **Black Magic Sliding Bitboards**: $O(1)$ Bishop, Rook, and Queen ray generation delivering over **35.5 Million attacks/sec**.
182
- 8. **Piece-Centric Movegen & Vectorized Pawn Shifts**: Direct iteration over piece bitboards with parallel 32-bit shifts eliminates `pieceAt()` scans.
183
- 9. **Zero-Allocation `MoveSink` & `forEachLegalMove` Visitor**: Bulk popcounting at perft leaves and stack-buffer packed move writing (`legalMovesInto`) eliminate all move object allocations.
184
- 10. **Incremental Zobrist XORs**: Hashing updates in $O(1)$ per move rather than rescanning the 64 squares.
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);
163
+ ```
185
164
 
186
165
  ---
187
166
 
188
- ## 🌐 GigaChess Dual-Ecosystem
189
-
190
- GigaChess is engineered for maximum performance across the entire chess stack:
167
+ ## 🔬 Under the Hood: Why GigaChess is Fast
191
168
 
192
- | Language & Package | Primary Environment | Performance Highlights | Repository |
193
- |---|---|---|---|
194
- | **`gigachess` (JS / TS)** *(this repo)* | Web frontends, Node.js, Electron, React UI | **Up to 7.4× faster than chess.js**, 18.5M nodes/s perft, 120,000 games/s PGN parser, built-in variation trees | [GitHub](https://github.com/itshak/gigachess) / [npm](https://www.npmjs.com/package/gigachess) |
195
- | **`gigachess` (Rust)** | Native backends, search engines, database indexing | **540 Mnps** perft, 144B `Copy` board, 1.41M games/s replay, zero heap allocations | [GitHub](https://github.com/itshak/gigachess-rs) / [crates.io](https://crates.io/crates/gigachess) |
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.
196
173
 
197
174
  ---
198
175
 
package/dist/attacks.d.ts CHANGED
@@ -34,9 +34,9 @@ export declare function lineRay(from: number, to: number): SquareSet;
34
34
  * evaluate attackedness with the moving king removed from the occupancy so
35
35
  * that sliders x-raying the king stay "attacking" through its old square).
36
36
  */
37
- export declare function attackersTo(board: import("./board.js").Board, square: number, attacker: Color, occ?: SquareSet): SquareSet;
38
- export declare function isAttacked(board: import("./board.js").Board, square: number, attacker: Color): boolean;
39
- 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;
40
40
  export declare function rookAttacksForTest(sqIdx: number, occ: SquareSet): SquareSet;
41
41
  export declare function bishopAttacksForTest(sqIdx: number, occ: SquareSet): SquareSet;
42
42
  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;AAiInC,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEtD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per 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";
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;
@@ -14,33 +17,88 @@ export type Board = {
14
17
  readonly promoted: SquareSet;
15
18
  readonly kingSq?: readonly [number, number];
16
19
  };
17
- export declare function emptyBoard(): Board;
18
- export declare function cloneBoard(board: Board): Board;
19
- /**
20
- * Pure Board construction helpers.
21
- *
22
- * Contract (per purechess-board-movegen spec): Board is an immutable value —
23
- * every public op takes a Board and returns a NEW Board; the input is never
24
- * mutated. The *implementation* uses the spec-sanctioned clone→mutate-clone
25
- * technique via `WritableBoard` (see below), which keeps types honest without
26
- * `as any` casts.
27
- */
28
- /**
29
- * Writable view of a Board. HOT-LOOP-ONLY escape hatch, per the FP policy:
30
- * in-place board mutation is permitted exclusively inside leaf functions that
31
- * own a private scratch buffer (legality testing, move application) where
32
- * allocation churn dominates. Rules:
33
- * 1. A WritableBoard must NEVER escape the function that created/borrowed it.
34
- * 2. While a borrowed scratch is live, only leaf helpers may be called
35
- * (SquareSet ops, attacks lookups) — nothing that re-enters movegen.
36
- * 3. Public APIs must keep the observable pure contract: inputs unmodified.
37
- *
38
- * Unlike Board, a WritableBoard's field objects are MUTABLE bitfields
39
- * (MutableSquareSet): the owning scratch copies bits in place instead of
40
- * allocating fresh {lo,hi} objects per edit. This is sound because the scratch
41
- * objects never alias any Board's (immutable) field objects — see
42
- * newScratchBoard/copyBoardInto — and never escape rule 1.
43
- */
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
+ }
44
102
  export type WritableBoard = {
45
103
  white: sq.MutableSquareSet;
46
104
  black: sq.MutableSquareSet;
@@ -54,31 +112,28 @@ export type WritableBoard = {
54
112
  promoted: sq.MutableSquareSet;
55
113
  kingSq: [number, number];
56
114
  };
115
+ export declare function emptyBoard(): BoardLike;
116
+ export declare function cloneBoard(board: BoardLike): BoardLike;
57
117
  export declare function newScratchBoard(): WritableBoard;
58
- export declare function cloneAsWritable(board: Board): WritableBoard;
59
- /** Copy `src`'s ten fields into `dst`. Zero-allocation: the scratch owns its
60
- * field objects, so only the 64-bit values are assigned (no {lo,hi} churn). */
61
- export declare function copyBoardInto(dst: WritableBoard, src: Board): void;
62
- /** In-place: remove the piece (any color/role) at sqIdx. Hot-loop only.
63
- * 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;
64
120
  export declare function clearSquareInPlace(b: WritableBoard, sqIdx: number): void;
65
- /** In-place: place a piece at sqIdx. Hot-loop only. Zero-allocation. */
66
121
  export declare function putPieceInPlace(b: WritableBoard, sqIdx: number, piece: {
67
122
  color: Color;
68
123
  role: Role;
69
124
  }): void;
70
- export declare function setPiece(board: Board, sqIdx: number, piece: {
125
+ export declare function setPiece(board: BoardLike, sqIdx: number, piece: {
71
126
  color: Color;
72
127
  role: Role;
73
128
  }): Board;
74
- export declare function removePiece(board: Board, sqIdx: number): Board;
75
- 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): {
76
131
  color: Color;
77
132
  role: Role;
78
133
  } | undefined;
79
- export declare function hasPiece(board: Board, sqIdx: number): boolean;
80
- export declare function kingSquare(board: Board, color: Color): number | undefined;
81
- export declare function occupiedEqualsWhiteBlack(board: Board): boolean;
82
- export declare function rolePartitionEqualsOccupied(board: Board): boolean;
83
- 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;
84
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,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ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