js-chess-engine 2.0.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -20
- package/dist/ai/AIEngine.d.ts +4 -4
- package/dist/ai/AIEngine.d.ts.map +1 -1
- package/dist/ai/AIEngine.js +8 -7
- package/dist/ai/AIEngine.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/types/ai.types.d.ts +2 -2
- package/dist/types/ai.types.d.ts.map +1 -1
- package/dist/utils/environment.d.ts +3 -3
- package/dist/utils/environment.d.ts.map +1 -1
- package/dist/utils/environment.js +18 -16
- package/dist/utils/environment.js.map +1 -1
- package/dist/utils/fen.d.ts +7 -0
- package/dist/utils/fen.d.ts.map +1 -1
- package/dist/utils/fen.js +45 -0
- package/dist/utils/fen.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|

|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
Complete TypeScript chess engine without dependencies for Node.js >=24 and browsers. Includes configurable AI with difficulty levels 1-
|
|
6
|
+
Complete TypeScript chess engine without dependencies for Node.js >=24 and browsers. Includes configurable AI with difficulty levels 1-6.
|
|
7
7
|
|
|
8
8
|
**⚠️ Upgrading from v1?** See [Breaking Changes](#breaking-changes-from-v1) section at the end of this document
|
|
9
9
|
|
|
@@ -174,7 +174,7 @@ game.removePiece('E5')
|
|
|
174
174
|
`game.aiMove(level)` - Calculate and perform the best move for the current player using AI. **Returns only the move** (v1 API compatible).
|
|
175
175
|
|
|
176
176
|
Params:
|
|
177
|
-
- `level` AILevel (_optional_) - AI difficulty level (1-
|
|
177
|
+
- `level` AILevel (_optional_) - AI difficulty level (1-6). See [Computer AI](#computer-ai) section. Default: 3
|
|
178
178
|
|
|
179
179
|
Returns: `HistoryEntry` - The played move (e.g., `{"E2": "E4"}`)
|
|
180
180
|
|
|
@@ -195,7 +195,7 @@ const board = game.exportJson()
|
|
|
195
195
|
|
|
196
196
|
Params:
|
|
197
197
|
- `options` object (_optional_) - Configuration options:
|
|
198
|
-
- `level` number (_optional_) - AI difficulty level (1-
|
|
198
|
+
- `level` number (_optional_) - AI difficulty level (1-6). See [Computer AI](#computer-ai) section. Default: `3`
|
|
199
199
|
- `play` boolean (_optional_) - Whether to apply the move to the game. Default: `true`. If `false`, returns the move without modifying the game state, and `board` will contain the current state (before the move).
|
|
200
200
|
- `ttSizeMB` number (_optional_) - Transposition table size in MB (0 to disable, 0.25-256). Default: **auto-scaled by AI level**. See [Auto-Scaling Transposition Table](#transposition-table) for details.
|
|
201
201
|
|
|
@@ -382,7 +382,7 @@ const config2: BoardConfig = move(config1, 'E7', 'E5')
|
|
|
382
382
|
|
|
383
383
|
Params:
|
|
384
384
|
- `boardConfiguration` BoardConfig | string (_mandatory_) - Board [configuration](#board-configuration)
|
|
385
|
-
- `level` AILevel (_optional_) - AI difficulty level (1-
|
|
385
|
+
- `level` AILevel (_optional_) - AI difficulty level (1-6). Default: 3
|
|
386
386
|
|
|
387
387
|
Returns: `HistoryEntry` - The played move (e.g., `{"E2": "E4"}`)
|
|
388
388
|
|
|
@@ -403,7 +403,7 @@ console.log(move) // {"E2": "E4"}
|
|
|
403
403
|
Params:
|
|
404
404
|
- `boardConfiguration` BoardConfig | string (_mandatory_) - Board [configuration](#board-configuration)
|
|
405
405
|
- `options` object (_optional_) - Configuration options:
|
|
406
|
-
- `level` number (_optional_) - AI difficulty level (1-
|
|
406
|
+
- `level` number (_optional_) - AI difficulty level (1-6). Default: `3`
|
|
407
407
|
- `play` boolean (_optional_) - Whether to apply the move to the board. Default: `true`. If `false`, returns the move without modifying the board state, and `board` will contain the current state (before the move).
|
|
408
408
|
- `ttSizeMB` number (_optional_) - Transposition table size in MB (0 to disable, 0.25-256). Default: **auto-scaled by AI level**. See [Auto-Scaling Transposition Table](#transposition-table) for details.
|
|
409
409
|
|
|
@@ -521,17 +521,18 @@ console.log(newConfig)
|
|
|
521
521
|
|
|
522
522
|
### Computer AI
|
|
523
523
|
|
|
524
|
-
The engine includes a sophisticated AI based on the Minimax algorithm with alpha-beta pruning, enhanced with advanced performance optimizations. There are
|
|
524
|
+
The engine includes a sophisticated AI based on the Minimax algorithm with alpha-beta pruning, enhanced with advanced performance optimizations. There are six difficulty levels:
|
|
525
525
|
|
|
526
|
-
| Level | Alias | Description | Search Depth |
|
|
527
|
-
| :---: | :---------------- | :----------------------------------- | :----------: |
|
|
528
|
-
| 1 | Beginner | Very weak play, minimal lookahead | 1-2 ply |
|
|
529
|
-
| 2 | Easy | Suitable for new chess players | 2-3 ply |
|
|
530
|
-
| 3 | Intermediate | Balanced difficulty (default) | 3-4 ply |
|
|
531
|
-
| 4 | Advanced | Strong play with deeper search | 4-5 ply |
|
|
532
|
-
| 5 | Expert |
|
|
526
|
+
| Level | Alias | Description | Search Depth |
|
|
527
|
+
| :---: | :---------------- | :----------------------------------- | :----------: |
|
|
528
|
+
| 1 | Beginner | Very weak play, minimal lookahead | 1-2 ply |
|
|
529
|
+
| 2 | Easy | Suitable for new chess players | 2-3 ply |
|
|
530
|
+
| 3 | Intermediate | Balanced difficulty (default) | 3-4 ply |
|
|
531
|
+
| 4 | Advanced | Strong play with deeper search | 4-5 ply |
|
|
532
|
+
| 5 | Expert | Very strong play, deep search | 5-6 ply |
|
|
533
|
+
| 6 | Master | Maximum difficulty and search depth | 6-7 ply |
|
|
533
534
|
|
|
534
|
-
**
|
|
535
|
+
**Performance:** Response time increases exponentially with level. Benchmarked on modern hardware (Linux x64, Node.js v24): levels 1-2 ~30ms, level 3 ~50ms, levels 4-6 ~60-90ms. Actual performance varies based on hardware, position complexity, and cache size. Run `npm run benchmark` to measure performance on your system.
|
|
535
536
|
|
|
536
537
|
```typescript
|
|
537
538
|
import { Game } from 'js-chess-engine'
|
|
@@ -545,6 +546,7 @@ game.aiMove(2) // Easy
|
|
|
545
546
|
game.aiMove(3) // Intermediate (default)
|
|
546
547
|
game.aiMove(4) // Advanced
|
|
547
548
|
game.aiMove(5) // Expert
|
|
549
|
+
game.aiMove(6) // Master
|
|
548
550
|
```
|
|
549
551
|
|
|
550
552
|
**Implementation Highlights:**
|
|
@@ -561,11 +563,12 @@ The engine automatically adjusts cache size based on AI level and environment:
|
|
|
561
563
|
|
|
562
564
|
| AI Level | Node.js Cache | Browser Cache | Use Case |
|
|
563
565
|
| :------: | :-----------: | :-----------: | :--------------------------- |
|
|
564
|
-
| 1 |
|
|
565
|
-
| 2 |
|
|
566
|
-
| 3 |
|
|
567
|
-
| 4 |
|
|
568
|
-
| 5 |
|
|
566
|
+
| 1 | 1 MB | 0.5 MB | Lightweight, fast responses |
|
|
567
|
+
| 2 | 2 MB | 1 MB | Mobile-friendly performance |
|
|
568
|
+
| 3 | 8 MB | 4 MB | Balanced (default) |
|
|
569
|
+
| 4 | 16 MB | 8 MB | Strong tactical play |
|
|
570
|
+
| 5 | 32 MB | 16 MB | Very strong play |
|
|
571
|
+
| 6 | 64 MB | 32 MB | Maximum strength |
|
|
569
572
|
|
|
570
573
|
Lower levels use less memory for faster responses, higher levels use more for better move quality. Browser cache sizes are appropriate for modern devices (2024+). Override with `ttSizeMB` option if needed.
|
|
571
574
|
|
|
@@ -633,6 +636,8 @@ I am not a chess pro. My father is.
|
|
|
633
636
|
|
|
634
637
|
When I was ten, I had an Atari (with Turbo Basic), and I was hoping for a new PC. My father told me: "Make me a computer program which beats me in chess, and I'll buy you a new PC."
|
|
635
638
|
|
|
639
|
+

|
|
640
|
+
|
|
636
641
|
Obviously, it was a trap and I failed. Twenty years later, it came back to my mind, and I decided to finish what I started. This is version 2.0 - a complete TypeScript rewrite with improved performance and architecture.
|
|
637
642
|
|
|
638
643
|
## Breaking Changes from v1
|
|
@@ -694,7 +699,7 @@ ai(config, 3) // Returns: { move: {"E2": "E4"}, board: {...} }
|
|
|
694
699
|
### 4. AI Difficulty Levels Changed
|
|
695
700
|
|
|
696
701
|
- **v1:** Levels 0-4 (0=easiest, 4=hardest)
|
|
697
|
-
- **v2:** Levels 1-
|
|
702
|
+
- **v2:** Levels 1-6 (1=easiest, 6=hardest)
|
|
698
703
|
|
|
699
704
|
**Migration:**
|
|
700
705
|
- Level 0 → Level 1 (Beginner)
|
|
@@ -702,6 +707,7 @@ ai(config, 3) // Returns: { move: {"E2": "E4"}, board: {...} }
|
|
|
702
707
|
- Level 2 → Level 3 (Intermediate, default)
|
|
703
708
|
- Level 3 → Level 4 (Advanced)
|
|
704
709
|
- Level 4 → Level 5 (Expert)
|
|
710
|
+
- New: Level 6 (Master)
|
|
705
711
|
|
|
706
712
|
The default level has changed from `2` to `3` to maintain similar difficulty in the middle range.
|
|
707
713
|
|
package/dist/ai/AIEngine.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { InternalBoard, InternalMove } from '../types';
|
|
|
7
7
|
import { AILevel } from '../types/ai.types';
|
|
8
8
|
/**
|
|
9
9
|
* AI difficulty level configuration
|
|
10
|
-
* Maps AI levels (1-
|
|
10
|
+
* Maps AI levels (1-6) to search depths
|
|
11
11
|
*/
|
|
12
12
|
interface LevelConfig {
|
|
13
13
|
baseDepth: number;
|
|
@@ -25,15 +25,15 @@ export declare class AIEngine {
|
|
|
25
25
|
* Find the best move for the current position
|
|
26
26
|
*
|
|
27
27
|
* @param board - Current board state
|
|
28
|
-
* @param level - AI difficulty level (1-
|
|
29
|
-
* @param ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256 MB,
|
|
28
|
+
* @param level - AI difficulty level (1-6, default 3)
|
|
29
|
+
* @param ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256 MB, auto-scaled by level)
|
|
30
30
|
* @returns Best move found by the AI
|
|
31
31
|
*/
|
|
32
32
|
findBestMove(board: InternalBoard, level?: AILevel, ttSizeMB?: number): InternalMove | null;
|
|
33
33
|
/**
|
|
34
34
|
* Get the search depth for a given AI level
|
|
35
35
|
*
|
|
36
|
-
* @param level - AI level (1-
|
|
36
|
+
* @param level - AI level (1-6)
|
|
37
37
|
* @returns Depth configuration
|
|
38
38
|
*/
|
|
39
39
|
static getLevelDepth(level: AILevel): LevelConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIEngine.d.ts","sourceRoot":"","sources":["../../src/ai/AIEngine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C;;;GAGG;AACH,UAAU,WAAW;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"AIEngine.d.ts","sourceRoot":"","sources":["../../src/ai/AIEngine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C;;;GAGG;AACH,UAAU,WAAW;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACzB;AAeD;;;GAGG;AACH,qBAAa,QAAQ;IACjB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAc;;IAMnC;;;;;;;OAOG;IACH,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,GAAE,OAAW,EAAE,QAAQ,GAAE,MAAW,GAAG,YAAY,GAAG,IAAI;IAoBlG;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW;CAGpD"}
|
package/dist/ai/AIEngine.js
CHANGED
|
@@ -12,11 +12,12 @@ const Search_1 = require("./Search");
|
|
|
12
12
|
* Based on v1 behavior for compatibility
|
|
13
13
|
*/
|
|
14
14
|
const LEVEL_CONFIG = {
|
|
15
|
-
1: { baseDepth: 1, extendedDepth: 2 }, //
|
|
15
|
+
1: { baseDepth: 1, extendedDepth: 2 }, // Beginner
|
|
16
16
|
2: { baseDepth: 2, extendedDepth: 3 }, // Easy
|
|
17
|
-
3: { baseDepth: 3, extendedDepth: 4 }, //
|
|
18
|
-
4: { baseDepth: 4, extendedDepth: 5 }, //
|
|
19
|
-
5: { baseDepth: 5, extendedDepth: 6 }, //
|
|
17
|
+
3: { baseDepth: 3, extendedDepth: 4 }, // Intermediate (default)
|
|
18
|
+
4: { baseDepth: 4, extendedDepth: 5 }, // Advanced
|
|
19
|
+
5: { baseDepth: 5, extendedDepth: 6 }, // Expert
|
|
20
|
+
6: { baseDepth: 6, extendedDepth: 7 }, // Master
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
23
|
* AI Engine class
|
|
@@ -32,8 +33,8 @@ class AIEngine {
|
|
|
32
33
|
* Find the best move for the current position
|
|
33
34
|
*
|
|
34
35
|
* @param board - Current board state
|
|
35
|
-
* @param level - AI difficulty level (1-
|
|
36
|
-
* @param ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256 MB,
|
|
36
|
+
* @param level - AI difficulty level (1-6, default 3)
|
|
37
|
+
* @param ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256 MB, auto-scaled by level)
|
|
37
38
|
* @returns Best move found by the AI
|
|
38
39
|
*/
|
|
39
40
|
findBestMove(board, level = 3, ttSizeMB = 16) {
|
|
@@ -51,7 +52,7 @@ class AIEngine {
|
|
|
51
52
|
/**
|
|
52
53
|
* Get the search depth for a given AI level
|
|
53
54
|
*
|
|
54
|
-
* @param level - AI level (1-
|
|
55
|
+
* @param level - AI level (1-6)
|
|
55
56
|
* @returns Depth configuration
|
|
56
57
|
*/
|
|
57
58
|
static getLevelDepth(level) {
|
package/dist/ai/AIEngine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIEngine.js","sourceRoot":"","sources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C;YAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;QAED,yCAAyC;QACzC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QAEnC,iBAAiB;QACjB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CACnC,KAAK,EACL,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,aAAa,CACvB,CAAC;QAEF,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,KAAc;QAC/B,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACJ;AA7CD,4BA6CC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare class Game {
|
|
|
73
73
|
/**
|
|
74
74
|
* Make an AI move (v1 compatible - returns only the move)
|
|
75
75
|
*
|
|
76
|
-
* @param level - AI level (1-
|
|
76
|
+
* @param level - AI level (1-6, default 3)
|
|
77
77
|
* @returns The played move object (e.g., {"E2": "E4"})
|
|
78
78
|
*/
|
|
79
79
|
aiMove(level?: number): HistoryEntry;
|
|
@@ -81,9 +81,9 @@ export declare class Game {
|
|
|
81
81
|
* Make an AI move and return both move and board state
|
|
82
82
|
*
|
|
83
83
|
* @param options - Optional configuration object
|
|
84
|
-
* @param options.level - AI difficulty level (1-
|
|
84
|
+
* @param options.level - AI difficulty level (1-6, default: 3)
|
|
85
85
|
* @param options.play - Whether to apply the move to the game (default: true). If false, only returns the move without modifying game state.
|
|
86
|
-
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3:
|
|
86
|
+
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3: 8 MB Node.js, 4 MB browser)
|
|
87
87
|
* @returns Object containing the move and board configuration (current state if play=false, updated state if play=true)
|
|
88
88
|
*/
|
|
89
89
|
ai(options?: {
|
|
@@ -129,7 +129,7 @@ export declare function move(config: BoardConfig | string, from: string, to: str
|
|
|
129
129
|
* Make an AI move (v1 compatible - returns only the move)
|
|
130
130
|
*
|
|
131
131
|
* @param config - Board configuration or FEN string
|
|
132
|
-
* @param level - AI level (1-
|
|
132
|
+
* @param level - AI level (1-6, default 3)
|
|
133
133
|
* @returns The played move object (e.g., {"E2": "E4"})
|
|
134
134
|
*/
|
|
135
135
|
export declare function aiMove(config: BoardConfig | string, level?: number): HistoryEntry;
|
|
@@ -138,9 +138,9 @@ export declare function aiMove(config: BoardConfig | string, level?: number): Hi
|
|
|
138
138
|
*
|
|
139
139
|
* @param config - Board configuration or FEN string
|
|
140
140
|
* @param options - Optional configuration object
|
|
141
|
-
* @param options.level - AI difficulty level (1-
|
|
141
|
+
* @param options.level - AI difficulty level (1-6, default: 3)
|
|
142
142
|
* @param options.play - Whether to apply the move to the game (default: true). If false, only returns the move without modifying game state.
|
|
143
|
-
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3:
|
|
143
|
+
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3: 8 MB Node.js, 4 MB browser)
|
|
144
144
|
* @returns Object containing the move and board configuration (current state if play=false, updated state if play=true)
|
|
145
145
|
*/
|
|
146
146
|
export declare function ai(config: BoardConfig | string, options?: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEH,WAAW,EACX,QAAQ,EAER,WAAW,EACX,YAAY,EACf,MAAM,SAAS,CAAC;AAkBjB,cAAc,SAAS,CAAC;AAExB;;GAEG;AACH,qBAAa,IAAI;IACb,OAAO,CA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,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,WAAW,CAAA;KAAE;CA2CtH;AA0BD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,CAG5D;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,WAAW,CAGhE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAGxF;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,YAAY,CAGpF;AAED;;;;;;;;;GASG;AACH,wBAAgB,EAAE,CACd,MAAM,EAAE,WAAW,GAAG,MAAM,EAC5B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACpE;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAG5C"}
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ class Game {
|
|
|
55
55
|
}
|
|
56
56
|
else if (typeof configuration === 'string') {
|
|
57
57
|
// FEN string
|
|
58
|
+
(0, fen_1.validateFEN)(configuration);
|
|
58
59
|
this.board = (0, fen_1.parseFEN)(configuration);
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
@@ -191,13 +192,13 @@ class Game {
|
|
|
191
192
|
/**
|
|
192
193
|
* Make an AI move (v1 compatible - returns only the move)
|
|
193
194
|
*
|
|
194
|
-
* @param level - AI level (1-
|
|
195
|
+
* @param level - AI level (1-6, default 3)
|
|
195
196
|
* @returns The played move object (e.g., {"E2": "E4"})
|
|
196
197
|
*/
|
|
197
198
|
aiMove(level = 3) {
|
|
198
199
|
// Validate level
|
|
199
|
-
if (level < 1 || level >
|
|
200
|
-
throw new Error('AI level must be between 1 and
|
|
200
|
+
if (level < 1 || level > 6) {
|
|
201
|
+
throw new Error('AI level must be between 1 and 6');
|
|
201
202
|
}
|
|
202
203
|
// Find best move
|
|
203
204
|
const bestMove = this.aiEngine.findBestMove(this.board, level);
|
|
@@ -218,9 +219,9 @@ class Game {
|
|
|
218
219
|
* Make an AI move and return both move and board state
|
|
219
220
|
*
|
|
220
221
|
* @param options - Optional configuration object
|
|
221
|
-
* @param options.level - AI difficulty level (1-
|
|
222
|
+
* @param options.level - AI difficulty level (1-6, default: 3)
|
|
222
223
|
* @param options.play - Whether to apply the move to the game (default: true). If false, only returns the move without modifying game state.
|
|
223
|
-
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3:
|
|
224
|
+
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3: 8 MB Node.js, 4 MB browser)
|
|
224
225
|
* @returns Object containing the move and board configuration (current state if play=false, updated state if play=true)
|
|
225
226
|
*/
|
|
226
227
|
ai(options = {}) {
|
|
@@ -231,8 +232,8 @@ class Game {
|
|
|
231
232
|
const defaultSize = (0, environment_1.getRecommendedTTSize)(level);
|
|
232
233
|
const ttSizeMB = options.ttSizeMB === 0 ? 0 : Math.max(0.25, Math.min(256, options.ttSizeMB ?? defaultSize));
|
|
233
234
|
// Validate level
|
|
234
|
-
if (level < 1 || level >
|
|
235
|
-
throw new Error('AI level must be between 1 and
|
|
235
|
+
if (level < 1 || level > 6) {
|
|
236
|
+
throw new Error('AI level must be between 1 and 6');
|
|
236
237
|
}
|
|
237
238
|
// Find best move
|
|
238
239
|
const bestMove = this.aiEngine.findBestMove(this.board, level, ttSizeMB);
|
|
@@ -329,7 +330,7 @@ function move(config, from, to) {
|
|
|
329
330
|
* Make an AI move (v1 compatible - returns only the move)
|
|
330
331
|
*
|
|
331
332
|
* @param config - Board configuration or FEN string
|
|
332
|
-
* @param level - AI level (1-
|
|
333
|
+
* @param level - AI level (1-6, default 3)
|
|
333
334
|
* @returns The played move object (e.g., {"E2": "E4"})
|
|
334
335
|
*/
|
|
335
336
|
function aiMove(config, level = 3) {
|
|
@@ -341,9 +342,9 @@ function aiMove(config, level = 3) {
|
|
|
341
342
|
*
|
|
342
343
|
* @param config - Board configuration or FEN string
|
|
343
344
|
* @param options - Optional configuration object
|
|
344
|
-
* @param options.level - AI difficulty level (1-
|
|
345
|
+
* @param options.level - AI difficulty level (1-6, default: 3)
|
|
345
346
|
* @param options.play - Whether to apply the move to the game (default: true). If false, only returns the move without modifying game state.
|
|
346
|
-
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3:
|
|
347
|
+
* @param options.ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256). Default: auto-scaled by level (e.g., level 3: 8 MB Node.js, 4 MB browser)
|
|
347
348
|
* @returns Object containing the move and board configuration (current state if play=false, updated state if play=true)
|
|
348
349
|
*/
|
|
349
350
|
function ai(config, options = {}) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAoUH,sBAGC;AAQD,wBAGC;AAQD,wBAGC;AAUD,oBAGC;AASD,wBAGC;AAYD,gBAMC;AA9XD,w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AM,CAAC,MAA4B;IAC/C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,IAAI,CAAC,MAA4B,EAAE,IAAY,EAAE,EAAU;IACvE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,MAA4B,EAAE,QAAgB,CAAC;IAClE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,EAAE,CACd,MAA4B,EAC5B,UAAiE,EAAE;IAEnE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/types/ai.types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.types.d.ts","sourceRoot":"","sources":["../../src/types/ai.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ai.types.d.ts","sourceRoot":"","sources":["../../src/types/ai.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG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AE,KAAK,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -17,8 +17,8 @@ export declare function isBrowserEnvironment(): boolean;
|
|
|
17
17
|
/**
|
|
18
18
|
* Get default transposition table size based on environment
|
|
19
19
|
*
|
|
20
|
-
* Node.js:
|
|
21
|
-
* Browser:
|
|
20
|
+
* Node.js: 8 MB (ample memory available)
|
|
21
|
+
* Browser: 4 MB (more conservative for web/mobile)
|
|
22
22
|
*
|
|
23
23
|
* @returns Recommended TT size in MB
|
|
24
24
|
*/
|
|
@@ -26,7 +26,7 @@ export declare function getDefaultTTSize(): number;
|
|
|
26
26
|
/**
|
|
27
27
|
* Get recommended TT size for a given AI level and environment
|
|
28
28
|
*
|
|
29
|
-
* @param level - AI difficulty level (1-
|
|
29
|
+
* @param level - AI difficulty level (1-6)
|
|
30
30
|
* @returns Recommended TT size in MB
|
|
31
31
|
*/
|
|
32
32
|
export declare function getRecommendedTTSize(level: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAwB1D"}
|
|
@@ -30,42 +30,44 @@ function isBrowserEnvironment() {
|
|
|
30
30
|
/**
|
|
31
31
|
* Get default transposition table size based on environment
|
|
32
32
|
*
|
|
33
|
-
* Node.js:
|
|
34
|
-
* Browser:
|
|
33
|
+
* Node.js: 8 MB (ample memory available)
|
|
34
|
+
* Browser: 4 MB (more conservative for web/mobile)
|
|
35
35
|
*
|
|
36
36
|
* @returns Recommended TT size in MB
|
|
37
37
|
*/
|
|
38
38
|
function getDefaultTTSize() {
|
|
39
|
-
return isNodeEnvironment() ?
|
|
39
|
+
return isNodeEnvironment() ? 8 : 4;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Get recommended TT size for a given AI level and environment
|
|
43
43
|
*
|
|
44
|
-
* @param level - AI difficulty level (1-
|
|
44
|
+
* @param level - AI difficulty level (1-6)
|
|
45
45
|
* @returns Recommended TT size in MB
|
|
46
46
|
*/
|
|
47
47
|
function getRecommendedTTSize(level) {
|
|
48
48
|
if (isNodeEnvironment()) {
|
|
49
49
|
// Node.js - more generous memory allocation
|
|
50
50
|
const nodeSizes = {
|
|
51
|
-
1:
|
|
52
|
-
2:
|
|
53
|
-
3:
|
|
54
|
-
4:
|
|
55
|
-
5:
|
|
51
|
+
1: 1, // Level 1: 1 MB
|
|
52
|
+
2: 2, // Level 2: 2 MB
|
|
53
|
+
3: 8, // Level 3: 8 MB (default)
|
|
54
|
+
4: 16, // Level 4: 16 MB
|
|
55
|
+
5: 32, // Level 5: 32 MB
|
|
56
|
+
6: 64, // Level 6: 64 MB
|
|
56
57
|
};
|
|
57
|
-
return nodeSizes[level] ??
|
|
58
|
+
return nodeSizes[level] ?? 8;
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
61
|
// Browser - modern-device-friendly allocation (reasonable for 2024+ devices)
|
|
61
62
|
const browserSizes = {
|
|
62
|
-
1:
|
|
63
|
-
2:
|
|
64
|
-
3:
|
|
65
|
-
4:
|
|
66
|
-
5:
|
|
63
|
+
1: 0.5, // Level 1: 0.5 MB (lightweight, older devices)
|
|
64
|
+
2: 1, // Level 2: 1 MB (mobile-friendly)
|
|
65
|
+
3: 4, // Level 3: 4 MB (balanced default - appropriate for modern browsers)
|
|
66
|
+
4: 8, // Level 4: 8 MB (strong performance)
|
|
67
|
+
5: 16, // Level 5: 16 MB (very strong play)
|
|
68
|
+
6: 32, // Level 6: 32 MB (maximum strength)
|
|
67
69
|
};
|
|
68
|
-
return browserSizes[level] ??
|
|
70
|
+
return browserSizes[level] ?? 4;
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
//# sourceMappingURL=environment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAOH,8CAOC;AAOD,oDAEC;AAUD,4CAEC;AAQD,
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAOH,8CAOC;AAOD,oDAEC;AAUD,4CAEC;AAQD,oDAwBC;AAjED;;;;GAIG;AACH,SAAgB,iBAAiB;IAC7B,qCAAqC;IACrC,OAAO,CACH,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;QACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAChC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB;IAChC,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB;IAC5B,OAAO,iBAAiB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAC9C,IAAI,iBAAiB,EAAE,EAAE,CAAC;QACtB,4CAA4C;QAC5C,MAAM,SAAS,GAA2B;YACtC,CAAC,EAAE,CAAC,EAAI,gBAAgB;YACxB,CAAC,EAAE,CAAC,EAAI,gBAAgB;YACxB,CAAC,EAAE,CAAC,EAAI,0BAA0B;YAClC,CAAC,EAAE,EAAE,EAAG,iBAAiB;YACzB,CAAC,EAAE,EAAE,EAAG,iBAAiB;YACzB,CAAC,EAAE,EAAE,EAAG,iBAAiB;SAC5B,CAAC;QACF,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACJ,6EAA6E;QAC7E,MAAM,YAAY,GAA2B;YACzC,CAAC,EAAE,GAAG,EAAG,+CAA+C;YACxD,CAAC,EAAE,CAAC,EAAK,kCAAkC;YAC3C,CAAC,EAAE,CAAC,EAAK,qEAAqE;YAC9E,CAAC,EAAE,CAAC,EAAK,qCAAqC;YAC9C,CAAC,EAAE,EAAE,EAAI,oCAAoC;YAC7C,CAAC,EAAE,EAAE,EAAI,oCAAoC;SAChD,CAAC;QACF,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;AACL,CAAC"}
|
package/dist/utils/fen.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ import { InternalBoard } from '../types';
|
|
|
12
12
|
* @returns Internal board representation
|
|
13
13
|
*/
|
|
14
14
|
export declare function parseFEN(fen: string): InternalBoard;
|
|
15
|
+
/**
|
|
16
|
+
* Validate a FEN string.
|
|
17
|
+
*
|
|
18
|
+
* This is intended for user-provided input. It throws with a descriptive message
|
|
19
|
+
* when the FEN is invalid.
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateFEN(fen: string): void;
|
|
15
22
|
/**
|
|
16
23
|
* Convert an internal board to a FEN string
|
|
17
24
|
*
|
package/dist/utils/fen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fen.d.ts","sourceRoot":"","sources":["../../src/utils/fen.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAqC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"fen.d.ts","sourceRoot":"","sources":["../../src/utils/fen.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAqC,MAAM,UAAU,CAAC;AAO5E;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CA+GnD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAG7C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAyDlD;AAkDD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
package/dist/utils/fen.js
CHANGED
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.parseFEN = parseFEN;
|
|
10
|
+
exports.validateFEN = validateFEN;
|
|
10
11
|
exports.toFEN = toFEN;
|
|
11
12
|
exports.getStartingFEN = getStartingFEN;
|
|
12
13
|
const types_1 = require("../types");
|
|
13
14
|
const Board_1 = require("../core/Board");
|
|
14
15
|
const conversion_1 = require("./conversion");
|
|
16
|
+
const FEN_CASTLING_RE = /^(-|[KQkq]{1,4})$/;
|
|
17
|
+
const FEN_EN_PASSANT_RE = /^(-|[a-h][36])$/;
|
|
15
18
|
/**
|
|
16
19
|
* Parse a FEN string into an internal board
|
|
17
20
|
*
|
|
@@ -56,6 +59,18 @@ function parseFEN(fen) {
|
|
|
56
59
|
throw new Error(`Invalid FEN: rank ${8 - rank} has ${file} files instead of 8`);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
62
|
+
// Validate piece placement has exactly one king of each color
|
|
63
|
+
let whiteKings = 0;
|
|
64
|
+
let blackKings = 0;
|
|
65
|
+
for (const p of board.mailbox) {
|
|
66
|
+
if (p === types_1.Piece.WHITE_KING)
|
|
67
|
+
whiteKings++;
|
|
68
|
+
if (p === types_1.Piece.BLACK_KING)
|
|
69
|
+
blackKings++;
|
|
70
|
+
}
|
|
71
|
+
if (whiteKings !== 1 || blackKings !== 1) {
|
|
72
|
+
throw new Error(`Invalid FEN: expected exactly one white king and one black king`);
|
|
73
|
+
}
|
|
59
74
|
// Parse active color
|
|
60
75
|
if (activeColor === 'w') {
|
|
61
76
|
board.turn = types_1.InternalColor.WHITE;
|
|
@@ -66,13 +81,27 @@ function parseFEN(fen) {
|
|
|
66
81
|
else {
|
|
67
82
|
throw new Error(`Invalid FEN: unknown active color '${activeColor}'`);
|
|
68
83
|
}
|
|
84
|
+
// Validate castling rights string
|
|
85
|
+
if (!FEN_CASTLING_RE.test(castling)) {
|
|
86
|
+
throw new Error(`Invalid FEN: invalid castling rights '${castling}'`);
|
|
87
|
+
}
|
|
88
|
+
if (castling !== '-') {
|
|
89
|
+
const unique = new Set(castling.split(''));
|
|
90
|
+
if (unique.size !== castling.length) {
|
|
91
|
+
throw new Error(`Invalid FEN: duplicate castling rights '${castling}'`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
69
94
|
// Parse castling rights
|
|
70
95
|
board.castlingRights.whiteShort = castling.includes('K');
|
|
71
96
|
board.castlingRights.whiteLong = castling.includes('Q');
|
|
72
97
|
board.castlingRights.blackShort = castling.includes('k');
|
|
73
98
|
board.castlingRights.blackLong = castling.includes('q');
|
|
74
99
|
// Parse en passant square
|
|
100
|
+
if (!FEN_EN_PASSANT_RE.test(enPassant)) {
|
|
101
|
+
throw new Error(`Invalid FEN: invalid en passant square '${enPassant}'`);
|
|
102
|
+
}
|
|
75
103
|
if (enPassant !== '-') {
|
|
104
|
+
// enPassant is lowercase by regex; squareToIndex expects uppercase.
|
|
76
105
|
board.enPassantSquare = (0, conversion_1.squareToIndex)(enPassant.toUpperCase());
|
|
77
106
|
}
|
|
78
107
|
// Parse half-move clock (for 50-move rule)
|
|
@@ -80,13 +109,29 @@ function parseFEN(fen) {
|
|
|
80
109
|
if (isNaN(board.halfMoveClock)) {
|
|
81
110
|
throw new Error(`Invalid FEN: invalid half-move clock '${halfMove}'`);
|
|
82
111
|
}
|
|
112
|
+
if (board.halfMoveClock < 0) {
|
|
113
|
+
throw new Error(`Invalid FEN: half-move clock must be >= 0`);
|
|
114
|
+
}
|
|
83
115
|
// Parse full move number
|
|
84
116
|
board.fullMoveNumber = parseInt(fullMove, 10);
|
|
85
117
|
if (isNaN(board.fullMoveNumber)) {
|
|
86
118
|
throw new Error(`Invalid FEN: invalid full move number '${fullMove}'`);
|
|
87
119
|
}
|
|
120
|
+
if (board.fullMoveNumber < 1) {
|
|
121
|
+
throw new Error(`Invalid FEN: full move number must be >= 1`);
|
|
122
|
+
}
|
|
88
123
|
return board;
|
|
89
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Validate a FEN string.
|
|
127
|
+
*
|
|
128
|
+
* This is intended for user-provided input. It throws with a descriptive message
|
|
129
|
+
* when the FEN is invalid.
|
|
130
|
+
*/
|
|
131
|
+
function validateFEN(fen) {
|
|
132
|
+
// parseFEN already performs full validation and throws on any error.
|
|
133
|
+
parseFEN(fen);
|
|
134
|
+
}
|
|
90
135
|
/**
|
|
91
136
|
* Convert an internal board to a FEN string
|
|
92
137
|
*
|
package/dist/utils/fen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fen.js","sourceRoot":"","sources":["../../src/utils/fen.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"fen.js","sourceRoot":"","sources":["../../src/utils/fen.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAeH,4BA+GC;AAQD,kCAGC;AAQD,sBAyDC;AAuDD,wCAEC;AAjQD,oCAA4E;AAC5E,yCAA2D;AAC3D,6CAA4D;AAE5D,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAChC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,sCAAsC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC;IAErF,MAAM,KAAK,GAAG,IAAA,wBAAgB,GAAE,CAAC;IAEjC,uDAAuD;IACvD,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,sCAAsC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,IAAI,GAAG,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;;GAIG;AACH,SAAgB,cAAc;IAC1B,OAAO,0DAA0D,CAAC;AACtE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-chess-engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Simple and fast Node.js chess engine without dependencies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chess",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsc",
|
|
17
17
|
"build:watch": "tsc --watch",
|
|
18
|
+
"benchmark": "npm run build && node scripts/benchmark-levels.mjs",
|
|
18
19
|
"clean": "rm -rf dist",
|
|
19
20
|
"prebuild": "npm run clean",
|
|
20
21
|
"test": "jest",
|