@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.
- package/LICENSE +23 -0
- package/README.md +87 -2
- package/dist/attack.d.ts +32 -0
- package/dist/attack.d.ts.map +1 -0
- package/dist/attack.js +103 -0
- package/dist/attack.js.map +1 -0
- package/dist/board.d.ts +33 -0
- package/dist/board.d.ts.map +1 -0
- package/dist/board.js +49 -0
- package/dist/board.js.map +1 -0
- package/dist/chess.d.ts +232 -0
- package/dist/chess.d.ts.map +1 -0
- package/dist/chess.js +1335 -0
- package/dist/chess.js.map +1 -0
- package/dist/fen.d.ts +38 -0
- package/dist/fen.d.ts.map +1 -0
- package/dist/fen.js +308 -0
- package/dist/fen.js.map +1 -0
- package/dist/hash.d.ts +34 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +98 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/move.d.ts +55 -0
- package/dist/move.d.ts.map +1 -0
- package/dist/move.js +79 -0
- package/dist/move.js.map +1 -0
- package/dist/movegen.d.ts +34 -0
- package/dist/movegen.d.ts.map +1 -0
- package/dist/movegen.js +242 -0
- package/dist/movegen.js.map +1 -0
- package/dist/node.d.ts +8 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2 -0
- package/dist/node.js.map +1 -0
- package/dist/notation.d.ts +33 -0
- package/dist/notation.d.ts.map +1 -0
- package/dist/notation.js +257 -0
- package/dist/notation.js.map +1 -0
- package/dist/pgn.d.ts +12 -0
- package/dist/pgn.d.ts.map +1 -0
- package/dist/pgn.js +1347 -0
- package/dist/pgn.js.map +1 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +237 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -4
package/dist/move.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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 type { Color, InternalMove, PieceSymbol, Square } from './types.js';
|
|
28
|
+
export declare class Move {
|
|
29
|
+
color: Color;
|
|
30
|
+
from: Square;
|
|
31
|
+
to: Square;
|
|
32
|
+
piece: PieceSymbol;
|
|
33
|
+
captured?: PieceSymbol;
|
|
34
|
+
promotion?: PieceSymbol;
|
|
35
|
+
rookFrom?: Square;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated This field is deprecated and will be removed in version 2.0.0.
|
|
38
|
+
* Please use move descriptor functions instead: `isCapture`, `isPromotion`,
|
|
39
|
+
* `isEnPassant`, `isKingsideCastle`, `isQueensideCastle`, `isCastle`, and
|
|
40
|
+
* `isBigPawn`
|
|
41
|
+
*/
|
|
42
|
+
flags: string;
|
|
43
|
+
san: string;
|
|
44
|
+
lan: string;
|
|
45
|
+
before: string;
|
|
46
|
+
after: string;
|
|
47
|
+
constructor(internal: InternalMove, san: string, before: string, after: string);
|
|
48
|
+
isCapture(): boolean;
|
|
49
|
+
isPromotion(): boolean;
|
|
50
|
+
isEnPassant(): boolean;
|
|
51
|
+
isKingsideCastle(): boolean;
|
|
52
|
+
isQueensideCastle(): boolean;
|
|
53
|
+
isBigPawn(): boolean;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=move.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../src/move.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAI1E,qBAAa,IAAI;IACf,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,WAAW,CAAA;IAClB,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,WAAW,CAAA;IAMvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;gBAGX,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM;IAuCf,SAAS;IAIT,WAAW;IAIX,WAAW;IAIX,gBAAgB;IAIhB,iBAAiB;IAIjB,SAAS;CAGV"}
|
package/dist/move.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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, FLAGS } from './types.js';
|
|
28
|
+
import { algebraic } from './board.js';
|
|
29
|
+
export class Move {
|
|
30
|
+
constructor(internal, san, before, after) {
|
|
31
|
+
const { color, piece, from, to, flags, captured, promotion } = internal;
|
|
32
|
+
const fromAlgebraic = algebraic(from);
|
|
33
|
+
const toAlgebraic = algebraic(to);
|
|
34
|
+
this.color = color;
|
|
35
|
+
this.piece = piece;
|
|
36
|
+
this.from = fromAlgebraic;
|
|
37
|
+
this.to = toAlgebraic;
|
|
38
|
+
this.san = san;
|
|
39
|
+
this.lan = fromAlgebraic + toAlgebraic;
|
|
40
|
+
this.before = before;
|
|
41
|
+
this.after = after;
|
|
42
|
+
// Build the text representation of the move flags
|
|
43
|
+
this.flags = '';
|
|
44
|
+
for (const flag in BITS) {
|
|
45
|
+
if (BITS[flag] & flags) {
|
|
46
|
+
this.flags += FLAGS[flag];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (captured) {
|
|
50
|
+
this.captured = captured;
|
|
51
|
+
}
|
|
52
|
+
if (internal.rookFrom !== undefined) {
|
|
53
|
+
this.rookFrom = algebraic(internal.rookFrom);
|
|
54
|
+
}
|
|
55
|
+
if (promotion) {
|
|
56
|
+
this.promotion = promotion;
|
|
57
|
+
this.lan += promotion;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
isCapture() {
|
|
61
|
+
return this.flags.indexOf(FLAGS['CAPTURE']) > -1;
|
|
62
|
+
}
|
|
63
|
+
isPromotion() {
|
|
64
|
+
return this.flags.indexOf(FLAGS['PROMOTION']) > -1;
|
|
65
|
+
}
|
|
66
|
+
isEnPassant() {
|
|
67
|
+
return this.flags.indexOf(FLAGS['EP_CAPTURE']) > -1;
|
|
68
|
+
}
|
|
69
|
+
isKingsideCastle() {
|
|
70
|
+
return this.flags.indexOf(FLAGS['KSIDE_CASTLE']) > -1;
|
|
71
|
+
}
|
|
72
|
+
isQueensideCastle() {
|
|
73
|
+
return this.flags.indexOf(FLAGS['QSIDE_CASTLE']) > -1;
|
|
74
|
+
}
|
|
75
|
+
isBigPawn() {
|
|
76
|
+
return this.flags.indexOf(FLAGS['BIG_PAWN']) > -1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=move.js.map
|
package/dist/move.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move.js","sourceRoot":"","sources":["../src/move.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,OAAO,IAAI;IA2Bf,YACE,QAAsB,EACtB,GAAW,EACX,MAAc,EACd,KAAa;QAEb,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAA;QAEvE,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;QACrC,MAAM,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,CAAA;QAEjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB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C,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACvD,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACvD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 type { CastlingRookSquares, Color, InternalMove, Piece, PieceSymbol, Square } from './types.js';
|
|
28
|
+
export declare function addMove(moves: InternalMove[], color: Color, from: number, to: number, piece: PieceSymbol, captured?: PieceSymbol | undefined, flags?: number, rookFrom?: number | undefined): void;
|
|
29
|
+
export declare function addCastlingMove(moves: InternalMove[], us: Color, them: Color, side: number, board: Piece[], kings: Record<Color, number>, castling: Record<Color, number>, castlingRooks: Record<Color, CastlingRookSquares>): void;
|
|
30
|
+
export declare function generatePseudoMoves(board: Piece[], turn: Color, epSquare: number, kings: Record<Color, number>, castling: Record<Color, number>, castlingRooks: Record<Color, CastlingRookSquares>, { piece: forPiece, square, }?: {
|
|
31
|
+
piece?: PieceSymbol;
|
|
32
|
+
square?: Square;
|
|
33
|
+
}): InternalMove[];
|
|
34
|
+
//# sourceMappingURL=movegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movegen.d.ts","sourceRoot":"","sources":["../src/movegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,KAAK,EACL,YAAY,EACZ,KAAK,EACL,WAAW,EACX,MAAM,EACP,MAAM,YAAY,CAAA;AAkBnB,wBAAgB,OAAO,CACrB,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,WAAW,EAClB,QAAQ,GAAE,WAAW,GAAG,SAAqB,EAC7C,KAAK,GAAE,MAAoB,EAC3B,QAAQ,GAAE,MAAM,GAAG,SAAqB,QA4BzC;AAYD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EAAE,EACrB,EAAE,EAAE,KAAK,EACT,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,EAAE,EACd,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAC5B,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAC/B,aAAa,EAAE,MAAM,CAAC,KAAK,EAAE,mBAAmB,CAAC,QAgGlD;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EAAE,EACd,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAC5B,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAC/B,aAAa,EAAE,MAAM,CAAC,KAAK,EAAE,mBAAmB,CAAC,EACjD,EACE,KAAK,EAAE,QAAQ,EACf,MAAM,GACP,GAAE;IAAE,KAAK,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,YAAY,EAAE,CAiJhB"}
|
package/dist/movegen.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
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, EMPTY, KING, KNIGHT, Ox88, PAWN, PAWN_OFFSETS, PIECE_OFFSETS, PROMOTIONS, RANK_1, RANK_8, SECOND_RANK, } from './types.js';
|
|
28
|
+
import { rank, swapColor } from './board.js';
|
|
29
|
+
import { attacked } from './attack.js';
|
|
30
|
+
export function addMove(moves, color, from, to, piece, captured = undefined, flags = BITS.NORMAL, rookFrom = undefined) {
|
|
31
|
+
const r = rank(to);
|
|
32
|
+
if (piece === PAWN && (r === RANK_1 || r === RANK_8)) {
|
|
33
|
+
for (let i = 0; i < PROMOTIONS.length; i++) {
|
|
34
|
+
const promotion = PROMOTIONS[i];
|
|
35
|
+
moves.push({
|
|
36
|
+
color,
|
|
37
|
+
from,
|
|
38
|
+
to,
|
|
39
|
+
piece,
|
|
40
|
+
captured,
|
|
41
|
+
promotion,
|
|
42
|
+
flags: flags | BITS.PROMOTION,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
moves.push({
|
|
48
|
+
color,
|
|
49
|
+
from,
|
|
50
|
+
to,
|
|
51
|
+
piece,
|
|
52
|
+
captured,
|
|
53
|
+
flags,
|
|
54
|
+
rookFrom,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/*
|
|
59
|
+
* CHESS960 castling generation, mirroring chessops castlingDest:
|
|
60
|
+
*
|
|
61
|
+
* - The king may not castle out of, through, or into check.
|
|
62
|
+
* - All squares on the king's and rook's paths (excluding their origin
|
|
63
|
+
* squares) must be empty.
|
|
64
|
+
* - The destination is checked with the king lifted off the board and the
|
|
65
|
+
* rook already relocated, which also covers the Chess960 corner cases
|
|
66
|
+
* where the king passes over or lands on the rook's origin square.
|
|
67
|
+
*/
|
|
68
|
+
export function addCastlingMove(moves, us, them, side, board, kings, castling, castlingRooks) {
|
|
69
|
+
if (!(castling[us] & side)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const rookFrom = side === BITS.KSIDE_CASTLE
|
|
73
|
+
? castlingRooks[us].kside
|
|
74
|
+
: castlingRooks[us].qside;
|
|
75
|
+
const kingFrom = kings[us];
|
|
76
|
+
if (rookFrom === EMPTY || kingFrom === EMPTY) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// king and rook destinations are fixed: g/c and f/d files
|
|
80
|
+
const kingTo = side === BITS.KSIDE_CASTLE
|
|
81
|
+
? us === 'w'
|
|
82
|
+
? Ox88.g1
|
|
83
|
+
: Ox88.g8
|
|
84
|
+
: us === 'w'
|
|
85
|
+
? Ox88.c1
|
|
86
|
+
: Ox88.c8;
|
|
87
|
+
const rookTo = side === BITS.KSIDE_CASTLE ? kingTo - 1 : kingTo + 1;
|
|
88
|
+
// the king may not castle while in check
|
|
89
|
+
if (attacked(board, them, kingFrom)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// every square on the king's and rook's paths must be empty,
|
|
93
|
+
// except the king's and rook's origin squares
|
|
94
|
+
const path = new Set();
|
|
95
|
+
for (let sq = Math.min(rookFrom, rookTo); sq <= Math.max(rookFrom, rookTo); sq++) {
|
|
96
|
+
path.add(sq);
|
|
97
|
+
}
|
|
98
|
+
for (let sq = Math.min(kingFrom, kingTo); sq <= Math.max(kingFrom, kingTo); sq++) {
|
|
99
|
+
path.add(sq);
|
|
100
|
+
}
|
|
101
|
+
path.delete(kingFrom);
|
|
102
|
+
path.delete(rookFrom);
|
|
103
|
+
for (const sq of path) {
|
|
104
|
+
if (board[sq]) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// lift the king so sliders pass through its origin square
|
|
109
|
+
const kingPiece = board[kingFrom];
|
|
110
|
+
if (!kingPiece) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
delete board[kingFrom];
|
|
114
|
+
let ok = true;
|
|
115
|
+
// every square the king crosses must be safe
|
|
116
|
+
for (let sq = Math.min(kingFrom, kingTo) + 1; sq < Math.max(kingFrom, kingTo); sq++) {
|
|
117
|
+
if (attacked(board, them, sq)) {
|
|
118
|
+
ok = false;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// the destination must be safe with the rook already relocated
|
|
123
|
+
const rookPiece = board[rookFrom];
|
|
124
|
+
if (ok && rookPiece) {
|
|
125
|
+
delete board[rookFrom];
|
|
126
|
+
board[rookTo] = rookPiece;
|
|
127
|
+
ok = !attacked(board, them, kingTo);
|
|
128
|
+
board[rookFrom] = rookPiece;
|
|
129
|
+
if (rookTo !== rookFrom) {
|
|
130
|
+
delete board[rookTo];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// restore the king
|
|
134
|
+
board[kingFrom] = kingPiece;
|
|
135
|
+
if (ok) {
|
|
136
|
+
addMove(moves, us, kingFrom, kingTo, KING, undefined, side, rookFrom);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export function generatePseudoMoves(board, turn, epSquare, kings, castling, castlingRooks, { piece: forPiece, square, } = {}) {
|
|
140
|
+
const forSquare = square ? square.toLowerCase() : undefined;
|
|
141
|
+
const moves = [];
|
|
142
|
+
const us = turn;
|
|
143
|
+
const them = swapColor(us);
|
|
144
|
+
let firstSquare = Ox88.a8;
|
|
145
|
+
let lastSquare = Ox88.h1;
|
|
146
|
+
let singleSquare = false;
|
|
147
|
+
// are we generating moves for a single square?
|
|
148
|
+
if (forSquare) {
|
|
149
|
+
// illegal square, return empty moves
|
|
150
|
+
if (!(forSquare in Ox88)) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
firstSquare = lastSquare = Ox88[forSquare];
|
|
155
|
+
singleSquare = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (let from = firstSquare; from <= lastSquare; from++) {
|
|
159
|
+
// did we run off the end of the board
|
|
160
|
+
if (from & 0x88) {
|
|
161
|
+
from += 7;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
// empty square or opponent, skip
|
|
165
|
+
if (!board[from] || board[from].color === them) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const { type } = board[from];
|
|
169
|
+
let to;
|
|
170
|
+
if (type === PAWN) {
|
|
171
|
+
if (forPiece && forPiece !== type)
|
|
172
|
+
continue;
|
|
173
|
+
// single square, non-capturing
|
|
174
|
+
to = from + PAWN_OFFSETS[us][0];
|
|
175
|
+
if (!board[to]) {
|
|
176
|
+
addMove(moves, us, from, to, PAWN);
|
|
177
|
+
// double square
|
|
178
|
+
to = from + PAWN_OFFSETS[us][1];
|
|
179
|
+
if (SECOND_RANK[us] === rank(from) && !board[to]) {
|
|
180
|
+
addMove(moves, us, from, to, PAWN, undefined, BITS.BIG_PAWN);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// pawn captures
|
|
184
|
+
for (let j = 2; j < 4; j++) {
|
|
185
|
+
to = from + PAWN_OFFSETS[us][j];
|
|
186
|
+
if (to & 0x88)
|
|
187
|
+
continue;
|
|
188
|
+
if (board[to]?.color === them) {
|
|
189
|
+
addMove(moves, us, from, to, PAWN, board[to].type, BITS.CAPTURE);
|
|
190
|
+
}
|
|
191
|
+
else if (to === epSquare) {
|
|
192
|
+
addMove(moves, us, from, to, PAWN, PAWN, BITS.EP_CAPTURE);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if (forPiece && forPiece !== type)
|
|
198
|
+
continue;
|
|
199
|
+
for (let j = 0, len = PIECE_OFFSETS[type].length; j < len; j++) {
|
|
200
|
+
const offset = PIECE_OFFSETS[type][j];
|
|
201
|
+
to = from;
|
|
202
|
+
while (true) {
|
|
203
|
+
to += offset;
|
|
204
|
+
if (to & 0x88)
|
|
205
|
+
break;
|
|
206
|
+
if (!board[to]) {
|
|
207
|
+
addMove(moves, us, from, to, type);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// own color, stop loop
|
|
211
|
+
if (board[to].color === us)
|
|
212
|
+
break;
|
|
213
|
+
addMove(moves, us, from, to, type, board[to].type, BITS.CAPTURE);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
/* break, if knight or king */
|
|
217
|
+
if (type === KNIGHT || type === KING)
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/*
|
|
224
|
+
* check for castling if we're:
|
|
225
|
+
* a) generating all moves, or
|
|
226
|
+
* b) doing single square move generation on the king's square
|
|
227
|
+
*/
|
|
228
|
+
if (forPiece === undefined || forPiece === KING) {
|
|
229
|
+
if (!singleSquare || lastSquare === kings[us]) {
|
|
230
|
+
// king-side castling
|
|
231
|
+
addCastlingMove(moves, us, them, BITS.KSIDE_CASTLE, board, kings, castling, castlingRooks);
|
|
232
|
+
// queen-side castling
|
|
233
|
+
addCastlingMove(moves, us, them, BITS.QSIDE_CASTLE, board, kings, castling, castlingRooks);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/*
|
|
237
|
+
* return all pseudo-legal moves (this includes moves that allow the king
|
|
238
|
+
* to be captured)
|
|
239
|
+
*/
|
|
240
|
+
return moves;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=movegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movegen.js","sourceRoot":"","sources":["../src/movegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAUH,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,MAAM,EACN,MAAM,EACN,WAAW,GACZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,UAAU,OAAO,CACrB,KAAqB,EACrB,KAAY,EACZ,IAAY,EACZ,EAAU,EACV,KAAkB,EAClB,WAAoC,SAAS,EAC7C,QAAgB,IAAI,CAAC,MAAM,EAC3B,WAA+B,SAAS;IAExC,MAAM,CAAC,GAAG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AAE,CAAC;QAChD,IAAI,CAAC,YAAY,IAAI,UAAU,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9C,qBAAqB;YACrB,eAAe,CACb,KAAK,EACL,EAAE,EACF,IAAI,EACJ,IAAI,CAAC,YAAY,EACjB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,aAAa,CACd,CAAA;YAED,sBAAsB;YACtB,eAAe,CACb,KAAK,EACL,EAAE,EACF,IAAI,EACJ,IAAI,CAAC,YAAY,EACjB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,aAAa,CACd,CAAA;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,IAAI,EAAE,CAAA;CACnB,CAAA"}
|
package/dist/node.js
ADDED
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 type { Color, InternalMove, PieceSymbol } from './types.js';
|
|
28
|
+
export declare function getDisambiguator(move: InternalMove, moves: InternalMove[]): string;
|
|
29
|
+
export declare function inferPieceType(san: string): PieceSymbol | undefined;
|
|
30
|
+
export declare function strippedSan(move: string): string;
|
|
31
|
+
export declare function moveToSan(move: InternalMove, moves: InternalMove[]): string;
|
|
32
|
+
export declare function moveFromSan(move: string, turn: Color, legalMoves: InternalMove[], strict?: boolean): InternalMove | null;
|
|
33
|
+
//# sourceMappingURL=notation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notation.d.ts","sourceRoot":"","sources":["../src/notation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAU,MAAM,YAAY,CAAA;AAK1E,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,YAAY,EAAE,GACpB,MAAM,CAmDR;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAcnE;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAOD,wBAAgB,SAAS,CACvB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,YAAY,EAAE,GACpB,MAAM,CA8BR;AAGD,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,YAAY,EAAE,EAC1B,MAAM,UAAQ,GACb,YAAY,GAAG,IAAI,CAuJrB"}
|