js-chess-engine 1.0.3 → 2.0.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +586 -205
- package/dist/adapters/APIAdapter.d.ts +88 -0
- package/dist/adapters/APIAdapter.d.ts.map +1 -0
- package/dist/adapters/APIAdapter.js +225 -0
- package/dist/adapters/APIAdapter.js.map +1 -0
- package/dist/ai/AIEngine.d.ts +42 -0
- package/dist/ai/AIEngine.d.ts.map +1 -0
- package/dist/ai/AIEngine.js +62 -0
- package/dist/ai/AIEngine.js.map +1 -0
- package/dist/ai/Evaluator.d.ts +48 -0
- package/dist/ai/Evaluator.d.ts.map +1 -0
- package/dist/ai/Evaluator.js +248 -0
- package/dist/ai/Evaluator.js.map +1 -0
- package/dist/ai/MoveOrdering.d.ts +60 -0
- package/dist/ai/MoveOrdering.d.ts.map +1 -0
- package/dist/ai/MoveOrdering.js +173 -0
- package/dist/ai/MoveOrdering.js.map +1 -0
- package/dist/ai/Search.d.ts +62 -0
- package/dist/ai/Search.d.ts.map +1 -0
- package/dist/ai/Search.js +340 -0
- package/dist/ai/Search.js.map +1 -0
- package/dist/ai/TranspositionTable.d.ts +100 -0
- package/dist/ai/TranspositionTable.d.ts.map +1 -0
- package/dist/ai/TranspositionTable.js +176 -0
- package/dist/ai/TranspositionTable.js.map +1 -0
- package/dist/core/AttackDetector.d.ts +52 -0
- package/dist/core/AttackDetector.d.ts.map +1 -0
- package/dist/core/AttackDetector.js +387 -0
- package/dist/core/AttackDetector.js.map +1 -0
- package/dist/core/Board.d.ts +109 -0
- package/dist/core/Board.d.ts.map +1 -0
- package/dist/core/Board.js +410 -0
- package/dist/core/Board.js.map +1 -0
- package/dist/core/MoveGenerator.d.ts +48 -0
- package/dist/core/MoveGenerator.d.ts.map +1 -0
- package/dist/core/MoveGenerator.js +678 -0
- package/dist/core/MoveGenerator.js.map +1 -0
- package/dist/core/Position.d.ts +135 -0
- package/dist/core/Position.d.ts.map +1 -0
- package/dist/core/Position.js +351 -0
- package/dist/core/Position.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +25 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/zobrist.d.ts +93 -0
- package/dist/core/zobrist.d.ts.map +1 -0
- package/dist/core/zobrist.js +273 -0
- package/dist/core/zobrist.js.map +1 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +353 -0
- package/dist/index.js.map +1 -0
- package/dist/types/ai.types.d.ts +97 -0
- package/dist/types/ai.types.d.ts.map +1 -0
- package/dist/types/ai.types.js +17 -0
- package/dist/types/ai.types.js.map +1 -0
- package/dist/types/board.types.d.ts +140 -0
- package/dist/types/board.types.d.ts.map +1 -0
- package/dist/types/board.types.js +34 -0
- package/dist/types/board.types.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +26 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/move.types.d.ts +70 -0
- package/dist/types/move.types.d.ts.map +1 -0
- package/dist/types/move.types.js +53 -0
- package/dist/types/move.types.js.map +1 -0
- package/dist/utils/constants.d.ts +123 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +259 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/conversion.d.ts +152 -0
- package/dist/utils/conversion.d.ts.map +1 -0
- package/dist/utils/conversion.js +288 -0
- package/dist/utils/conversion.js.map +1 -0
- package/dist/utils/environment.d.ts +33 -0
- package/dist/utils/environment.d.ts.map +1 -0
- package/dist/utils/environment.js +71 -0
- package/dist/utils/environment.js.map +1 -0
- package/dist/utils/fen.d.ts +28 -0
- package/dist/utils/fen.d.ts.map +1 -0
- package/dist/utils/fen.js +203 -0
- package/dist/utils/fen.js.map +1 -0
- package/package.json +25 -29
- package/.eslintrc.json +0 -16
- package/.github/workflows/main.yml +0 -20
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -597
- package/dist/js-chess-engine.js +0 -1
- package/example/aiMatch.mjs +0 -21
- package/example/console.mjs +0 -37
- package/example/server.mjs +0 -27
- package/lib/Board.mjs +0 -946
- package/lib/const/board.mjs +0 -838
- package/lib/js-chess-engine.mjs +0 -99
- package/lib/utils.mjs +0 -154
- package/test/.eslintrc.json +0 -11
- package/test/ai.test.mjs +0 -132
- package/test/badge.svg +0 -1
- package/test/importExport.mjs +0 -108
- package/test/moves.test.mjs +0 -798
- package/webpack.config.js +0 -12
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Adapter for converting between internal and external representations
|
|
3
|
+
*
|
|
4
|
+
* Internal format uses:
|
|
5
|
+
* - Square indices (0-63)
|
|
6
|
+
* - Piece enums
|
|
7
|
+
* - InternalColor enum
|
|
8
|
+
*
|
|
9
|
+
* External format (v1 API) uses:
|
|
10
|
+
* - Square strings (A1-H8)
|
|
11
|
+
* - Piece symbols (K, Q, R, B, N, P, k, q, r, b, n, p)
|
|
12
|
+
* - Color strings ('white', 'black')
|
|
13
|
+
*/
|
|
14
|
+
import { InternalBoard, BoardConfig, MovesMap, Piece, PieceSymbol, InternalColor, Color, Square, SquareIndex } from '../types';
|
|
15
|
+
import { InternalMove } from '../types/move.types';
|
|
16
|
+
/**
|
|
17
|
+
* Convert internal board to public board configuration
|
|
18
|
+
*
|
|
19
|
+
* @param board - Internal board representation
|
|
20
|
+
* @returns Public board configuration (v1 API format)
|
|
21
|
+
*/
|
|
22
|
+
export declare function boardToConfig(board: InternalBoard): BoardConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Convert public board configuration to internal board
|
|
25
|
+
*
|
|
26
|
+
* @param config - Public board configuration
|
|
27
|
+
* @returns Internal board representation
|
|
28
|
+
*/
|
|
29
|
+
export declare function configToBoard(config: BoardConfig): InternalBoard;
|
|
30
|
+
/**
|
|
31
|
+
* Convert board configuration to FEN string
|
|
32
|
+
*
|
|
33
|
+
* @param config - Public board configuration
|
|
34
|
+
* @returns FEN string
|
|
35
|
+
*/
|
|
36
|
+
export declare function configToFEN(config: BoardConfig): string;
|
|
37
|
+
/**
|
|
38
|
+
* Convert internal moves to public moves map
|
|
39
|
+
*
|
|
40
|
+
* @param moves - Array of internal moves
|
|
41
|
+
* @returns Public moves map (from-square -> [to-squares])
|
|
42
|
+
*/
|
|
43
|
+
export declare function movesToMap(moves: InternalMove[]): MovesMap;
|
|
44
|
+
/**
|
|
45
|
+
* Convert internal moves from a specific square to array of to-squares
|
|
46
|
+
*
|
|
47
|
+
* @param moves - Array of internal moves
|
|
48
|
+
* @param fromIndex - From square index
|
|
49
|
+
* @returns Array of to-square strings
|
|
50
|
+
*/
|
|
51
|
+
export declare function movesFromSquare(moves: InternalMove[], fromIndex: SquareIndex): Square[];
|
|
52
|
+
/**
|
|
53
|
+
* Convert piece enum to piece symbol
|
|
54
|
+
*
|
|
55
|
+
* @param piece - Internal piece enum
|
|
56
|
+
* @returns Piece symbol or null if empty
|
|
57
|
+
*/
|
|
58
|
+
export declare function pieceToSymbol(piece: Piece): PieceSymbol | null;
|
|
59
|
+
/**
|
|
60
|
+
* Convert piece symbol to piece enum
|
|
61
|
+
*
|
|
62
|
+
* @param symbol - Piece symbol
|
|
63
|
+
* @returns Internal piece enum
|
|
64
|
+
*/
|
|
65
|
+
export declare function symbolToPiece(symbol: PieceSymbol): Piece;
|
|
66
|
+
/**
|
|
67
|
+
* Convert color string to internal color
|
|
68
|
+
*
|
|
69
|
+
* @param color - Color string
|
|
70
|
+
* @returns Internal color enum
|
|
71
|
+
*/
|
|
72
|
+
export declare function colorToInternal(color: Color): InternalColor;
|
|
73
|
+
/**
|
|
74
|
+
* Convert internal color to color string
|
|
75
|
+
*
|
|
76
|
+
* @param color - Internal color enum
|
|
77
|
+
* @returns Color string
|
|
78
|
+
*/
|
|
79
|
+
export declare function internalToColor(color: InternalColor): Color;
|
|
80
|
+
/**
|
|
81
|
+
* Normalize square string to uppercase (A1-H8)
|
|
82
|
+
* V1 API accepts case-insensitive input
|
|
83
|
+
*
|
|
84
|
+
* @param square - Square string (case-insensitive)
|
|
85
|
+
* @returns Normalized uppercase square string
|
|
86
|
+
*/
|
|
87
|
+
export declare function normalizeSquare(square: string): string;
|
|
88
|
+
//# sourceMappingURL=APIAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/APIAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACH,aAAa,EACb,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,aAAa,EACb,KAAK,EACL,MAAM,EACN,WAAW,EACd,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CA0B/D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAOhE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA4CvD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,QAAQ,CAe1D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,CAIvF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,IAAI,CAgB9D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CAexD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API Adapter for converting between internal and external representations
|
|
4
|
+
*
|
|
5
|
+
* Internal format uses:
|
|
6
|
+
* - Square indices (0-63)
|
|
7
|
+
* - Piece enums
|
|
8
|
+
* - InternalColor enum
|
|
9
|
+
*
|
|
10
|
+
* External format (v1 API) uses:
|
|
11
|
+
* - Square strings (A1-H8)
|
|
12
|
+
* - Piece symbols (K, Q, R, B, N, P, k, q, r, b, n, p)
|
|
13
|
+
* - Color strings ('white', 'black')
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.boardToConfig = boardToConfig;
|
|
17
|
+
exports.configToBoard = configToBoard;
|
|
18
|
+
exports.configToFEN = configToFEN;
|
|
19
|
+
exports.movesToMap = movesToMap;
|
|
20
|
+
exports.movesFromSquare = movesFromSquare;
|
|
21
|
+
exports.pieceToSymbol = pieceToSymbol;
|
|
22
|
+
exports.symbolToPiece = symbolToPiece;
|
|
23
|
+
exports.colorToInternal = colorToInternal;
|
|
24
|
+
exports.internalToColor = internalToColor;
|
|
25
|
+
exports.normalizeSquare = normalizeSquare;
|
|
26
|
+
const types_1 = require("../types");
|
|
27
|
+
const conversion_1 = require("../utils/conversion");
|
|
28
|
+
/**
|
|
29
|
+
* Convert internal board to public board configuration
|
|
30
|
+
*
|
|
31
|
+
* @param board - Internal board representation
|
|
32
|
+
* @returns Public board configuration (v1 API format)
|
|
33
|
+
*/
|
|
34
|
+
function boardToConfig(board) {
|
|
35
|
+
const pieces = {};
|
|
36
|
+
// Convert mailbox to pieces object
|
|
37
|
+
for (let i = 0; i < 64; i++) {
|
|
38
|
+
const piece = board.mailbox[i];
|
|
39
|
+
if (piece !== types_1.Piece.EMPTY) {
|
|
40
|
+
const square = (0, conversion_1.indexToSquare)(i);
|
|
41
|
+
const symbol = pieceToSymbol(piece);
|
|
42
|
+
if (symbol) {
|
|
43
|
+
pieces[square] = symbol;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
pieces,
|
|
49
|
+
turn: board.turn === types_1.InternalColor.WHITE ? 'white' : 'black',
|
|
50
|
+
isFinished: board.isCheckmate || board.isStalemate,
|
|
51
|
+
check: board.isCheck,
|
|
52
|
+
checkMate: board.isCheckmate,
|
|
53
|
+
castling: { ...board.castlingRights },
|
|
54
|
+
enPassant: board.enPassantSquare !== null ? (0, conversion_1.indexToSquare)(board.enPassantSquare) : null,
|
|
55
|
+
halfMove: board.halfMoveClock,
|
|
56
|
+
fullMove: board.fullMoveNumber,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Convert public board configuration to internal board
|
|
61
|
+
*
|
|
62
|
+
* @param config - Public board configuration
|
|
63
|
+
* @returns Internal board representation
|
|
64
|
+
*/
|
|
65
|
+
function configToBoard(config) {
|
|
66
|
+
// We'll use FEN conversion for this as it's more straightforward
|
|
67
|
+
// First convert config to FEN, then parse FEN to internal board
|
|
68
|
+
// However, for simplicity, we can also build it directly
|
|
69
|
+
const { parseFEN } = require('../utils/fen');
|
|
70
|
+
const fen = configToFEN(config);
|
|
71
|
+
return parseFEN(fen);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Convert board configuration to FEN string
|
|
75
|
+
*
|
|
76
|
+
* @param config - Public board configuration
|
|
77
|
+
* @returns FEN string
|
|
78
|
+
*/
|
|
79
|
+
function configToFEN(config) {
|
|
80
|
+
// Build piece placement string
|
|
81
|
+
const ranks = [];
|
|
82
|
+
for (let rank = 7; rank >= 0; rank--) {
|
|
83
|
+
let rankStr = '';
|
|
84
|
+
let emptyCount = 0;
|
|
85
|
+
for (let file = 0; file < 8; file++) {
|
|
86
|
+
const square = (0, conversion_1.indexToSquare)((rank * 8 + file));
|
|
87
|
+
const piece = config.pieces[square];
|
|
88
|
+
if (!piece) {
|
|
89
|
+
emptyCount++;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
if (emptyCount > 0) {
|
|
93
|
+
rankStr += emptyCount.toString();
|
|
94
|
+
emptyCount = 0;
|
|
95
|
+
}
|
|
96
|
+
rankStr += piece;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (emptyCount > 0) {
|
|
100
|
+
rankStr += emptyCount.toString();
|
|
101
|
+
}
|
|
102
|
+
ranks.push(rankStr);
|
|
103
|
+
}
|
|
104
|
+
const piecePlacement = ranks.join('/');
|
|
105
|
+
const activeColor = config.turn === 'white' ? 'w' : 'b';
|
|
106
|
+
let castling = '';
|
|
107
|
+
if (config.castling.whiteShort)
|
|
108
|
+
castling += 'K';
|
|
109
|
+
if (config.castling.whiteLong)
|
|
110
|
+
castling += 'Q';
|
|
111
|
+
if (config.castling.blackShort)
|
|
112
|
+
castling += 'k';
|
|
113
|
+
if (config.castling.blackLong)
|
|
114
|
+
castling += 'q';
|
|
115
|
+
if (!castling)
|
|
116
|
+
castling = '-';
|
|
117
|
+
const enPassant = config.enPassant ? config.enPassant.toLowerCase() : '-';
|
|
118
|
+
const halfMove = config.halfMove.toString();
|
|
119
|
+
const fullMove = config.fullMove.toString();
|
|
120
|
+
return `${piecePlacement} ${activeColor} ${castling} ${enPassant} ${halfMove} ${fullMove}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Convert internal moves to public moves map
|
|
124
|
+
*
|
|
125
|
+
* @param moves - Array of internal moves
|
|
126
|
+
* @returns Public moves map (from-square -> [to-squares])
|
|
127
|
+
*/
|
|
128
|
+
function movesToMap(moves) {
|
|
129
|
+
const movesMap = {};
|
|
130
|
+
for (const move of moves) {
|
|
131
|
+
const fromSquare = (0, conversion_1.indexToSquare)(move.from);
|
|
132
|
+
const toSquare = (0, conversion_1.indexToSquare)(move.to);
|
|
133
|
+
if (!movesMap[fromSquare]) {
|
|
134
|
+
movesMap[fromSquare] = [];
|
|
135
|
+
}
|
|
136
|
+
movesMap[fromSquare].push(toSquare);
|
|
137
|
+
}
|
|
138
|
+
return movesMap;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Convert internal moves from a specific square to array of to-squares
|
|
142
|
+
*
|
|
143
|
+
* @param moves - Array of internal moves
|
|
144
|
+
* @param fromIndex - From square index
|
|
145
|
+
* @returns Array of to-square strings
|
|
146
|
+
*/
|
|
147
|
+
function movesFromSquare(moves, fromIndex) {
|
|
148
|
+
return moves
|
|
149
|
+
.filter(move => move.from === fromIndex)
|
|
150
|
+
.map(move => (0, conversion_1.indexToSquare)(move.to));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Convert piece enum to piece symbol
|
|
154
|
+
*
|
|
155
|
+
* @param piece - Internal piece enum
|
|
156
|
+
* @returns Piece symbol or null if empty
|
|
157
|
+
*/
|
|
158
|
+
function pieceToSymbol(piece) {
|
|
159
|
+
switch (piece) {
|
|
160
|
+
case types_1.Piece.WHITE_KING: return 'K';
|
|
161
|
+
case types_1.Piece.WHITE_QUEEN: return 'Q';
|
|
162
|
+
case types_1.Piece.WHITE_ROOK: return 'R';
|
|
163
|
+
case types_1.Piece.WHITE_BISHOP: return 'B';
|
|
164
|
+
case types_1.Piece.WHITE_KNIGHT: return 'N';
|
|
165
|
+
case types_1.Piece.WHITE_PAWN: return 'P';
|
|
166
|
+
case types_1.Piece.BLACK_KING: return 'k';
|
|
167
|
+
case types_1.Piece.BLACK_QUEEN: return 'q';
|
|
168
|
+
case types_1.Piece.BLACK_ROOK: return 'r';
|
|
169
|
+
case types_1.Piece.BLACK_BISHOP: return 'b';
|
|
170
|
+
case types_1.Piece.BLACK_KNIGHT: return 'n';
|
|
171
|
+
case types_1.Piece.BLACK_PAWN: return 'p';
|
|
172
|
+
default: return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Convert piece symbol to piece enum
|
|
177
|
+
*
|
|
178
|
+
* @param symbol - Piece symbol
|
|
179
|
+
* @returns Internal piece enum
|
|
180
|
+
*/
|
|
181
|
+
function symbolToPiece(symbol) {
|
|
182
|
+
switch (symbol) {
|
|
183
|
+
case 'K': return types_1.Piece.WHITE_KING;
|
|
184
|
+
case 'Q': return types_1.Piece.WHITE_QUEEN;
|
|
185
|
+
case 'R': return types_1.Piece.WHITE_ROOK;
|
|
186
|
+
case 'B': return types_1.Piece.WHITE_BISHOP;
|
|
187
|
+
case 'N': return types_1.Piece.WHITE_KNIGHT;
|
|
188
|
+
case 'P': return types_1.Piece.WHITE_PAWN;
|
|
189
|
+
case 'k': return types_1.Piece.BLACK_KING;
|
|
190
|
+
case 'q': return types_1.Piece.BLACK_QUEEN;
|
|
191
|
+
case 'r': return types_1.Piece.BLACK_ROOK;
|
|
192
|
+
case 'b': return types_1.Piece.BLACK_BISHOP;
|
|
193
|
+
case 'n': return types_1.Piece.BLACK_KNIGHT;
|
|
194
|
+
case 'p': return types_1.Piece.BLACK_PAWN;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Convert color string to internal color
|
|
199
|
+
*
|
|
200
|
+
* @param color - Color string
|
|
201
|
+
* @returns Internal color enum
|
|
202
|
+
*/
|
|
203
|
+
function colorToInternal(color) {
|
|
204
|
+
return color === 'white' ? types_1.InternalColor.WHITE : types_1.InternalColor.BLACK;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Convert internal color to color string
|
|
208
|
+
*
|
|
209
|
+
* @param color - Internal color enum
|
|
210
|
+
* @returns Color string
|
|
211
|
+
*/
|
|
212
|
+
function internalToColor(color) {
|
|
213
|
+
return color === types_1.InternalColor.WHITE ? 'white' : 'black';
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Normalize square string to uppercase (A1-H8)
|
|
217
|
+
* V1 API accepts case-insensitive input
|
|
218
|
+
*
|
|
219
|
+
* @param square - Square string (case-insensitive)
|
|
220
|
+
* @returns Normalized uppercase square string
|
|
221
|
+
*/
|
|
222
|
+
function normalizeSquare(square) {
|
|
223
|
+
return square.toUpperCase();
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=APIAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIAdapter.js","sourceRoot":"","sources":["../../src/adapters/APIAdapter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAsBH,sCA0BC;AAQD,sCAOC;AAQD,kCA4CC;AAQD,gCAeC;AASD,0CAIC;AAQD,sCAgBC;AAQD,sCAeC;AAQD,0CAEC;AAQD,0CAEC;AASD,0CAEC;AAnOD,oCAUkB;AAClB,oDAAmE;AAGnE;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAoB;IAC9C,MAAM,MAAM,GAAgC,EAAE,CAAC;IAE/C,mCAAmC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,aAAK,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,IAAA,0BAAa,EAAC,CAAgB,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,MAAM,EAAE,CAAC;gBACT,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;YAC5B,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO;QACH,MAAM;QACN,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,qBAAa,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;QAC5D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pC,KAAK,GAAG,CAAC,CAAC,OAAO,aAAK,CAAC,YAAY,CAAC;QACpC,KAAK,GAAG,CAAC,CAAC,OAAO,aAAK,CAAC,UAAU,CAAC;IACtC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,KAAY;IACxC,OAAO,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAa,CAAC,KAAK,CAAC,CAAC,CAAC,qBAAa,CAAC,KAAK,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,KAAoB;IAChD,OAAO,KAAK,KAAK,qBAAa,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC1C,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Engine for js-chess-engine v2
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the AI search and provides level-based difficulty settings.
|
|
5
|
+
*/
|
|
6
|
+
import { InternalBoard, InternalMove } from '../types';
|
|
7
|
+
import { AILevel } from '../types/ai.types';
|
|
8
|
+
/**
|
|
9
|
+
* AI difficulty level configuration
|
|
10
|
+
* Maps AI levels (1-5) to search depths
|
|
11
|
+
*/
|
|
12
|
+
interface LevelConfig {
|
|
13
|
+
baseDepth: number;
|
|
14
|
+
extendedDepth: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* AI Engine class
|
|
18
|
+
* Manages AI move selection and search
|
|
19
|
+
*/
|
|
20
|
+
export declare class AIEngine {
|
|
21
|
+
private search;
|
|
22
|
+
private currentTTSize;
|
|
23
|
+
constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Find the best move for the current position
|
|
26
|
+
*
|
|
27
|
+
* @param board - Current board state
|
|
28
|
+
* @param level - AI difficulty level (1-5, default 3)
|
|
29
|
+
* @param ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256 MB, default 16)
|
|
30
|
+
* @returns Best move found by the AI
|
|
31
|
+
*/
|
|
32
|
+
findBestMove(board: InternalBoard, level?: AILevel, ttSizeMB?: number): InternalMove | null;
|
|
33
|
+
/**
|
|
34
|
+
* Get the search depth for a given AI level
|
|
35
|
+
*
|
|
36
|
+
* @param level - AI level (1-5)
|
|
37
|
+
* @returns Depth configuration
|
|
38
|
+
*/
|
|
39
|
+
static getLevelDepth(level: AILevel): LevelConfig;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=AIEngine.d.ts.map
|
|
@@ -0,0 +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;AAcD;;;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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI Engine for js-chess-engine v2
|
|
4
|
+
*
|
|
5
|
+
* Orchestrates the AI search and provides level-based difficulty settings.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AIEngine = void 0;
|
|
9
|
+
const Search_1 = require("./Search");
|
|
10
|
+
/**
|
|
11
|
+
* AI level to depth mapping
|
|
12
|
+
* Based on v1 behavior for compatibility
|
|
13
|
+
*/
|
|
14
|
+
const LEVEL_CONFIG = {
|
|
15
|
+
1: { baseDepth: 1, extendedDepth: 2 }, // Very easy
|
|
16
|
+
2: { baseDepth: 2, extendedDepth: 3 }, // Easy
|
|
17
|
+
3: { baseDepth: 3, extendedDepth: 4 }, // Medium (default)
|
|
18
|
+
4: { baseDepth: 4, extendedDepth: 5 }, // Hard
|
|
19
|
+
5: { baseDepth: 5, extendedDepth: 6 }, // Very hard
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* AI Engine class
|
|
23
|
+
* Manages AI move selection and search
|
|
24
|
+
*/
|
|
25
|
+
class AIEngine {
|
|
26
|
+
search;
|
|
27
|
+
currentTTSize = 16;
|
|
28
|
+
constructor() {
|
|
29
|
+
this.search = new Search_1.Search(this.currentTTSize);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Find the best move for the current position
|
|
33
|
+
*
|
|
34
|
+
* @param board - Current board state
|
|
35
|
+
* @param level - AI difficulty level (1-5, default 3)
|
|
36
|
+
* @param ttSizeMB - Transposition table size in MB (0 to disable, 0.25-256 MB, default 16)
|
|
37
|
+
* @returns Best move found by the AI
|
|
38
|
+
*/
|
|
39
|
+
findBestMove(board, level = 3, ttSizeMB = 16) {
|
|
40
|
+
// Recreate search if TT size changed
|
|
41
|
+
if (ttSizeMB !== this.currentTTSize) {
|
|
42
|
+
this.currentTTSize = ttSizeMB;
|
|
43
|
+
this.search = new Search_1.Search(ttSizeMB);
|
|
44
|
+
}
|
|
45
|
+
// Get depth configuration for this level
|
|
46
|
+
const config = LEVEL_CONFIG[level];
|
|
47
|
+
// Perform search
|
|
48
|
+
const result = this.search.findBestMove(board, config.baseDepth, config.extendedDepth);
|
|
49
|
+
return result ? result.move : null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the search depth for a given AI level
|
|
53
|
+
*
|
|
54
|
+
* @param level - AI level (1-5)
|
|
55
|
+
* @returns Depth configuration
|
|
56
|
+
*/
|
|
57
|
+
static getLevelDepth(level) {
|
|
58
|
+
return LEVEL_CONFIG[level];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.AIEngine = AIEngine;
|
|
62
|
+
//# sourceMappingURL=AIEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIEngine.js","sourceRoot":"","sources":["../../src/ai/AIEngine.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,qCAAkC;AAWlC;;;GAGG;AACH,MAAM,YAAY,GAAiC;IAC/C,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAG,YAAY;IACpD,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAG,OAAO;IAC/C,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAG,mBAAmB;IAC3D,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAG,OAAO;IAC/C,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAG,YAAY;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAa,QAAQ;IACT,MAAM,CAAS;IACf,aAAa,GAAW,EAAE,CAAC;IAEnC;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACH,YAAY,CAAC,KAAoB,EAAE,QAAiB,CAAC,EAAE,WAAmB,EAAE;QACxE,qCAAqC;QACrC,IAAI,QAAQ,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Position evaluator for js-chess-engine v2
|
|
3
|
+
*
|
|
4
|
+
* Evaluates chess positions using material count and piece-square tables.
|
|
5
|
+
* Based on v1 implementation for API parity.
|
|
6
|
+
*/
|
|
7
|
+
import { InternalBoard, InternalColor } from '../types';
|
|
8
|
+
import { Score } from '../types/ai.types';
|
|
9
|
+
/**
|
|
10
|
+
* Score bounds for special positions
|
|
11
|
+
*/
|
|
12
|
+
export declare const SCORE_MIN = -1000;
|
|
13
|
+
export declare const SCORE_MAX = 1000;
|
|
14
|
+
export declare class Evaluator {
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate a position from the perspective of the specified color
|
|
17
|
+
*
|
|
18
|
+
* @param board - Board to evaluate
|
|
19
|
+
* @param playerColor - Color to evaluate for (positive = good for this color)
|
|
20
|
+
* @param depth - Current search depth (used for mate scoring)
|
|
21
|
+
* @returns Score in centipawns (positive = good for playerColor)
|
|
22
|
+
*/
|
|
23
|
+
static evaluate(board: InternalBoard, playerColor: InternalColor, depth?: number): Score;
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate material balance
|
|
26
|
+
*
|
|
27
|
+
* @param board - Board to evaluate
|
|
28
|
+
* @param playerColor - Color to evaluate for
|
|
29
|
+
* @returns Material score
|
|
30
|
+
*/
|
|
31
|
+
private static evaluateMaterial;
|
|
32
|
+
/**
|
|
33
|
+
* Evaluate piece-square table bonuses
|
|
34
|
+
*
|
|
35
|
+
* @param board - Board to evaluate
|
|
36
|
+
* @param playerColor - Color to evaluate for
|
|
37
|
+
* @returns Positional score
|
|
38
|
+
*/
|
|
39
|
+
private static evaluatePieceSquareTables;
|
|
40
|
+
/**
|
|
41
|
+
* Get total material value on the board (used for endgame detection)
|
|
42
|
+
*
|
|
43
|
+
* @param board - Board to evaluate
|
|
44
|
+
* @returns Total material value
|
|
45
|
+
*/
|
|
46
|
+
static getTotalMaterialValue(board: InternalBoard): number;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=Evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Evaluator.d.ts","sourceRoot":"","sources":["../../src/ai/Evaluator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAS,aAAa,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAsB1C;;GAEG;AACH,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,SAAS,OAAO,CAAC;AA+H9B,qBAAa,SAAS;IAClB;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,GAAE,MAAU,GAAG,KAAK;IAwB3F;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAoB/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA0BxC;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM;CAY7D"}
|