gigachess 0.4.1 → 0.4.3
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/dist/board.d.ts +79 -2
- package/dist/board.d.ts.map +1 -1
- package/dist/board.js +138 -20
- package/dist/chess.d.ts +39 -4
- package/dist/chess.d.ts.map +1 -1
- package/dist/chess.js +102 -2
- package/dist/chesstree.d.ts.map +1 -1
- package/dist/chesstree.js +42 -25
- package/dist/core.d.ts +2 -2
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/packedMove.d.ts +30 -2
- package/dist/packedMove.d.ts.map +1 -1
- package/dist/packedMove.js +56 -2
- package/dist/san.d.ts +32 -0
- package/dist/san.d.ts.map +1 -1
- package/dist/san.js +104 -15
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/zobrist.d.ts +13 -0
- package/dist/zobrist.d.ts.map +1 -1
- package/dist/zobrist.js +34 -0
- package/package.json +2 -2
package/dist/board.d.ts
CHANGED
|
@@ -35,6 +35,24 @@ export type Undo = {
|
|
|
35
35
|
readonly zobristLo: number;
|
|
36
36
|
readonly zobristHi: number;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Snapshot for a null move (pass). A pass moves no piece, so it records only
|
|
40
|
+
* the state its transition touches — ep, the clocks, turn and the caches —
|
|
41
|
+
* and carries `isNull: true` as the discriminant `unmakeMove` dispatches on.
|
|
42
|
+
* Mirrors gigachess-rs `make_null_move` (board.rs).
|
|
43
|
+
*/
|
|
44
|
+
export type NullUndo = {
|
|
45
|
+
readonly isNull: true;
|
|
46
|
+
readonly epSquare: number | null;
|
|
47
|
+
readonly castling: CastlingRights;
|
|
48
|
+
readonly castlingMask?: number;
|
|
49
|
+
readonly halfmoves: number;
|
|
50
|
+
readonly fullmoves: number;
|
|
51
|
+
readonly kingSq: readonly [number, number];
|
|
52
|
+
readonly checkers: SquareSet;
|
|
53
|
+
readonly zobristLo: number;
|
|
54
|
+
readonly zobristHi: number;
|
|
55
|
+
};
|
|
38
56
|
export declare class Board implements BoardLike {
|
|
39
57
|
white: MutableSquareSet;
|
|
40
58
|
black: MutableSquareSet;
|
|
@@ -88,15 +106,74 @@ export declare class Board implements BoardLike {
|
|
|
88
106
|
kingSquare(color: Color): number | undefined;
|
|
89
107
|
private _clearSquare;
|
|
90
108
|
private _putPiece;
|
|
91
|
-
|
|
92
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Plays a null move (pass): the position stays, the side to move flips.
|
|
111
|
+
*
|
|
112
|
+
* Castling rights are untouched, the en-passant square clears, the halfmove
|
|
113
|
+
* clock advances and the move always completes a full move (the number
|
|
114
|
+
* advances whoever passed). The Polyglot key and the cached `checkers` are
|
|
115
|
+
* both maintained.
|
|
116
|
+
*
|
|
117
|
+
* Throws when the side to move is in check: a pass answers no check. The test
|
|
118
|
+
* is computed from the bitboards (never from the cached `checkers`, which a
|
|
119
|
+
* cache-free make may have left stale). Mirrors gigachess-rs
|
|
120
|
+
* `Board::make_null_move`.
|
|
121
|
+
*/
|
|
122
|
+
makeNullMove(): NullUndo;
|
|
123
|
+
/**
|
|
124
|
+
* Reverts the most recent null move, restoring the exact prior position.
|
|
125
|
+
*
|
|
126
|
+
* Each null must be unmade before an older one, with no ordinary moves
|
|
127
|
+
* interleaved past the matching make — exactly like `unmakeMove`.
|
|
128
|
+
*/
|
|
129
|
+
unmakeNullMove(undo: NullUndo): void;
|
|
130
|
+
makeMove(moveWord: number | Move): Undo | NullUndo;
|
|
131
|
+
unmakeMove(undo: Undo | NullUndo): void;
|
|
93
132
|
legalMoves(outBuffer?: Uint16Array): Uint16Array;
|
|
94
133
|
forEachLegalMove(fn: (moveWord: number) => void): void;
|
|
95
134
|
toSan(moveWord: number): string;
|
|
96
135
|
toUci(moveWord: number): string;
|
|
97
136
|
toFen(): string;
|
|
98
137
|
parseSan(san: string): number | null;
|
|
138
|
+
/**
|
|
139
|
+
* `parseSan` with the failure reason kept.
|
|
140
|
+
*
|
|
141
|
+
* `parseSan` maps every error — `san/ambiguous`, `san/noLegalMove`,
|
|
142
|
+
* `san/invalidSan` — onto the same `null`, so a caller cannot tell "no such
|
|
143
|
+
* move" from "several moves answer to this and you must disambiguate". Those
|
|
144
|
+
* are different answers for a UI: one is an error, the other needs the
|
|
145
|
+
* candidates named (BlindBase ADR-042, field report #11).
|
|
146
|
+
*
|
|
147
|
+
* The error code is returned rather than a richer object because the codes
|
|
148
|
+
* are the library's own error vocabulary (`SanError["code"]`), already
|
|
149
|
+
* documented and already i18n-keyed upstream.
|
|
150
|
+
*/
|
|
151
|
+
parseSanResult(san: string): {
|
|
152
|
+
ok: true;
|
|
153
|
+
moveWord: number;
|
|
154
|
+
} | {
|
|
155
|
+
ok: false;
|
|
156
|
+
code: string;
|
|
157
|
+
};
|
|
99
158
|
parseUci(uci: string): number | null;
|
|
159
|
+
/**
|
|
160
|
+
* Every packed move word `san` could denote here, or the reason it names none.
|
|
161
|
+
*
|
|
162
|
+
* `parseSan` reports `san/ambiguous` and discards the matches, so a caller
|
|
163
|
+
* can tell the user the input was ambiguous but not which moves it meant.
|
|
164
|
+
* This returns them, letting a caller present the disambiguated spellings
|
|
165
|
+
* rather than making the user guess (BlindBase ADR-042, field report #11).
|
|
166
|
+
*
|
|
167
|
+
* A resolved move comes back as a one-element array, so this can replace
|
|
168
|
+
* `parseSan` wherever the caller only needs "one move, or a reason".
|
|
169
|
+
*/
|
|
170
|
+
parseSanCandidates(san: string): {
|
|
171
|
+
ok: true;
|
|
172
|
+
moveWords: number[];
|
|
173
|
+
} | {
|
|
174
|
+
ok: false;
|
|
175
|
+
code: string;
|
|
176
|
+
};
|
|
100
177
|
perft(depth: number): number;
|
|
101
178
|
}
|
|
102
179
|
export type WritableBoard = {
|
package/dist/board.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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,MAAM,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,CAajG;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAO7E;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAElE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAMrE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAa/D"}
|
package/dist/board.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import * as sq from "./squareSet.js";
|
|
4
4
|
import { Color, Role } from "./types.js";
|
|
5
5
|
import { opposite } from "./util.js";
|
|
6
|
-
import { kingAttackers } from "./attacks.js";
|
|
6
|
+
import { kingAttackers, attackersTo } from "./attacks.js";
|
|
7
7
|
import { zobristTablesLoaded, calculateZobrist, zobristHex, pieceKeyIdx, castlingKeyIdx, epIsHashable, keyLo, keyHi, castleKeyLo, castleKeyHi, IDX_EP, IDX_SIDE, } from "./zobrist.js";
|
|
8
8
|
import { CASTLE_CLEAR_STD, CASTLING_RIGHTS_TABLE, getCastlingMask, detectCastling, } from "./castling.js";
|
|
9
|
-
import { packOf, unpackToMove, promoCodeToRole, } from "./packedMove.js";
|
|
9
|
+
import { packOf, unpackToMove, promoCodeToRole, isNull, } from "./packedMove.js";
|
|
10
10
|
import { parseFen, makeFen } from "./fen.js";
|
|
11
|
-
import { parseSan, makeSan, parseUci, makeUci } from "./san.js";
|
|
11
|
+
import { parseSan, parseSanCandidates, makeSan, parseUci, makeUci } from "./san.js";
|
|
12
12
|
import { legalMovesInto, forEachLegalMove, countLegalMoves, isLegal, INITIAL_FEN } from "./chess.js";
|
|
13
13
|
export class Board {
|
|
14
14
|
constructor(input) {
|
|
@@ -396,8 +396,84 @@ export class Board {
|
|
|
396
396
|
this.kingSq[color] = sqIdx;
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Plays a null move (pass): the position stays, the side to move flips.
|
|
401
|
+
*
|
|
402
|
+
* Castling rights are untouched, the en-passant square clears, the halfmove
|
|
403
|
+
* clock advances and the move always completes a full move (the number
|
|
404
|
+
* advances whoever passed). The Polyglot key and the cached `checkers` are
|
|
405
|
+
* both maintained.
|
|
406
|
+
*
|
|
407
|
+
* Throws when the side to move is in check: a pass answers no check. The test
|
|
408
|
+
* is computed from the bitboards (never from the cached `checkers`, which a
|
|
409
|
+
* cache-free make may have left stale). Mirrors gigachess-rs
|
|
410
|
+
* `Board::make_null_move`.
|
|
411
|
+
*/
|
|
412
|
+
makeNullMove() {
|
|
413
|
+
const us = this.turn;
|
|
414
|
+
const them = opposite(us);
|
|
415
|
+
// Fresh in-check scan — the cache may describe an earlier position.
|
|
416
|
+
const ksq = this.kingSq[us === Color.White ? 0 : 1];
|
|
417
|
+
if (ksq >= 0 && !sq.isEmpty(attackersTo(this, ksq, them, this.occupied))) {
|
|
418
|
+
throw new Error("illegal null move: the side to move is in check");
|
|
419
|
+
}
|
|
420
|
+
const undo = {
|
|
421
|
+
isNull: true,
|
|
422
|
+
epSquare: this.epSquare,
|
|
423
|
+
castling: this.castling,
|
|
424
|
+
castlingMask: this.castlingMask,
|
|
425
|
+
halfmoves: this.halfmoves,
|
|
426
|
+
fullmoves: this.fullmoves,
|
|
427
|
+
kingSq: [this.kingSq[0], this.kingSq[1]],
|
|
428
|
+
checkers: this.checkers,
|
|
429
|
+
zobristLo: this._zobristLo,
|
|
430
|
+
zobristHi: this._zobristHi,
|
|
431
|
+
};
|
|
432
|
+
// Hash out the old en-passant contribution (relevance uses the mover's
|
|
433
|
+
// pawns, which a pass does not move) before clearing it.
|
|
434
|
+
if (zobristTablesLoaded() && keyLo && keyHi) {
|
|
435
|
+
if (this._zobristLo === 0 && this._zobristHi === 0)
|
|
436
|
+
this.refreshZobrist();
|
|
437
|
+
if (this.epSquare !== null && epIsHashable(this, this.epSquare, us)) {
|
|
438
|
+
const kEp = IDX_EP + (this.epSquare & 7);
|
|
439
|
+
this._zobristLo = (this._zobristLo ^ keyLo[kEp]) >>> 0;
|
|
440
|
+
this._zobristHi = (this._zobristHi ^ keyHi[kEp]) >>> 0;
|
|
441
|
+
}
|
|
442
|
+
// a pass is a full move — the side key always flips
|
|
443
|
+
this._zobristLo = (this._zobristLo ^ keyLo[IDX_SIDE]) >>> 0;
|
|
444
|
+
this._zobristHi = (this._zobristHi ^ keyHi[IDX_SIDE]) >>> 0;
|
|
445
|
+
}
|
|
446
|
+
this.epSquare = null;
|
|
447
|
+
this.halfmoves = this.halfmoves + 1;
|
|
448
|
+
this.fullmoves = this.fullmoves + 1;
|
|
449
|
+
this.turn = them;
|
|
450
|
+
this.checkers = kingAttackers(this, them);
|
|
451
|
+
return undo;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Reverts the most recent null move, restoring the exact prior position.
|
|
455
|
+
*
|
|
456
|
+
* Each null must be unmade before an older one, with no ordinary moves
|
|
457
|
+
* interleaved past the matching make — exactly like `unmakeMove`.
|
|
458
|
+
*/
|
|
459
|
+
unmakeNullMove(undo) {
|
|
460
|
+
this.turn = opposite(this.turn);
|
|
461
|
+
this.fullmoves = undo.fullmoves;
|
|
462
|
+
this.epSquare = undo.epSquare;
|
|
463
|
+
this.castling = undo.castling;
|
|
464
|
+
this.castlingMask = undo.castlingMask;
|
|
465
|
+
this.halfmoves = undo.halfmoves;
|
|
466
|
+
this.kingSq[0] = undo.kingSq[0];
|
|
467
|
+
this.kingSq[1] = undo.kingSq[1];
|
|
468
|
+
this.checkers = undo.checkers;
|
|
469
|
+
this._zobristLo = undo.zobristLo;
|
|
470
|
+
this._zobristHi = undo.zobristHi;
|
|
471
|
+
}
|
|
399
472
|
makeMove(moveWord) {
|
|
400
473
|
const word = typeof moveWord === "number" ? moveWord : packOf(moveWord);
|
|
474
|
+
// The null sentinel is a first-class pass, not a from/to/promo word.
|
|
475
|
+
if (isNull(word))
|
|
476
|
+
return this.makeNullMove();
|
|
401
477
|
const from = word & 0x3f;
|
|
402
478
|
const to = (word >> 6) & 0x3f;
|
|
403
479
|
const promoCode = (word >> 12) & 0x0f;
|
|
@@ -648,22 +724,28 @@ export class Board {
|
|
|
648
724
|
};
|
|
649
725
|
}
|
|
650
726
|
unmakeMove(undo) {
|
|
651
|
-
|
|
652
|
-
|
|
727
|
+
// A pass records no piece edits — restore clocks/turn/caches only.
|
|
728
|
+
if (undo.isNull === true) {
|
|
729
|
+
this.unmakeNullMove(undo);
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
const normal = undo;
|
|
733
|
+
const from = normal.move & 0x3f;
|
|
734
|
+
const to = (normal.move >> 6) & 0x3f;
|
|
653
735
|
const us = opposite(this.turn);
|
|
654
736
|
this.turn = us;
|
|
655
|
-
this.halfmoves =
|
|
656
|
-
this.fullmoves =
|
|
657
|
-
this.epSquare =
|
|
658
|
-
this.castling =
|
|
659
|
-
this.castlingMask =
|
|
660
|
-
this.kingSq[0] =
|
|
661
|
-
this.kingSq[1] =
|
|
662
|
-
this.checkers =
|
|
663
|
-
this._zobristLo =
|
|
664
|
-
this._zobristHi =
|
|
665
|
-
if (
|
|
666
|
-
const plan =
|
|
737
|
+
this.halfmoves = normal.halfmoves;
|
|
738
|
+
this.fullmoves = normal.fullmoves;
|
|
739
|
+
this.epSquare = normal.epSquare;
|
|
740
|
+
this.castling = normal.castling;
|
|
741
|
+
this.castlingMask = normal.castlingMask;
|
|
742
|
+
this.kingSq[0] = normal.kingSq[0];
|
|
743
|
+
this.kingSq[1] = normal.kingSq[1];
|
|
744
|
+
this.checkers = normal.checkers;
|
|
745
|
+
this._zobristLo = normal.zobristLo;
|
|
746
|
+
this._zobristHi = normal.zobristHi;
|
|
747
|
+
if (normal.castlingPlan !== null) {
|
|
748
|
+
const plan = normal.castlingPlan;
|
|
667
749
|
this._clearSquare(plan.kingTo);
|
|
668
750
|
this._clearSquare(plan.rookTo);
|
|
669
751
|
this._putPiece(plan.kingFrom, us, Role.King);
|
|
@@ -671,10 +753,10 @@ export class Board {
|
|
|
671
753
|
}
|
|
672
754
|
else {
|
|
673
755
|
this._clearSquare(to);
|
|
674
|
-
this._putPiece(from, us,
|
|
675
|
-
if (
|
|
756
|
+
this._putPiece(from, us, normal.movingRole);
|
|
757
|
+
if (normal.capturedSq >= 0 && normal.capturedRole >= 0) {
|
|
676
758
|
const them = opposite(us);
|
|
677
|
-
this._putPiece(
|
|
759
|
+
this._putPiece(normal.capturedSq, them, normal.capturedRole);
|
|
678
760
|
}
|
|
679
761
|
}
|
|
680
762
|
}
|
|
@@ -703,10 +785,46 @@ export class Board {
|
|
|
703
785
|
const res = parseSan(san, this);
|
|
704
786
|
return res.ok ? packOf(res.value) : null;
|
|
705
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* `parseSan` with the failure reason kept.
|
|
790
|
+
*
|
|
791
|
+
* `parseSan` maps every error — `san/ambiguous`, `san/noLegalMove`,
|
|
792
|
+
* `san/invalidSan` — onto the same `null`, so a caller cannot tell "no such
|
|
793
|
+
* move" from "several moves answer to this and you must disambiguate". Those
|
|
794
|
+
* are different answers for a UI: one is an error, the other needs the
|
|
795
|
+
* candidates named (BlindBase ADR-042, field report #11).
|
|
796
|
+
*
|
|
797
|
+
* The error code is returned rather than a richer object because the codes
|
|
798
|
+
* are the library's own error vocabulary (`SanError["code"]`), already
|
|
799
|
+
* documented and already i18n-keyed upstream.
|
|
800
|
+
*/
|
|
801
|
+
parseSanResult(san) {
|
|
802
|
+
const res = parseSan(san, this);
|
|
803
|
+
return res.ok
|
|
804
|
+
? { ok: true, moveWord: packOf(res.value) }
|
|
805
|
+
: { ok: false, code: res.error.code };
|
|
806
|
+
}
|
|
706
807
|
parseUci(uci) {
|
|
707
808
|
const res = parseUci(uci);
|
|
708
809
|
return res.ok && isLegal(this, res.value) ? packOf(res.value) : null;
|
|
709
810
|
}
|
|
811
|
+
/**
|
|
812
|
+
* Every packed move word `san` could denote here, or the reason it names none.
|
|
813
|
+
*
|
|
814
|
+
* `parseSan` reports `san/ambiguous` and discards the matches, so a caller
|
|
815
|
+
* can tell the user the input was ambiguous but not which moves it meant.
|
|
816
|
+
* This returns them, letting a caller present the disambiguated spellings
|
|
817
|
+
* rather than making the user guess (BlindBase ADR-042, field report #11).
|
|
818
|
+
*
|
|
819
|
+
* A resolved move comes back as a one-element array, so this can replace
|
|
820
|
+
* `parseSan` wherever the caller only needs "one move, or a reason".
|
|
821
|
+
*/
|
|
822
|
+
parseSanCandidates(san) {
|
|
823
|
+
const res = parseSanCandidates(san, this);
|
|
824
|
+
return res.ok
|
|
825
|
+
? { ok: true, moveWords: res.value.map(packOf) }
|
|
826
|
+
: { ok: false, code: res.error.code };
|
|
827
|
+
}
|
|
710
828
|
perft(depth) {
|
|
711
829
|
if (depth <= 0)
|
|
712
830
|
return 1;
|
package/dist/chess.d.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import type { SquareSet } from "./squareSet.js";
|
|
2
|
-
import { Board, type Undo as BoardUndo } from "./board.js";
|
|
2
|
+
import { Board, type Undo as BoardUndo, type NullUndo } from "./board.js";
|
|
3
3
|
import { Color, Role } from "./types.js";
|
|
4
4
|
import type { Setup, Move, Position } from "./types.js";
|
|
5
5
|
import type { ZobristKey } from "./zobrist.js";
|
|
6
6
|
import type { TreeWrapper } from "./chesstree.js";
|
|
7
7
|
export declare function isCheck(pos: Position): boolean;
|
|
8
8
|
export declare function kingAttackers(pos: Position, color: Color): SquareSet;
|
|
9
|
+
/**
|
|
10
|
+
* In-check test computed FRESH from the attack tables — never from the cached
|
|
11
|
+
* `checkers` bitboard.
|
|
12
|
+
*
|
|
13
|
+
* The null-move legality gate must use this: a caller that reached a pass
|
|
14
|
+
* through a cache-free make holds a `checkers` value describing some earlier
|
|
15
|
+
* position, and reading it would accept or refuse the wrong positions. The scan
|
|
16
|
+
* costs one `attackersTo` on a path taken roughly once per ten thousand plies.
|
|
17
|
+
* Mirrors gigachess-rs `make_null_move` (board.rs).
|
|
18
|
+
*/
|
|
19
|
+
export declare function isCheckFresh(pos: Position): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A pass is legal iff the side to move is NOT in check (a null move answers no
|
|
22
|
+
* check). Always judged from the attack tables — see {@link isCheckFresh}.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isNullMoveLegal(pos: Position): boolean;
|
|
9
25
|
export declare function isInsufficientMaterial(pos: Position): boolean;
|
|
10
26
|
export declare function isFiftyMoveDraw(pos: Position): boolean;
|
|
11
27
|
export declare function isSeventyFiveMoveDraw(pos: Position): boolean;
|
|
@@ -15,6 +31,24 @@ import { detectCastling, castlingPlanFor, planForDest } from "./castling.js";
|
|
|
15
31
|
import type { CastlingPlan } from "./castling.js";
|
|
16
32
|
export { detectCastling, castlingPlanFor, planForDest, };
|
|
17
33
|
export type { CastlingPlan };
|
|
34
|
+
/**
|
|
35
|
+
* Plays a null move (pass): the position stays, the side to move flips.
|
|
36
|
+
*
|
|
37
|
+
* Semantics mirror an ordinary move's state transition: castling rights are
|
|
38
|
+
* untouched, the en-passant square clears (any pending double push lapses), the
|
|
39
|
+
* halfmove clock advances and the move always completes a full move (a pass is
|
|
40
|
+
* a move, not a half-move: after the pass White is to move with the number
|
|
41
|
+
* advanced, whoever passed). The incremental Polyglot hash and the cached
|
|
42
|
+
* `checkers` are maintained, so `zobrist()` still equals a full recompute and
|
|
43
|
+
* `isCheck` stays branch-free.
|
|
44
|
+
*
|
|
45
|
+
* Throws when the side to move is in check: a pass answers no check. The test
|
|
46
|
+
* is computed from the bitboards rather than read from the cache — see
|
|
47
|
+
* {@link isCheckFresh}.
|
|
48
|
+
*
|
|
49
|
+
* Mirrors gigachess-rs `Board::make_null_move` (board.rs).
|
|
50
|
+
*/
|
|
51
|
+
export declare function makeNullMove(pos: Position): Position;
|
|
18
52
|
export declare function makeMove(pos: Position, move: Move): Position;
|
|
19
53
|
export declare const play: typeof makeMove;
|
|
20
54
|
type CheckContext = {
|
|
@@ -69,7 +103,8 @@ export type VerboseMove = {
|
|
|
69
103
|
color: ColorName;
|
|
70
104
|
from: string;
|
|
71
105
|
to: string;
|
|
72
|
-
piece
|
|
106
|
+
/** Absent on a null move (pass) — a pass moves no piece. */
|
|
107
|
+
piece?: PieceChar;
|
|
73
108
|
captured?: PieceChar;
|
|
74
109
|
promotion?: PieceChar;
|
|
75
110
|
flags: string;
|
|
@@ -83,11 +118,11 @@ export type HistoryEntry = {
|
|
|
83
118
|
readonly after: Position;
|
|
84
119
|
readonly move: Move;
|
|
85
120
|
readonly san: string;
|
|
86
|
-
readonly boardUndo?: BoardUndo;
|
|
121
|
+
readonly boardUndo?: BoardUndo | NullUndo;
|
|
87
122
|
readonly prev_checkers?: SquareSet;
|
|
88
123
|
readonly prev_zobrist?: ZobristKey;
|
|
89
124
|
};
|
|
90
|
-
export type { BoardUndo as Undo };
|
|
125
|
+
export type { BoardUndo as Undo, NullUndo };
|
|
91
126
|
export { Board };
|
|
92
127
|
/**
|
|
93
128
|
* Unified root `Chess` (design D1): the chess.js-ergonomic mutable façade
|
package/dist/chess.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chess.d.ts","sourceRoot":"","sources":["../src/chess.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"chess.d.ts","sourceRoot":"","sources":["../src/chess.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,C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IAAI,GAAG,OAAO;IAE5B,yDAAyD;IACzD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAE5B,8EAA8E;IAC9E,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAkBtB,gEAAgE;IAChE,OAAO,IAAI,UAAU;IAIrB,mEAAmE;IACnE,UAAU,IAAI,MAAM;IAEpB,iEAAiE;IACjE,QAAQ,IAAI,WAAW;IAMvB,kFAAkF;IAClF,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,EAAE,QAAQ,GAAE,MAAoB,GAAG,IAAI;IASlF,kFAAkF;IAClF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,EAAE,QAAQ,GAAE,MAAoB,GAAG,KAAK;IAM1F,uCAAuC;IACvC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IAIrC,qDAAqD;IACrD,MAAM,CAAC,OAAO,IAAI,KAAK;IAIvB,gEAAgE;IAChE,IAAI,QAAQ,IAAI,MAAM,CAA2B;IAEjD,qEAAqE;IACrE,IAAI,GAAG,IAAI,QAAQ,CAA4B;IAC/C,IAAI,IAAI,IAAI,QAAQ,CAA4B;IAChD,IAAI,aAAa,IAAI,KAAK,CAAwB;IAElD,6DAA6D;IAC7D,IAAI,cAAc,IAAI,SAAS,YAAY,EAAE,CAA0B;IAEvE;;;;OAIG;IACH,MAAM,IAAI,WAAW;IAmBrB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;CA6HnC"}
|
package/dist/chess.js
CHANGED
|
@@ -18,10 +18,10 @@ import { Board } from "./board.js";
|
|
|
18
18
|
import * as attacks from "./attacks.js";
|
|
19
19
|
import { Color, Role } from "./types.js";
|
|
20
20
|
import { opposite, squareFile, squareRank, parseSquare, squareName } from "./util.js";
|
|
21
|
-
import { zobristTablesLoaded, zobristAfterMove } from "./zobrist.js";
|
|
21
|
+
import { zobristTablesLoaded, zobristAfterMove, zobristAfterNullMove } from "./zobrist.js";
|
|
22
22
|
import { parseFen, makeFen } from "./fen.js";
|
|
23
23
|
import { parseSan, makeSan, parseUci, makeUci } from "./san.js";
|
|
24
|
-
import { packOf, packedToMoves, PROMO_NONE, PROMO_KNIGHT, PROMO_BISHOP, PROMO_ROOK, PROMO_QUEEN, } from "./packedMove.js";
|
|
24
|
+
import { packOf, packedToMoves, isNullMove, PROMO_NONE, PROMO_KNIGHT, PROMO_BISHOP, PROMO_ROOK, PROMO_QUEEN, } from "./packedMove.js";
|
|
25
25
|
import { build as buildTreeWrapper, pgnImport as pgnImportData } from "./chesstree.js";
|
|
26
26
|
import { pieceAt } from "./board.js";
|
|
27
27
|
import { CASTLE_WK, CASTLE_WQ, CASTLE_BK, CASTLE_BQ, CASTLE_CLEAR_STD, CASTLING_RIGHTS_TABLE, PLAN_WHITE_K, PLAN_WHITE_Q, PLAN_BLACK_K, PLAN_BLACK_Q, getCastlingMask, CASTLE_PATH_LO, CASTLE_PATH_HI, CASTLE_TRAVERSAL_WHITE, CASTLE_TRAVERSAL_BLACK, } from "./castling.js";
|
|
@@ -39,6 +39,30 @@ export function isCheck(pos) {
|
|
|
39
39
|
export function kingAttackers(pos, color) {
|
|
40
40
|
return attacks.kingAttackers(pos.board, color);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* In-check test computed FRESH from the attack tables — never from the cached
|
|
44
|
+
* `checkers` bitboard.
|
|
45
|
+
*
|
|
46
|
+
* The null-move legality gate must use this: a caller that reached a pass
|
|
47
|
+
* through a cache-free make holds a `checkers` value describing some earlier
|
|
48
|
+
* position, and reading it would accept or refuse the wrong positions. The scan
|
|
49
|
+
* costs one `attackersTo` on a path taken roughly once per ten thousand plies.
|
|
50
|
+
* Mirrors gigachess-rs `make_null_move` (board.rs).
|
|
51
|
+
*/
|
|
52
|
+
export function isCheckFresh(pos) {
|
|
53
|
+
const ksq = board.kingSquare(pos.board, pos.turn);
|
|
54
|
+
if (ksq === undefined)
|
|
55
|
+
return false;
|
|
56
|
+
const them = opposite(pos.turn);
|
|
57
|
+
return !sq.isEmpty(attacks.attackersTo(pos.board, ksq, them, pos.board.occupied));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A pass is legal iff the side to move is NOT in check (a null move answers no
|
|
61
|
+
* check). Always judged from the attack tables — see {@link isCheckFresh}.
|
|
62
|
+
*/
|
|
63
|
+
export function isNullMoveLegal(pos) {
|
|
64
|
+
return !isCheckFresh(pos);
|
|
65
|
+
}
|
|
42
66
|
// insufficient material per spec
|
|
43
67
|
export function isInsufficientMaterial(pos) {
|
|
44
68
|
const b = pos.board;
|
|
@@ -205,7 +229,65 @@ isPromotion, promotion, captured) {
|
|
|
205
229
|
board.putPieceInPlace(nb, to, { color: piece.color, role });
|
|
206
230
|
}
|
|
207
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Plays a null move (pass): the position stays, the side to move flips.
|
|
234
|
+
*
|
|
235
|
+
* Semantics mirror an ordinary move's state transition: castling rights are
|
|
236
|
+
* untouched, the en-passant square clears (any pending double push lapses), the
|
|
237
|
+
* halfmove clock advances and the move always completes a full move (a pass is
|
|
238
|
+
* a move, not a half-move: after the pass White is to move with the number
|
|
239
|
+
* advanced, whoever passed). The incremental Polyglot hash and the cached
|
|
240
|
+
* `checkers` are maintained, so `zobrist()` still equals a full recompute and
|
|
241
|
+
* `isCheck` stays branch-free.
|
|
242
|
+
*
|
|
243
|
+
* Throws when the side to move is in check: a pass answers no check. The test
|
|
244
|
+
* is computed from the bitboards rather than read from the cache — see
|
|
245
|
+
* {@link isCheckFresh}.
|
|
246
|
+
*
|
|
247
|
+
* Mirrors gigachess-rs `Board::make_null_move` (board.rs).
|
|
248
|
+
*/
|
|
249
|
+
export function makeNullMove(pos) {
|
|
250
|
+
if (!isNullMoveLegal(pos)) {
|
|
251
|
+
throw new Error("illegal null move: the side to move is in check");
|
|
252
|
+
}
|
|
253
|
+
const us = pos.turn;
|
|
254
|
+
const newTurn = opposite(us);
|
|
255
|
+
const newHalf = (pos.halfmoves ?? pos.halfmove ?? 0) + 1;
|
|
256
|
+
// A pass is a move, not a half-move: the number advances whoever passed
|
|
257
|
+
// (this is what keeps FEN's "White to move" and number incremented
|
|
258
|
+
// consistent).
|
|
259
|
+
const newFull = (pos.fullmoves ?? pos.fullmove ?? 1) + 1;
|
|
260
|
+
const nextKingSq = pos.kingSq
|
|
261
|
+
? [pos.kingSq[0], pos.kingSq[1]]
|
|
262
|
+
: [board.kingSquare(pos.board, Color.White) ?? -1, board.kingSquare(pos.board, Color.Black) ?? -1];
|
|
263
|
+
const newPos = {
|
|
264
|
+
// A pass moves no piece, so the board is carried over untouched (the input
|
|
265
|
+
// position is never mutated).
|
|
266
|
+
board: pos.board,
|
|
267
|
+
turn: newTurn,
|
|
268
|
+
castling: pos.castling,
|
|
269
|
+
castlingMask: pos.castlingMask,
|
|
270
|
+
isChess960: pos.isChess960 ?? false,
|
|
271
|
+
epSquare: null,
|
|
272
|
+
halfmoves: newHalf,
|
|
273
|
+
fullmoves: newFull,
|
|
274
|
+
halfmove: newHalf,
|
|
275
|
+
fullmove: newFull,
|
|
276
|
+
kingSq: nextKingSq,
|
|
277
|
+
checkers: attacks.kingAttackers(pos.board, newTurn),
|
|
278
|
+
};
|
|
279
|
+
if (zobristTablesLoaded()) {
|
|
280
|
+
const zk = zobristAfterNullMove(pos);
|
|
281
|
+
newPos.zobristLo = zk.lo;
|
|
282
|
+
newPos.zobristHi = zk.hi;
|
|
283
|
+
}
|
|
284
|
+
return newPos;
|
|
285
|
+
}
|
|
208
286
|
export function makeMove(pos, move) {
|
|
287
|
+
// First-class pass: the null sentinel dispatches here, before any from/to
|
|
288
|
+
// interpretation (a pass has no origin square).
|
|
289
|
+
if (isNullMove(move))
|
|
290
|
+
return makeNullMove(pos);
|
|
209
291
|
let from = move.from;
|
|
210
292
|
let to = move.to;
|
|
211
293
|
let piece = board.pieceAt(pos.board, from);
|
|
@@ -856,6 +938,10 @@ export function allDests(pos) {
|
|
|
856
938
|
return m;
|
|
857
939
|
}
|
|
858
940
|
export function isLegal(pos, move) {
|
|
941
|
+
// A pass is legal iff the side to move is not in check — judged fresh from
|
|
942
|
+
// the attack tables, never from the cached `checkers` bitboard.
|
|
943
|
+
if (isNullMove(move))
|
|
944
|
+
return isNullMoveLegal(pos);
|
|
859
945
|
// Single castling path (design D2): both the normalized (e1g1) and the
|
|
860
946
|
// baseline/960 (e1h1) input forms resolve through detectCastling.
|
|
861
947
|
const castling = detectCastling(pos, move.from, move.to);
|
|
@@ -1763,6 +1849,20 @@ _Chess_board = new WeakMap(), _Chess_startFen = new WeakMap(), _Chess_history =
|
|
|
1763
1849
|
out.push(h.after);
|
|
1764
1850
|
return out;
|
|
1765
1851
|
}, _Chess_describe = function _Chess_describe(pos, mv, after, san) {
|
|
1852
|
+
// A pass moves no piece: it has no origin, destination or piece, so the
|
|
1853
|
+
// chess.js-shaped record is built from the pass contract instead.
|
|
1854
|
+
if (isNullMove(mv)) {
|
|
1855
|
+
return {
|
|
1856
|
+
color: colorName(pos.turn),
|
|
1857
|
+
from: "",
|
|
1858
|
+
to: "",
|
|
1859
|
+
flags: "",
|
|
1860
|
+
san,
|
|
1861
|
+
lan: makeUci(mv),
|
|
1862
|
+
before: __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, pos),
|
|
1863
|
+
after: __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_fenOf).call(this, after),
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1766
1866
|
const piece = pieceAt(pos.board, mv.from);
|
|
1767
1867
|
if (!piece)
|
|
1768
1868
|
throw new Error("corrupt move: missing origin piece");
|
package/dist/chesstree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chesstree.d.ts","sourceRoot":"","sources":["../src/chesstree.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,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