gigachess 0.4.1 → 0.4.2
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 +41 -2
- package/dist/board.d.ts.map +1 -1
- package/dist/board.js +101 -19
- 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 +9 -0
- package/dist/san.d.ts.map +1 -1
- package/dist/san.js +36 -0
- 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,8 +106,29 @@ 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;
|
package/dist/board.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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ED,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAa/D"}
|
package/dist/board.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
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
11
|
import { parseSan, makeSan, parseUci, makeUci } from "./san.js";
|
|
12
12
|
import { legalMovesInto, forEachLegalMove, countLegalMoves, isLegal, INITIAL_FEN } from "./chess.js";
|
|
@@ -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
|
}
|
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,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAA0B,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGhF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAe/C,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAuB5D,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAQ9C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,CAEpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAKnD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAEt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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,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;I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,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,SAAS;IAOtE,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAInC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAI/B,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,SAAS;IAK5C,MAAM,IAAI,MAAM;IAOhB,GAAG,IAAI,MAAM;CAGd;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,WAAW,CAEjD;AAsGD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,eAAO,MAAM,SAAS;IACpB;;8BAE0B;wBACN,WAAW,GAAG,MAAM;IAOxC,wEAAwE;6BAC/C,IAAI,YAAY,QAAQ,EAAE,GAAG,MAAM;CAqB7D,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,SAAS,cAAQ,CAAC"}
|
package/dist/chesstree.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
// Not part of the third-party baseline; MIT like the rest of gigachess.
|
|
7
7
|
import { parsePgn } from "./pgn.js";
|
|
8
8
|
import { parseFen, makeFen } from "./fen.js";
|
|
9
|
-
import { makeMove, isCheck } from "./chess.js";
|
|
10
|
-
import { parseSan, makeUci } from "./san.js";
|
|
9
|
+
import { makeMove, isCheck, isNullMoveLegal } from "./chess.js";
|
|
10
|
+
import { parseSan, makeUci, isNullMoveSan } from "./san.js";
|
|
11
|
+
import { NULL_MOVE_SAN, NULL_MOVE_UCI, nullMove } from "./packedMove.js";
|
|
11
12
|
import { Color } from "./types.js";
|
|
12
13
|
const START_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
|
13
|
-
const NULL_MOVE_SANS = new Set(["--", "Z0", "null"]);
|
|
14
14
|
const ID_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
15
15
|
/** Deterministic unique 2-char node id (same alphabet/contract the
|
|
16
16
|
* workstation's `createUniqueMoveNodeId` relies on). */
|
|
@@ -29,7 +29,7 @@ function commentId(fullPath, index) {
|
|
|
29
29
|
// Same scheme the baseline emits: pgn-comment-comment-<path-to-node>-<i>
|
|
30
30
|
return `pgn-comment-comment-${fullPath}-${index}`;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const isNullMoveNode = (node) => node.san !== undefined && isNullMoveSan(node.san);
|
|
33
33
|
/** Baseline import semantics: a move repeated as a sibling (same SAN — e.g.
|
|
34
34
|
* the same line reached via several variations) merges into one node;
|
|
35
35
|
* subtrees and comments fold together recursively. */
|
|
@@ -69,19 +69,29 @@ function replaySection(moves, ctx, out) {
|
|
|
69
69
|
};
|
|
70
70
|
let advance = null;
|
|
71
71
|
if (isNullMoveSan(m.san)) {
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
node.
|
|
72
|
+
// A pass is a first-class ply, not a skipped token: it advances the
|
|
73
|
+
// position (turn flips, ep clears, halfmove and fullmove both bump), so
|
|
74
|
+
// node.fen must be the RESULT position and ctx must advance exactly as
|
|
75
|
+
// for any other move — otherwise every later node on this line stays one
|
|
76
|
+
// ply out of step and carries the parent's FEN. A pass is illegal while
|
|
77
|
+
// the side to move is in check: skip it, never throw.
|
|
78
|
+
if (!isNullMoveLegal(ctx.pos))
|
|
79
|
+
continue;
|
|
80
|
+
// the baseline normalizes the Z0 pass token to san "--", uci "0000"
|
|
81
|
+
node.san = NULL_MOVE_SAN;
|
|
82
|
+
node.uci = NULL_MOVE_UCI;
|
|
83
|
+
advance = { pos: makeMove(ctx.pos, nullMove()) };
|
|
84
|
+
node.fen = fenWithEpPolicy(advance.pos);
|
|
75
85
|
}
|
|
76
86
|
else {
|
|
77
87
|
const parsed = parseSan(m.san, ctx.pos);
|
|
78
88
|
if (!parsed.ok)
|
|
79
89
|
continue; // never throw on garbage — skip the move
|
|
80
90
|
const move = parsed.value;
|
|
81
|
-
advance = { move };
|
|
82
91
|
node.san = m.san;
|
|
83
92
|
node.uci = makeUci(move);
|
|
84
|
-
|
|
93
|
+
advance = { pos: makeMove(ctx.pos, move) };
|
|
94
|
+
node.fen = fenWithEpPolicy(advance.pos);
|
|
85
95
|
}
|
|
86
96
|
if (m.comments.length > 0) {
|
|
87
97
|
node.comments = m.comments.map((text, i) => ({
|
|
@@ -93,7 +103,7 @@ function replaySection(moves, ctx, out) {
|
|
|
93
103
|
// node, recursively merging their subtrees
|
|
94
104
|
const existing = target.find((c) => c.san !== undefined && c.san === node.san);
|
|
95
105
|
let mergedInto;
|
|
96
|
-
if (existing !== undefined && !
|
|
106
|
+
if (existing !== undefined && !isNullMoveNode(node)) {
|
|
97
107
|
mergeTree(existing, node);
|
|
98
108
|
mergedInto = existing;
|
|
99
109
|
}
|
|
@@ -101,7 +111,7 @@ function replaySection(moves, ctx, out) {
|
|
|
101
111
|
target.push(node);
|
|
102
112
|
}
|
|
103
113
|
if (advance) {
|
|
104
|
-
ctx.pos =
|
|
114
|
+
ctx.pos = advance.pos;
|
|
105
115
|
ctx.ply += 1;
|
|
106
116
|
ctx.path += id;
|
|
107
117
|
}
|
|
@@ -408,14 +418,20 @@ function renderHeaders(game, rootFen) {
|
|
|
408
418
|
}
|
|
409
419
|
return lines;
|
|
410
420
|
}
|
|
411
|
-
function advanceState(state) {
|
|
412
|
-
|
|
421
|
+
function advanceState(state, isPass) {
|
|
422
|
+
// A pass is a FULL move: the number advances whoever passed, exactly as the
|
|
423
|
+
// null-move FEN transition does (fullmove+1 regardless of side). A normal
|
|
424
|
+
// move only advances the number when Black just moved.
|
|
425
|
+
if (isPass || state.turn === "b") {
|
|
413
426
|
state.moveNo += 1;
|
|
414
427
|
state.turn = "w";
|
|
415
428
|
}
|
|
416
429
|
else {
|
|
417
430
|
state.turn = "b";
|
|
418
431
|
}
|
|
432
|
+
// A pass always completes a move, so the next token must carry its number.
|
|
433
|
+
if (isPass)
|
|
434
|
+
state.needNumber = true;
|
|
419
435
|
}
|
|
420
436
|
/** Emits the tree from `list[idx]`: the node, then the paren groups for its
|
|
421
437
|
* sibling alternatives (list[idx+1..], which replace it — baseline places
|
|
@@ -427,7 +443,9 @@ function emitFrom(list, idx, state, tokens) {
|
|
|
427
443
|
const node = list[idx];
|
|
428
444
|
const san = node.san;
|
|
429
445
|
const isNull = san !== undefined && isNullMoveSan(san);
|
|
430
|
-
|
|
446
|
+
// A pass is emitted as `--` — it is a real ply, so dropping it (the old
|
|
447
|
+
// behavior) desynchronized the numbering of every following token.
|
|
448
|
+
if (san !== undefined) {
|
|
431
449
|
if (state.turn === "w")
|
|
432
450
|
tokens.push(state.moveNo + ".");
|
|
433
451
|
else if (state.needNumber)
|
|
@@ -442,8 +460,8 @@ function emitFrom(list, idx, state, tokens) {
|
|
|
442
460
|
}
|
|
443
461
|
for (const c of node.comments ?? [])
|
|
444
462
|
tokens.push("{" + c.text + "}");
|
|
445
|
-
if (san !== undefined
|
|
446
|
-
advanceState(state);
|
|
463
|
+
if (san !== undefined)
|
|
464
|
+
advanceState(state, isNull);
|
|
447
465
|
for (let j = idx + 1; j < list.length; j++) {
|
|
448
466
|
const inner = { ...stateBefore, needNumber: true };
|
|
449
467
|
const sub = [];
|
|
@@ -495,15 +513,14 @@ export const pgnExport = {
|
|
|
495
513
|
if (san === undefined)
|
|
496
514
|
continue;
|
|
497
515
|
const isNull = isNullMoveSan(san);
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
516
|
+
// A pass is emitted as `--` and advances the numbering as a full move.
|
|
517
|
+
if (state.turn === "w")
|
|
518
|
+
tokens.push(`${state.moveNo}.`);
|
|
519
|
+
else if (state.needNumber)
|
|
520
|
+
tokens.push(`${state.moveNo}...`);
|
|
521
|
+
tokens.push(san);
|
|
522
|
+
state.needNumber = false;
|
|
523
|
+
advanceState(state, isNull);
|
|
507
524
|
for (const c of node.comments ?? [])
|
|
508
525
|
tokens.push(`{${c.text}}`);
|
|
509
526
|
}
|
package/dist/core.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export * from "./util.js";
|
|
|
5
5
|
export * from "./fen.js";
|
|
6
6
|
export * from "./san.js";
|
|
7
7
|
export { knightAttacks, kingAttacks, pawnAttacks, bishopAttacks, rookAttacks, queenAttacks, ensureMagicTablesLoaded, magicTablesLoaded, ray, between, isAttacked, kingAttackers, } from "./attacks.js";
|
|
8
|
-
export { dests, allDests, detectCastling, isCheck, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isThreefoldRepetition, perft, makeMove, play, } from "./chess.js";
|
|
9
|
-
export type { CastlingPlan } from "./chess.js";
|
|
8
|
+
export { dests, allDests, detectCastling, isCheck, isCheckFresh, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isThreefoldRepetition, isLegal, isNullMoveLegal, perft, makeMove, makeNullMove, play, } from "./chess.js";
|
|
9
|
+
export type { CastlingPlan, NullUndo } from "./chess.js";
|
|
10
10
|
//# sourceMappingURL=core.d.ts.map
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,GAAG,EACH,OAAO,EACP,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,KAAK,EACL,QAAQ,EACR,IAAI,GACL,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,GAAG,EACH,OAAO,EACP,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,YAAY,EACZ,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,IAAI,GACL,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/core.js
CHANGED
|
@@ -8,4 +8,4 @@ export * from "./util.js";
|
|
|
8
8
|
export * from "./fen.js";
|
|
9
9
|
export * from "./san.js";
|
|
10
10
|
export { knightAttacks, kingAttacks, pawnAttacks, bishopAttacks, rookAttacks, queenAttacks, ensureMagicTablesLoaded, magicTablesLoaded, ray, between, isAttacked, kingAttackers, } from "./attacks.js";
|
|
11
|
-
export { dests, allDests, detectCastling, isCheck, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isThreefoldRepetition, perft, makeMove, play, } from "./chess.js";
|
|
11
|
+
export { dests, allDests, detectCastling, isCheck, isCheckFresh, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isThreefoldRepetition, isLegal, isNullMoveLegal, perft, makeMove, makeNullMove, play, } from "./chess.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export * from "./packedMove.js";
|
|
|
11
11
|
export { knightAttacks, kingAttacks, pawnAttacks, bishopAttacks, rookAttacks, queenAttacks, ensureMagicTablesLoaded, magicTablesLoaded, ray, between, lineRay, LINE_RAY_LO, LINE_RAY_HI, isAttacked, } from "./attacks.js";
|
|
12
12
|
export { kingAttackers } from "./attacks.js";
|
|
13
13
|
export { CASTLE_PATH_LO, CASTLE_PATH_HI, CASTLE_CLEAR_STD, } from "./castling.js";
|
|
14
|
-
export { dests, allDests, detectCastling, isCheck, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isSeventyFiveMoveDraw, isThreefoldRepetition, isLegal, perft, countLegalMoves, legalMovesInto, forEachLegalMove, MoveCounter, makeMove, play, INITIAL_FEN, } from "./chess.js";
|
|
15
|
-
export type { CastlingPlan } from "./chess.js";
|
|
14
|
+
export { dests, allDests, detectCastling, isCheck, isCheckFresh, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isSeventyFiveMoveDraw, isThreefoldRepetition, isLegal, isNullMoveLegal, perft, countLegalMoves, legalMovesInto, forEachLegalMove, MoveCounter, makeMove, makeNullMove, play, INITIAL_FEN, } from "./chess.js";
|
|
15
|
+
export type { CastlingPlan, NullUndo } from "./chess.js";
|
|
16
16
|
export { pgnImport, buildTree, build, pgnExport, TreeWrapperImpl, } from "./chesstree.js";
|
|
17
17
|
export type { TreeWrapper, TreeNode, Path, Comment, Glyph, Clock, Shape, Eval as TreeEval, Game, Player, AnalyseData, } from "./chesstree.js";
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrE,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,GAAG,EACH,OAAO,EACP,OAAO,EACP,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrE,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,GAAG,EACH,OAAO,EACP,OAAO,EACP,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,YAAY,EACZ,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,KAAK,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,SAAS,EACT,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,IAAI,QAAQ,EAChB,IAAI,EACJ,MAAM,EACN,WAAW,GACZ,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,6 @@ export { knightAttacks, kingAttacks, pawnAttacks, bishopAttacks, rookAttacks, qu
|
|
|
16
16
|
export { kingAttackers } from "./attacks.js";
|
|
17
17
|
export { CASTLE_PATH_LO, CASTLE_PATH_HI, CASTLE_CLEAR_STD, } from "./castling.js";
|
|
18
18
|
// chess core (avoid duplicate Position and kingAttackers)
|
|
19
|
-
export { dests, allDests, detectCastling, isCheck, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isSeventyFiveMoveDraw, isThreefoldRepetition, isLegal, perft, countLegalMoves, legalMovesInto, forEachLegalMove, MoveCounter, makeMove, play, INITIAL_FEN, } from "./chess.js";
|
|
19
|
+
export { dests, allDests, detectCastling, isCheck, isCheckFresh, isCheckmate, isStalemate, isInsufficientMaterial, isFiftyMoveDraw, isSeventyFiveMoveDraw, isThreefoldRepetition, isLegal, isNullMoveLegal, perft, countLegalMoves, legalMovesInto, forEachLegalMove, MoveCounter, makeMove, makeNullMove, play, INITIAL_FEN, } from "./chess.js";
|
|
20
20
|
// chesstree integration (tree shapes + analysis API, folded into the root)
|
|
21
21
|
export { pgnImport, buildTree, build, pgnExport, TreeWrapperImpl, } from "./chesstree.js";
|
package/dist/packedMove.d.ts
CHANGED
|
@@ -14,7 +14,30 @@ export declare const PROMO_ROOK = 3;
|
|
|
14
14
|
export declare const PROMO_QUEEN = 4;
|
|
15
15
|
/** Packs from/to/promo into one 16-bit word. */
|
|
16
16
|
export declare function packMove(from: number, to: number, promo?: number): number;
|
|
17
|
-
/**
|
|
17
|
+
/** The null-move (pass) sentinel word. */
|
|
18
|
+
export declare const NULL_MOVE_WORD = 65535;
|
|
19
|
+
/** Canonical SAN rendering of a pass — never suffixed with `+` or `#`. */
|
|
20
|
+
export declare const NULL_MOVE_SAN = "--";
|
|
21
|
+
/** Canonical UCI rendering of a pass. */
|
|
22
|
+
export declare const NULL_MOVE_UCI = "0000";
|
|
23
|
+
/** True when `word` is the null-move sentinel (a pass, not a board move). */
|
|
24
|
+
export declare function isNull(word: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* A fresh null-move value (never share one instance across callers).
|
|
27
|
+
*
|
|
28
|
+
* `from`/`to` mirror the sentinel's own field decode (both 63) so the value
|
|
29
|
+
* round-trips through the wire format unchanged; `isNull` is what identifies
|
|
30
|
+
* it as a pass, never the squares.
|
|
31
|
+
*/
|
|
32
|
+
export declare function nullMove(): Move;
|
|
33
|
+
/** True when `move` is the null move (pass). */
|
|
34
|
+
export declare function isNullMove(move: Move): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Unpacks a 16-bit word into its from/to/promo fields.
|
|
37
|
+
*
|
|
38
|
+
* The null-move sentinel `0xffff` is a pass, not a from/to/promo triple; the
|
|
39
|
+
* caller must test `isNull(word)` first (see `unpackToMove`, which does).
|
|
40
|
+
*/
|
|
18
41
|
export declare function unpackMove(word: number): PackedMove;
|
|
19
42
|
/** Role enum → moves2 promotion code. */
|
|
20
43
|
export declare function roleToPromoCode(role: Role): number;
|
|
@@ -22,7 +45,12 @@ export declare function roleToPromoCode(role: Role): number;
|
|
|
22
45
|
export declare function promoCodeToRole(code: number): Role | undefined;
|
|
23
46
|
/** Packs a Move into its 16-bit word (promotion flags are honored). */
|
|
24
47
|
export declare function packOf(move: Move): number;
|
|
25
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Expands a 16-bit word into an engine Move (no legality interpretation).
|
|
50
|
+
*
|
|
51
|
+
* The null-move sentinel decodes to a first-class pass — it must NOT be masked
|
|
52
|
+
* through as the bogus normal word `from=63, to=63, promo=15`.
|
|
53
|
+
*/
|
|
26
54
|
export declare function unpackToMove(word: number): Move;
|
|
27
55
|
/** Packs a move list into a flat Uint16Array (moves2 stream). */
|
|
28
56
|
export declare function movesToPacked(moves: readonly Move[]): Uint16Array;
|
package/dist/packedMove.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packedMove.d.ts","sourceRoot":"","sources":["../src/packedMove.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE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CAAC;AAElC,yCAAyC;AACzC,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC,6EAA6E;AAC7E,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAU/B;AAED,gDAAgD;AAChD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAOnD;AAED,yCAAyC;AACzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQlD;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAQ9D;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKzC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAY/C;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,WAAW,CAIjE;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,EAAE,CAatE"}
|
package/dist/packedMove.js
CHANGED
|
@@ -18,7 +18,51 @@ export const PROMO_QUEEN = 4;
|
|
|
18
18
|
export function packMove(from, to, promo = PROMO_NONE) {
|
|
19
19
|
return ((from & 0x3f) | ((to & 0x3f) << 6) | ((promo & 0x0f) << 12)) & 0xffff;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
// ---------- null move (pass) — the first-class `0xffff` sentinel ----------
|
|
22
|
+
//
|
|
23
|
+
// The null move is NOT a from/to/promo triple: it is the single u16 sentinel
|
|
24
|
+
// `0xffff`, matching gigachess-rs `Move(0xffff)` (board.rs make_null_move).
|
|
25
|
+
// The sentinel is reserved — no legal move packs to it (the widest legal word
|
|
26
|
+
// is 0x4fff: from=63, to=63, promo=4), so the value is unambiguous in a
|
|
27
|
+
// moves2 stream.
|
|
28
|
+
/** The null-move (pass) sentinel word. */
|
|
29
|
+
export const NULL_MOVE_WORD = 0xffff;
|
|
30
|
+
/** Canonical SAN rendering of a pass — never suffixed with `+` or `#`. */
|
|
31
|
+
export const NULL_MOVE_SAN = "--";
|
|
32
|
+
/** Canonical UCI rendering of a pass. */
|
|
33
|
+
export const NULL_MOVE_UCI = "0000";
|
|
34
|
+
/** True when `word` is the null-move sentinel (a pass, not a board move). */
|
|
35
|
+
export function isNull(word) {
|
|
36
|
+
return (word & 0xffff) === NULL_MOVE_WORD;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A fresh null-move value (never share one instance across callers).
|
|
40
|
+
*
|
|
41
|
+
* `from`/`to` mirror the sentinel's own field decode (both 63) so the value
|
|
42
|
+
* round-trips through the wire format unchanged; `isNull` is what identifies
|
|
43
|
+
* it as a pass, never the squares.
|
|
44
|
+
*/
|
|
45
|
+
export function nullMove() {
|
|
46
|
+
return {
|
|
47
|
+
from: 63,
|
|
48
|
+
to: 63,
|
|
49
|
+
promotion: null,
|
|
50
|
+
isPromotion: false,
|
|
51
|
+
isEnPassant: false,
|
|
52
|
+
isCastling: false,
|
|
53
|
+
isNull: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** True when `move` is the null move (pass). */
|
|
57
|
+
export function isNullMove(move) {
|
|
58
|
+
return move.isNull === true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Unpacks a 16-bit word into its from/to/promo fields.
|
|
62
|
+
*
|
|
63
|
+
* The null-move sentinel `0xffff` is a pass, not a from/to/promo triple; the
|
|
64
|
+
* caller must test `isNull(word)` first (see `unpackToMove`, which does).
|
|
65
|
+
*/
|
|
22
66
|
export function unpackMove(word) {
|
|
23
67
|
const w = word & 0xffff;
|
|
24
68
|
return {
|
|
@@ -49,11 +93,21 @@ export function promoCodeToRole(code) {
|
|
|
49
93
|
}
|
|
50
94
|
/** Packs a Move into its 16-bit word (promotion flags are honored). */
|
|
51
95
|
export function packOf(move) {
|
|
96
|
+
// A pass is the reserved sentinel, not a from/to/promo triple.
|
|
97
|
+
if (isNullMove(move))
|
|
98
|
+
return NULL_MOVE_WORD;
|
|
52
99
|
const promo = move.promotion !== null && move.promotion !== undefined ? roleToPromoCode(move.promotion) : PROMO_NONE;
|
|
53
100
|
return packMove(move.from, move.to, promo);
|
|
54
101
|
}
|
|
55
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Expands a 16-bit word into an engine Move (no legality interpretation).
|
|
104
|
+
*
|
|
105
|
+
* The null-move sentinel decodes to a first-class pass — it must NOT be masked
|
|
106
|
+
* through as the bogus normal word `from=63, to=63, promo=15`.
|
|
107
|
+
*/
|
|
56
108
|
export function unpackToMove(word) {
|
|
109
|
+
if (isNull(word))
|
|
110
|
+
return nullMove();
|
|
57
111
|
const { from, to, promo } = unpackMove(word);
|
|
58
112
|
const role = promoCodeToRole(promo);
|
|
59
113
|
return {
|
package/dist/san.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { Position, Move, Result, SanError, UciError } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The null move is a first-class pass, not a placeholder alias: the only SAN
|
|
4
|
+
* tokens that denote one are `--` (the canonical rendering) and `Z0` (the
|
|
5
|
+
* moves2/FEN pass token). `null`, `pass` and every other spelling are rejected
|
|
6
|
+
* by `parseSan`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const NULL_MOVE_SANS: readonly string[];
|
|
9
|
+
/** True when `san` is one of the two accepted null-move tokens. */
|
|
10
|
+
export declare function isNullMoveSan(san: string): boolean;
|
|
2
11
|
export declare function makeSan(move: Move, pos: Position): string;
|
|
3
12
|
export declare function parseSan(san: string, pos: Position): Result<Move, SanError>;
|
|
4
13
|
export declare function parseUci(uci: string): Result<Move, UciError>;
|
package/dist/san.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"san.d.ts","sourceRoot":"","sources":["../src/san.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"san.d.ts","sourceRoot":"","sources":["../src/san.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQ7E;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAA0B,CAAC;AAGvE,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAYD,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAG,MAAM,CA0JzD;AAGD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAqM3E;AAGD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CA2B5D;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAmB1C"}
|
package/dist/san.js
CHANGED
|
@@ -7,8 +7,21 @@ import * as attacks from "./attacks.js";
|
|
|
7
7
|
import { Color, Role } from "./types.js";
|
|
8
8
|
import { Err, Ok } from "./types.js";
|
|
9
9
|
import { squareFile, squareRank, parseSquare, squareName } from "./util.js";
|
|
10
|
+
import { isNullMove, nullMove, NULL_MOVE_SAN, NULL_MOVE_UCI } from "./packedMove.js";
|
|
10
11
|
const ROLE_SAN = ["", "N", "B", "R", "Q", "K"];
|
|
11
12
|
const roleToSanChar = (role) => ROLE_SAN[role] ?? "";
|
|
13
|
+
/**
|
|
14
|
+
* The null move is a first-class pass, not a placeholder alias: the only SAN
|
|
15
|
+
* tokens that denote one are `--` (the canonical rendering) and `Z0` (the
|
|
16
|
+
* moves2/FEN pass token). `null`, `pass` and every other spelling are rejected
|
|
17
|
+
* by `parseSan`.
|
|
18
|
+
*/
|
|
19
|
+
export const NULL_MOVE_SANS = [NULL_MOVE_SAN, "Z0"];
|
|
20
|
+
const NULL_MOVE_SAN_SET = new Set(NULL_MOVE_SANS);
|
|
21
|
+
/** True when `san` is one of the two accepted null-move tokens. */
|
|
22
|
+
export function isNullMoveSan(san) {
|
|
23
|
+
return NULL_MOVE_SAN_SET.has(san);
|
|
24
|
+
}
|
|
12
25
|
const SAN_ROLES = { K: Role.King, Q: Role.Queen, R: Role.Rook, B: Role.Bishop, N: Role.Knight };
|
|
13
26
|
const sanCharToRole = (ch) => SAN_ROLES[ch];
|
|
14
27
|
const promoCharToRole = (ch) => SAN_ROLES[ch.toUpperCase()];
|
|
@@ -18,6 +31,11 @@ function normalizeCastlingSan(s) {
|
|
|
18
31
|
}
|
|
19
32
|
// ---------- makeSan ----------
|
|
20
33
|
export function makeSan(move, pos) {
|
|
34
|
+
// A pass renders as exactly `--` and returns here: it is never suffixed with
|
|
35
|
+
// `+` or `#` (a pass can neither give nor answer check), and it has no
|
|
36
|
+
// origin square for the castling/disambiguation paths below.
|
|
37
|
+
if (isNullMove(move))
|
|
38
|
+
return NULL_MOVE_SAN;
|
|
21
39
|
// Castling — detected via the shared detectCastling path (design D2) so a
|
|
22
40
|
// canonical castling move given in the representation's encoding renders
|
|
23
41
|
// O-O/O-O-O, never "Kg1"/"Kxh1" (measured defect: makeSan({4,6}, kiwipete)
|
|
@@ -190,6 +208,15 @@ export function makeSan(move, pos) {
|
|
|
190
208
|
export function parseSan(san, pos) {
|
|
191
209
|
const orig = san;
|
|
192
210
|
let s = normalizeCastlingSan(san.trim());
|
|
211
|
+
// Null move (pass) — exactly `--` or `Z0`, matched BEFORE any check-suffix
|
|
212
|
+
// handling so a suffixed spelling (`--+`) is not silently accepted. A pass is
|
|
213
|
+
// legal iff the side to move is not in check; the test is computed fresh from
|
|
214
|
+
// the attack tables, never from the cached `checkers` bitboard.
|
|
215
|
+
if (isNullMoveSan(s)) {
|
|
216
|
+
if (!chess.isNullMoveLegal(pos))
|
|
217
|
+
return Err({ code: "san/illegal" });
|
|
218
|
+
return Ok(nullMove());
|
|
219
|
+
}
|
|
193
220
|
// Handle check suffix for later, but keep for validation
|
|
194
221
|
let checkSuffix = "";
|
|
195
222
|
if (s.endsWith("+") || s.endsWith("#")) {
|
|
@@ -407,6 +434,11 @@ export function parseSan(san, pos) {
|
|
|
407
434
|
// ---------- UCI ----------
|
|
408
435
|
export function parseUci(uci) {
|
|
409
436
|
const s = uci.trim();
|
|
437
|
+
// The null move is the `0000` token (its own 4-char spelling, not a square
|
|
438
|
+
// pair). Parsing is position-free; the legality of a pass is judged by the
|
|
439
|
+
// validating entry points (isLegal / parseSan / makeMove).
|
|
440
|
+
if (s === NULL_MOVE_UCI)
|
|
441
|
+
return Ok(nullMove());
|
|
410
442
|
if (s.length < 4 || s.length > 5)
|
|
411
443
|
return Err({ code: "uci/invalidUci" });
|
|
412
444
|
const fromStr = s.slice(0, 2);
|
|
@@ -433,6 +465,10 @@ export function parseUci(uci) {
|
|
|
433
465
|
return Ok(move);
|
|
434
466
|
}
|
|
435
467
|
export function makeUci(move) {
|
|
468
|
+
// A pass renders as `0000` (the 16-bit sentinel's 4-char spelling) and
|
|
469
|
+
// returns here — it has no origin/destination square.
|
|
470
|
+
if (isNullMove(move))
|
|
471
|
+
return NULL_MOVE_UCI;
|
|
436
472
|
const from = squareName(move.from);
|
|
437
473
|
const to = squareName(move.to);
|
|
438
474
|
let promo = "";
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|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C1D,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1D,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/zobrist.d.ts
CHANGED
|
@@ -64,4 +64,17 @@ export declare function zobristAfterMove(pos: Position, move: {
|
|
|
64
64
|
} | undefined, newPos: Position): ZobristKey;
|
|
65
65
|
/** 16-hex-digit rendering of a {lo,hi} key (hi first, zero-padded). */
|
|
66
66
|
export declare function zobristHex(key: ZobristKey): string;
|
|
67
|
+
/**
|
|
68
|
+
* Incremental $O(1)$ Zobrist update for a null move (pass) — the delta-free
|
|
69
|
+
* counterpart of {@link zobristAfterMove}. A pass touches no piece, so the only
|
|
70
|
+
* contributions that change are the ones the transition clears/flips:
|
|
71
|
+
*
|
|
72
|
+
* - the OLD en-passant square leaves (relevance is tested against the mover's
|
|
73
|
+
* pawns, which a pass does not move) — a pass always clears the ep square,
|
|
74
|
+
* - no NEW en-passant square is ever set by a pass,
|
|
75
|
+
* - the side-to-move key flips.
|
|
76
|
+
*
|
|
77
|
+
* Mirrors gigachess-rs `Board::make_null_move` (board.rs).
|
|
78
|
+
*/
|
|
79
|
+
export declare function zobristAfterNullMove(pos: Position): ZobristKey;
|
|
67
80
|
//# sourceMappingURL=zobrist.d.ts.map
|
package/dist/zobrist.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zobrist.d.ts","sourceRoot":"","sources":["../src/zobrist.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,C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M,GAAG,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAC3G,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,EAClD,MAAM,EAAE,QAAQ,GACf,UAAU,CAmEZ;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAKlD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,QAAQ,GAAG,UAAU,CAmB9D"}
|
package/dist/zobrist.js
CHANGED
|
@@ -340,3 +340,37 @@ export function zobristHex(key) {
|
|
|
340
340
|
return ((key.hi >>> 0).toString(16).padStart(8, "0") +
|
|
341
341
|
(key.lo >>> 0).toString(16).padStart(8, "0"));
|
|
342
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Incremental $O(1)$ Zobrist update for a null move (pass) — the delta-free
|
|
345
|
+
* counterpart of {@link zobristAfterMove}. A pass touches no piece, so the only
|
|
346
|
+
* contributions that change are the ones the transition clears/flips:
|
|
347
|
+
*
|
|
348
|
+
* - the OLD en-passant square leaves (relevance is tested against the mover's
|
|
349
|
+
* pawns, which a pass does not move) — a pass always clears the ep square,
|
|
350
|
+
* - no NEW en-passant square is ever set by a pass,
|
|
351
|
+
* - the side-to-move key flips.
|
|
352
|
+
*
|
|
353
|
+
* Mirrors gigachess-rs `Board::make_null_move` (board.rs).
|
|
354
|
+
*/
|
|
355
|
+
export function zobristAfterNullMove(pos) {
|
|
356
|
+
if (!zobristTablesLoaded())
|
|
357
|
+
throw new Error("zobrist tables not loaded — call ensureZobristLoaded() first");
|
|
358
|
+
// base key: inherited from the old position, or computed once from scratch
|
|
359
|
+
let lo, hi;
|
|
360
|
+
if (pos.zobristLo !== undefined && pos.zobristHi !== undefined) {
|
|
361
|
+
lo = pos.zobristLo >>> 0;
|
|
362
|
+
hi = pos.zobristHi >>> 0;
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
const base = calculateZobrist(pos);
|
|
366
|
+
lo = base.lo;
|
|
367
|
+
hi = base.hi;
|
|
368
|
+
}
|
|
369
|
+
// the pass clears the en-passant square — hash its contribution back out
|
|
370
|
+
if (pos.epSquare !== null && pos.epSquare !== undefined && epIsHashable(pos, pos.epSquare, pos.turn)) {
|
|
371
|
+
[lo, hi] = xorInto(lo, hi, IDX_EP + (pos.epSquare & 7));
|
|
372
|
+
}
|
|
373
|
+
// side to move flipped
|
|
374
|
+
[lo, hi] = xorInto(lo, hi, IDX_SIDE);
|
|
375
|
+
return { lo: lo >>> 0, hi: hi >>> 0 };
|
|
376
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gigachess",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "The fastest chess library and engine in TypeScript. 45x faster than chess.js, 18.7M nodes/s perft, zero dependencies, 100% MIT.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"typecheck": "tsc --noEmit",
|
|
109
|
-
"test": "npm run typecheck && node tests/native-board.mjs && node tests/perft.mjs && node tests/castling.mjs && node tests/parity.mjs && node tests/purity.mjs && node tests/compat-chessops.mjs && node tests/chessjs-parity.mjs && node tests/chesstree-parity.mjs && node tests/zobrist-parity.mjs && node tests/packed-moves.mjs && node tests/zero-copy-moves.mjs && node tests/fuzz-differential.mjs",
|
|
109
|
+
"test": "npm run typecheck && node tests/native-board.mjs && node tests/perft.mjs && node tests/castling.mjs && node tests/parity.mjs && node tests/purity.mjs && node tests/compat-chessops.mjs && node tests/chessjs-parity.mjs && node tests/chesstree-parity.mjs && node tests/zobrist-parity.mjs && node tests/packed-moves.mjs && node tests/zero-copy-moves.mjs && node tests/null-move.mjs && node tests/fuzz-differential.mjs",
|
|
110
110
|
"test:fuzz": "node tests/fuzz-differential.mjs",
|
|
111
111
|
"bench": "node bench/bench-sliding.mjs --iters 1000000 && node bench/bench-perft.mjs --depth 5 && node bench/bench-pgn.mjs --games 1000 && node bench/bench-fen-san.mjs --iters 1000 && node bench/bench-bundle.mjs --entry core",
|
|
112
112
|
"bench:sliding": "node bench/bench-sliding.mjs",
|