@weshell/chess.js 0.0.0-stage → 1.0.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 (51) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +87 -2
  3. package/dist/attack.d.ts +32 -0
  4. package/dist/attack.d.ts.map +1 -0
  5. package/dist/attack.js +103 -0
  6. package/dist/attack.js.map +1 -0
  7. package/dist/board.d.ts +33 -0
  8. package/dist/board.d.ts.map +1 -0
  9. package/dist/board.js +49 -0
  10. package/dist/board.js.map +1 -0
  11. package/dist/chess.d.ts +232 -0
  12. package/dist/chess.d.ts.map +1 -0
  13. package/dist/chess.js +1335 -0
  14. package/dist/chess.js.map +1 -0
  15. package/dist/fen.d.ts +38 -0
  16. package/dist/fen.d.ts.map +1 -0
  17. package/dist/fen.js +308 -0
  18. package/dist/fen.js.map +1 -0
  19. package/dist/hash.d.ts +34 -0
  20. package/dist/hash.d.ts.map +1 -0
  21. package/dist/hash.js +98 -0
  22. package/dist/hash.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/move.d.ts +55 -0
  28. package/dist/move.d.ts.map +1 -0
  29. package/dist/move.js +79 -0
  30. package/dist/move.js.map +1 -0
  31. package/dist/movegen.d.ts +34 -0
  32. package/dist/movegen.d.ts.map +1 -0
  33. package/dist/movegen.js +242 -0
  34. package/dist/movegen.js.map +1 -0
  35. package/dist/node.d.ts +8 -0
  36. package/dist/node.d.ts.map +1 -0
  37. package/dist/node.js +2 -0
  38. package/dist/node.js.map +1 -0
  39. package/dist/notation.d.ts +33 -0
  40. package/dist/notation.d.ts.map +1 -0
  41. package/dist/notation.js +257 -0
  42. package/dist/notation.js.map +1 -0
  43. package/dist/pgn.d.ts +12 -0
  44. package/dist/pgn.d.ts.map +1 -0
  45. package/dist/pgn.js +1347 -0
  46. package/dist/pgn.js.map +1 -0
  47. package/dist/types.d.ts +118 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +237 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +45 -4
@@ -0,0 +1,257 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2025, Jeff Hlywa (jhlywa@gmail.com)
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ * this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ * POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+ import { BITS, KING, Ox88, PAWN, SAN_NULLMOVE } from './types.js';
28
+ import { algebraic, file, rank } from './board.js';
29
+ // this function is used to uniquely identify ambiguous moves
30
+ export function getDisambiguator(move, moves) {
31
+ const from = move.from;
32
+ const to = move.to;
33
+ const piece = move.piece;
34
+ let ambiguities = 0;
35
+ let sameRank = 0;
36
+ let sameFile = 0;
37
+ for (let i = 0, len = moves.length; i < len; i++) {
38
+ const ambigFrom = moves[i].from;
39
+ const ambigTo = moves[i].to;
40
+ const ambigPiece = moves[i].piece;
41
+ /*
42
+ * if a move of the same piece type ends on the same to square, we'll need
43
+ * to add a disambiguator to the algebraic notation
44
+ */
45
+ if (piece === ambigPiece && from !== ambigFrom && to === ambigTo) {
46
+ ambiguities++;
47
+ if (rank(from) === rank(ambigFrom)) {
48
+ sameRank++;
49
+ }
50
+ if (file(from) === file(ambigFrom)) {
51
+ sameFile++;
52
+ }
53
+ }
54
+ }
55
+ if (ambiguities > 0) {
56
+ if (sameRank > 0 && sameFile > 0) {
57
+ /*
58
+ * if there exists a similar moving piece on the same rank and file as
59
+ * the move in question, use the square as the disambiguator
60
+ */
61
+ return algebraic(from);
62
+ }
63
+ else if (sameFile > 0) {
64
+ /*
65
+ * if the moving piece rests on the same file, use the rank symbol as the
66
+ * disambiguator
67
+ */
68
+ return algebraic(from).charAt(1);
69
+ }
70
+ else {
71
+ // else use the file symbol
72
+ return algebraic(from).charAt(0);
73
+ }
74
+ }
75
+ return '';
76
+ }
77
+ export function inferPieceType(san) {
78
+ let pieceType = san.charAt(0);
79
+ if (pieceType >= 'a' && pieceType <= 'h') {
80
+ const matches = san.match(/[a-h]\d.*[a-h]\d/);
81
+ if (matches) {
82
+ return undefined;
83
+ }
84
+ return PAWN;
85
+ }
86
+ pieceType = pieceType.toLowerCase();
87
+ if (pieceType === 'o') {
88
+ return KING;
89
+ }
90
+ return pieceType;
91
+ }
92
+ // parses all of the decorators out of a SAN string
93
+ export function strippedSan(move) {
94
+ return move.replace(/=/, '').replace(/[+#]?[?!]*$/, '');
95
+ }
96
+ /*
97
+ * Convert a move from 0x88 coordinates to Standard Algebraic Notation
98
+ * (SAN), without the check/checkmate suffix. The caller is responsible
99
+ * for appending '+'/'#' (which requires making the move).
100
+ */
101
+ export function moveToSan(move, moves) {
102
+ let output = '';
103
+ if (move.flags & BITS.KSIDE_CASTLE) {
104
+ output = 'O-O';
105
+ }
106
+ else if (move.flags & BITS.QSIDE_CASTLE) {
107
+ output = 'O-O-O';
108
+ }
109
+ else if (move.flags & BITS.NULL_MOVE) {
110
+ return SAN_NULLMOVE;
111
+ }
112
+ else {
113
+ if (move.piece !== PAWN) {
114
+ const disambiguator = getDisambiguator(move, moves);
115
+ output += move.piece.toUpperCase() + disambiguator;
116
+ }
117
+ if (move.flags & (BITS.CAPTURE | BITS.EP_CAPTURE)) {
118
+ if (move.piece === PAWN) {
119
+ output += algebraic(move.from)[0];
120
+ }
121
+ output += 'x';
122
+ }
123
+ output += algebraic(move.to);
124
+ if (move.promotion) {
125
+ output += '=' + move.promotion.toUpperCase();
126
+ }
127
+ }
128
+ return output;
129
+ }
130
+ // convert a move from Standard Algebraic Notation (SAN) to 0x88 coordinates
131
+ export function moveFromSan(move, turn, legalMoves, strict = false) {
132
+ // strip off any move decorations: e.g Nf3+?! becomes Nf3
133
+ let cleanMove = strippedSan(move);
134
+ if (!strict) {
135
+ if (cleanMove === '0-0') {
136
+ cleanMove = 'O-O';
137
+ }
138
+ else if (cleanMove === '0-0-0') {
139
+ cleanMove = 'O-O-O';
140
+ }
141
+ }
142
+ //first implementation of null with a dummy move (black king moves from a8 to a8), maybe this can be implemented better
143
+ if (cleanMove == SAN_NULLMOVE) {
144
+ const res = {
145
+ color: turn,
146
+ from: 0,
147
+ to: 0,
148
+ piece: 'k',
149
+ flags: BITS.NULL_MOVE,
150
+ };
151
+ return res;
152
+ }
153
+ let pieceType = inferPieceType(cleanMove);
154
+ let moves = pieceType
155
+ ? legalMoves.filter((m) => m.piece === pieceType)
156
+ : legalMoves;
157
+ // strict parser
158
+ for (let i = 0, len = moves.length; i < len; i++) {
159
+ if (cleanMove === strippedSan(moveToSan(moves[i], moves))) {
160
+ return moves[i];
161
+ }
162
+ }
163
+ // the strict parser failed
164
+ if (strict) {
165
+ return null;
166
+ }
167
+ let piece = undefined;
168
+ let matches = undefined;
169
+ let from = undefined;
170
+ let to = undefined;
171
+ let promotion = undefined;
172
+ /*
173
+ * The default permissive (non-strict) parser allows the user to parse
174
+ * non-standard chess notations. This parser is only run after the strict
175
+ * Standard Algebraic Notation (SAN) parser has failed.
176
+ *
177
+ * When running the permissive parser, we'll run a regex to grab the piece, the
178
+ * to/from square, and an optional promotion piece. This regex will
179
+ * parse common non-standard notation like: Pe2-e4, Rc1c4, Qf3xf7,
180
+ * f7f8q, b1c3
181
+ *
182
+ * NOTE: Some positions and moves may be ambiguous when using the permissive
183
+ * parser. For example, in this position: 6k1/8/8/A7/8/8/8/BN4K1 w - - 0 1,
184
+ * the move b1c3 may be interpreted as Nc3 or B1c3 (a disambiguated bishop
185
+ * move). In these cases, the permissive parser will default to the most
186
+ * basic interpretation (which is b1c3 parsing to Nc3).
187
+ */
188
+ let overlyDisambiguated = false;
189
+ matches = cleanMove.match(/([pnbrqkPNBRQK])?([a-h][1-8])x?-?([a-h][1-8])([qrbnQRBN])?/);
190
+ if (matches) {
191
+ piece = matches[1];
192
+ from = matches[2];
193
+ to = matches[3];
194
+ promotion = matches[4];
195
+ if (from.length == 1) {
196
+ overlyDisambiguated = true;
197
+ }
198
+ }
199
+ else {
200
+ /*
201
+ * The [a-h]?[1-8]? portion of the regex below handles moves that may be
202
+ * overly disambiguated (e.g. Nge7 is unnecessary and non-standard when
203
+ * there is one legal knight move to e7). In this case, the value of
204
+ * 'from' variable will be a rank or file, not a square.
205
+ */
206
+ matches = cleanMove.match(/([pnbrqkPNBRQK])?([a-h]?[1-8]?)x?-?([a-h][1-8])([qrbnQRBN])?/);
207
+ if (matches) {
208
+ piece = matches[1];
209
+ from = matches[2];
210
+ to = matches[3];
211
+ promotion = matches[4];
212
+ if (from.length == 1) {
213
+ overlyDisambiguated = true;
214
+ }
215
+ }
216
+ }
217
+ pieceType = inferPieceType(cleanMove);
218
+ moves = piece
219
+ ? legalMoves.filter((m) => m.piece === piece)
220
+ : pieceType
221
+ ? legalMoves.filter((m) => m.piece === pieceType)
222
+ : legalMoves;
223
+ if (!to) {
224
+ return null;
225
+ }
226
+ for (let i = 0, len = moves.length; i < len; i++) {
227
+ if (!from) {
228
+ // if there is no from square, it could be just 'x' missing from a capture
229
+ if (cleanMove ===
230
+ strippedSan(moveToSan(moves[i], moves)).replace('x', '')) {
231
+ return moves[i];
232
+ }
233
+ // hand-compare move properties with the results from our permissive regex
234
+ }
235
+ else if ((!piece || piece.toLowerCase() == moves[i].piece) &&
236
+ Ox88[from] == moves[i].from &&
237
+ Ox88[to] == moves[i].to &&
238
+ (!promotion || promotion.toLowerCase() == moves[i].promotion)) {
239
+ return moves[i];
240
+ }
241
+ else if (overlyDisambiguated) {
242
+ /*
243
+ * SPECIAL CASE: we parsed a move string that may have an unneeded
244
+ * rank/file disambiguator (e.g. Nge7). The 'from' variable will
245
+ */
246
+ const square = algebraic(moves[i].from);
247
+ if ((!piece || piece.toLowerCase() == moves[i].piece) &&
248
+ Ox88[to] == moves[i].to &&
249
+ (from == square[0] || from == square[1]) &&
250
+ (!promotion || promotion.toLowerCase() == moves[i].promotion)) {
251
+ return moves[i];
252
+ }
253
+ }
254
+ }
255
+ return null;
256
+ }
257
+ //# sourceMappingURL=notation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notation.js","sourceRoot":"","sources":["../src/notation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAElD,6DAA6D;AAC7D,MAAM,UAAU,gBAAgB,CAC9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;gBACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAA;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
package/dist/pgn.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ declare const peg$allowedStartRules: string[];
2
+ declare function peg$SyntaxError(message: any, expected: any, found: any, location: any): Error;
3
+ declare class peg$SyntaxError {
4
+ constructor(message: any, expected: any, found: any, location: any);
5
+ format(sources: any): string;
6
+ }
7
+ declare namespace peg$SyntaxError {
8
+ function buildMessage(expected: any, found: any): string;
9
+ }
10
+ declare function peg$parse(input: any, options: any): any;
11
+ export { peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse };
12
+ //# sourceMappingURL=pgn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgn.d.ts","sourceRoot":"","sources":["../src/pgn.js"],"names":[],"mappings":"AAwxCA,8CAEE;AAptCF,gGAWC;;IAXD,oEAWC;IAYD,6BAgCC;;;IAED,yDAkGC;;AAED,0DAmjCC"}