gigachess 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -49
- package/dist/attacks.d.ts +7 -4
- package/dist/attacks.d.ts.map +1 -1
- package/dist/attacks.js +36 -15
- package/dist/chess960.d.ts +2 -9
- package/dist/chess960.d.ts.map +1 -1
- package/dist/chess960.js +2 -18
- package/dist/chessjs.d.ts +1 -1
- package/dist/chessjs.d.ts.map +1 -1
- package/dist/chessjs.js +1 -1
- package/dist/chessops/board.d.ts +1 -1
- package/dist/chessops/board.d.ts.map +1 -1
- package/dist/chessops/board.js +1 -1
- package/dist/chessops/chess.d.ts +6 -10
- package/dist/chessops/chess.d.ts.map +1 -1
- package/dist/chessops/chess.js +73 -97
- package/dist/chessops/convert.d.ts +1 -1
- package/dist/chessops/convert.d.ts.map +1 -1
- package/dist/chessops/convert.js +1 -1
- package/dist/chessops/debug.d.ts.map +1 -1
- package/dist/chessops/debug.js +7 -0
- package/dist/chessops/fen.d.ts.map +1 -1
- package/dist/chessops/fen.js +13 -2
- package/dist/chessops/fenInternal.d.ts +1 -1
- package/dist/chessops/fenInternal.d.ts.map +1 -1
- package/dist/chessops/fenInternal.js +1 -1
- package/dist/chessops/nativeBridge.d.ts +14 -0
- package/dist/chessops/nativeBridge.d.ts.map +1 -0
- package/dist/chessops/nativeBridge.js +87 -0
- package/dist/chessops/san.d.ts.map +1 -1
- package/dist/chessops/san.js +12 -10
- package/dist/chesstree.d.ts.map +1 -1
- package/dist/chesstree.js +23 -62
- package/dist/core.d.ts +6 -8
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +5 -10
- package/dist/fast/index.js +1 -1
- package/dist/fast.d.ts +1 -11
- package/dist/fast.d.ts.map +1 -1
- package/dist/fast.js +2 -11
- package/dist/index.d.ts +1 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -19
- package/dist/native96.d.ts +16 -0
- package/dist/native96.d.ts.map +1 -0
- package/dist/native96.js +6 -0
- package/dist/nativeBoard96.d.ts +118 -0
- package/dist/nativeBoard96.d.ts.map +1 -0
- package/dist/nativeBoard96.js +1077 -0
- package/dist/nativeChess.d.ts +97 -0
- package/dist/nativeChess.d.ts.map +1 -0
- package/dist/nativeChess.js +201 -0
- package/dist/nativeMovegen96.d.ts +2 -0
- package/dist/nativeMovegen96.d.ts.map +1 -0
- package/dist/{standardMovegen.js → nativeMovegen96.js} +77 -48
- package/dist/nativePublicTypes.d.ts +3 -0
- package/dist/nativePublicTypes.d.ts.map +1 -0
- package/dist/nativePublicTypes.js +1 -0
- package/dist/perftCompact.d.ts +7 -0
- package/dist/perftCompact.d.ts.map +1 -1
- package/dist/perftCompact.js +124 -62
- package/dist/pgn.d.ts +2 -3
- package/dist/pgn.d.ts.map +1 -1
- package/dist/pgn.js +2 -5
- package/dist/setupBoard.d.ts +54 -0
- package/dist/setupBoard.d.ts.map +1 -0
- package/dist/setupBoard.js +249 -0
- package/dist/{fen.d.ts → setupFen.d.ts} +1 -1
- package/dist/setupFen.d.ts.map +1 -0
- package/dist/{fen.js → setupFen.js} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/zobrist.d.ts +2 -2
- package/dist/zobrist.d.ts.map +1 -1
- package/package.json +10 -7
- package/dist/board.d.ts +0 -242
- package/dist/board.d.ts.map +0 -1
- package/dist/board.js +0 -1403
- package/dist/chess.d.ts +0 -259
- package/dist/chess.d.ts.map +0 -1
- package/dist/chess.js +0 -2314
- package/dist/fen.d.ts.map +0 -1
- package/dist/san.d.ts +0 -38
- package/dist/san.d.ts.map +0 -1
- package/dist/san.js +0 -523
- package/dist/standardMovegen.d.ts +0 -3
- package/dist/standardMovegen.d.ts.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Board96, INITIAL_FEN } from "./nativeBoard96.js";
|
|
2
|
+
import type { Move } from "./types.js";
|
|
3
|
+
import type { SquareSet } from "./squareSet.js";
|
|
4
|
+
import { type ZobristKey } from "./zobrist.js";
|
|
5
|
+
import type { TreeWrapper } from "./chesstree.js";
|
|
6
|
+
export { INITIAL_FEN };
|
|
7
|
+
export type ColorName = "w" | "b";
|
|
8
|
+
/** Baseline-style piece type char. */
|
|
9
|
+
export type PieceChar = "p" | "n" | "b" | "r" | "q" | "k";
|
|
10
|
+
/** Verbose move object (chessjs-consumer `Move` shape). */
|
|
11
|
+
export type VerboseMove = {
|
|
12
|
+
color: ColorName;
|
|
13
|
+
from: string;
|
|
14
|
+
to: string;
|
|
15
|
+
/** Absent on a null move (pass) — a pass moves no piece. */
|
|
16
|
+
piece?: PieceChar;
|
|
17
|
+
captured?: PieceChar;
|
|
18
|
+
promotion?: PieceChar;
|
|
19
|
+
flags: string;
|
|
20
|
+
san: string;
|
|
21
|
+
lan: string;
|
|
22
|
+
before: string;
|
|
23
|
+
after: string;
|
|
24
|
+
};
|
|
25
|
+
export type HistoryEntry = {
|
|
26
|
+
readonly before: Board96;
|
|
27
|
+
readonly after: Board96;
|
|
28
|
+
readonly word: number;
|
|
29
|
+
readonly san: string;
|
|
30
|
+
readonly verbose: VerboseMove;
|
|
31
|
+
};
|
|
32
|
+
export declare class Chess {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(fen?: string);
|
|
35
|
+
load(fen: string): void;
|
|
36
|
+
reset(): void;
|
|
37
|
+
fen(): string;
|
|
38
|
+
turn(): ColorName;
|
|
39
|
+
moveNumber(): number;
|
|
40
|
+
get boardInstance(): Board96;
|
|
41
|
+
get startFen(): string;
|
|
42
|
+
get historyEntries(): readonly HistoryEntry[];
|
|
43
|
+
move(input: string | {
|
|
44
|
+
from: string;
|
|
45
|
+
to: string;
|
|
46
|
+
promotion?: string;
|
|
47
|
+
}): VerboseMove | null;
|
|
48
|
+
moves(options: {
|
|
49
|
+
square?: string;
|
|
50
|
+
verbose: true;
|
|
51
|
+
}): VerboseMove[];
|
|
52
|
+
moves(options?: {
|
|
53
|
+
square?: string;
|
|
54
|
+
verbose?: false;
|
|
55
|
+
}): string[];
|
|
56
|
+
history(options: {
|
|
57
|
+
verbose: true;
|
|
58
|
+
}): VerboseMove[];
|
|
59
|
+
history(options?: {
|
|
60
|
+
verbose?: false;
|
|
61
|
+
}): string[];
|
|
62
|
+
undo(): VerboseMove | null;
|
|
63
|
+
isCheck(): boolean;
|
|
64
|
+
inCheck(): boolean;
|
|
65
|
+
isCheckmate(): boolean;
|
|
66
|
+
isStalemate(): boolean;
|
|
67
|
+
isDrawByFiftyMoves(): boolean;
|
|
68
|
+
isInsufficientMaterial(): boolean;
|
|
69
|
+
isThreefoldRepetition(): boolean;
|
|
70
|
+
isDraw(): boolean;
|
|
71
|
+
isGameOver(): boolean;
|
|
72
|
+
get(square: string): {
|
|
73
|
+
type: PieceChar;
|
|
74
|
+
color: ColorName;
|
|
75
|
+
} | undefined;
|
|
76
|
+
board(): ({
|
|
77
|
+
square: string;
|
|
78
|
+
type: PieceChar;
|
|
79
|
+
color: ColorName;
|
|
80
|
+
} | null)[][];
|
|
81
|
+
squareColor(square: string): "light" | "dark" | undefined;
|
|
82
|
+
perft(depth: number): number;
|
|
83
|
+
dests(square: string | number): SquareSet;
|
|
84
|
+
allDests(): Map<number, SquareSet>;
|
|
85
|
+
isLegal(move: Move): boolean;
|
|
86
|
+
play(move: Move): this;
|
|
87
|
+
zobrist(): ZobristKey;
|
|
88
|
+
zobristHex(): string;
|
|
89
|
+
toMoves2(): Uint16Array;
|
|
90
|
+
loadMoves2(input: Uint16Array | Uint8Array, fen?: string): void;
|
|
91
|
+
static fromMoves2(input: Uint16Array | Uint8Array, fen?: string): Chess;
|
|
92
|
+
static default(): Chess;
|
|
93
|
+
pgn(): string;
|
|
94
|
+
toTree(): TreeWrapper;
|
|
95
|
+
loadTree(pgn: string): TreeWrapper;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=nativeChess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeChess.d.ts","sourceRoot":"","sources":["../src/nativeChess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,CAAC;AAClC,sCAAsC;AACtC,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE1D,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAOF,MAAM,MAAM,YAAY,GAAC;IAAC,QAAQ,CAAC,MAAM,EAAC,OAAO,CAAC;IAAA,QAAQ,CAAC,KAAK,EAAC,OAAO,CAAC;IAAA,QAAQ,CAAC,IAAI,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,GAAG,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,OAAO,EAAC,WAAW,CAAA;CAAC,CAAC;AAoBhJ,qBAAa,KAAK;;gBAIL,GAAG,SAAY;IAC3B,IAAI,CAAC,GAAG,EAAC,MAAM,GAAE,IAAI;IACrB,KAAK,IAAG,IAAI;IACZ,GAAG,IAAG,MAAM;IACZ,IAAI,IAAG,SAAS;IAChB,UAAU,IAAG,MAAM;IACnB,IAAI,aAAa,IAAG,OAAO,CAA6B;IACxD,IAAI,QAAQ,IAAG,MAAM,CAAwB;IAC7C,IAAI,cAAc,IAAG,SAAS,YAAY,EAAE,CAA6G;IAMzJ,IAAI,CAAC,KAAK,EAAC,MAAM,GAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAA,EAAE,EAAC,MAAM,CAAC;QAAA,SAAS,CAAC,EAAC,MAAM,CAAA;KAAC,GAAE,WAAW,GAAC,IAAI;IAU7E,KAAK,CAAC,OAAO,EAAC;QAAC,MAAM,CAAC,EAAC,MAAM,CAAC;QAAA,OAAO,EAAC,IAAI,CAAA;KAAC,GAAE,WAAW,EAAE;IAC1D,KAAK,CAAC,OAAO,CAAC,EAAC;QAAC,MAAM,CAAC,EAAC,MAAM,CAAC;QAAA,OAAO,CAAC,EAAC,KAAK,CAAA;KAAC,GAAE,MAAM,EAAE;IAQxD,OAAO,CAAC,OAAO,EAAC;QAAC,OAAO,EAAC,IAAI,CAAA;KAAC,GAAE,WAAW,EAAE;IAC7C,OAAO,CAAC,OAAO,CAAC,EAAC;QAAC,OAAO,CAAC,EAAC,KAAK,CAAA;KAAC,GAAE,MAAM,EAAE;IAE3C,IAAI,IAAG,WAAW,GAAC,IAAI;IACvB,OAAO,IAAG,OAAO;IACjB,OAAO,IAAG,OAAO;IACjB,WAAW,IAAG,OAAO;IACrB,WAAW,IAAG,OAAO;IACrB,kBAAkB,IAAG,OAAO;IAC5B,sBAAsB,IAAG,OAAO;IAChC,qBAAqB,IAAG,OAAO;IAC/B,MAAM,IAAG,OAAO;IAChB,UAAU,IAAG,OAAO;IACpB,GAAG,CAAC,MAAM,EAAC,MAAM,GAAE;QAAC,IAAI,EAAC,SAAS,CAAC;QAAA,KAAK,EAAC,SAAS,CAAA;KAAC,GAAC,SAAS;IAC7D,KAAK,IAAG,CAAC;QAAC,MAAM,EAAC,MAAM,CAAC;QAAA,IAAI,EAAC,SAAS,CAAC;QAAA,KAAK,EAAC,SAAS,CAAA;KAAC,GAAC,IAAI,CAAC,EAAE,EAAE;IAIjE,WAAW,CAAC,MAAM,EAAC,MAAM,GAAE,OAAO,GAAC,MAAM,GAAC,SAAS;IACnD,KAAK,CAAC,KAAK,EAAC,MAAM,GAAE,MAAM;IAC1B,KAAK,CAAC,MAAM,EAAC,MAAM,GAAC,MAAM,GAAE,SAAS;IACrC,QAAQ,IAAG,GAAG,CAAC,MAAM,EAAC,SAAS,CAAC;IAChC,OAAO,CAAC,IAAI,EAAC,IAAI,GAAE,OAAO;IAC1B,IAAI,CAAC,IAAI,EAAC,IAAI,GAAE,IAAI;IACpB,OAAO,IAAG,UAAU;IACpB,UAAU,IAAG,MAAM;IACnB,QAAQ,IAAG,WAAW;IACtB,UAAU,CAAC,KAAK,EAAC,WAAW,GAAC,UAAU,EAAC,GAAG,SAAY,GAAE,IAAI;IAO7D,MAAM,CAAC,UAAU,CAAC,KAAK,EAAC,WAAW,GAAC,UAAU,EAAC,GAAG,SAAY,GAAE,KAAK;IACrE,MAAM,CAAC,OAAO,IAAG,KAAK;IACtB,GAAG,IAAG,MAAM;IAOZ,MAAM,IAAG,WAAW;IACpB,QAAQ,CAAC,GAAG,EAAC,MAAM,GAAE,WAAW;CAChC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Chess_instances, _Chess_board, _Chess_history, _Chess_startFen, _Chess_apply;
|
|
13
|
+
// chess.js-style interface over the sole playable engine, Board96.
|
|
14
|
+
import { Board96, INITIAL_FEN } from "./nativeBoard96.js";
|
|
15
|
+
import { squareName, parseSquare } from "./util.js";
|
|
16
|
+
import { packOf } from "./packedMove.js";
|
|
17
|
+
import { zobristTablesLoaded } from "./zobrist.js";
|
|
18
|
+
import { build as buildTreeWrapper, pgnImport as pgnImportData } from "./chesstree.js";
|
|
19
|
+
export { INITIAL_FEN };
|
|
20
|
+
const ROLE_CHARS = {
|
|
21
|
+
0: "p", 1: "n", 2: "b", 3: "r", 4: "q", 5: "k",
|
|
22
|
+
};
|
|
23
|
+
function fenOf(b) {
|
|
24
|
+
const fen = b.toFen();
|
|
25
|
+
if (b.epSquare === null || b.hasLegalEp())
|
|
26
|
+
return fen;
|
|
27
|
+
const fields = fen.split(" ");
|
|
28
|
+
fields[3] = "-";
|
|
29
|
+
return fields.join(" ");
|
|
30
|
+
}
|
|
31
|
+
function describe(b, word, after, san) {
|
|
32
|
+
const color = b.turn ? "w" : "b", before = fenOf(b), end = fenOf(after);
|
|
33
|
+
if (word === 65535)
|
|
34
|
+
return { color, from: "", to: "", flags: "", san, lan: "0000", before, after: end };
|
|
35
|
+
const from = word & 63, to = (word >>> 6) & 63, promo = word >>> 12, role = b.roleAt(from), target = b.roleAt(to);
|
|
36
|
+
let castling = -1;
|
|
37
|
+
if (role === 5)
|
|
38
|
+
for (let i = b.turn ? 0 : 2; i < (b.turn ? 2 : 4); i++)
|
|
39
|
+
if (b.castleRookSquare(i) === to) {
|
|
40
|
+
castling = i;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
const ep = role === 0 && b.epSquare === to && (from & 7) !== (to & 7) && target < 0;
|
|
44
|
+
const capture = castling < 0 && target >= 0 && b.colorAt(to) !== b.turn;
|
|
45
|
+
const landing = castling < 0 ? to : (b.turn ? 0 : 56) + (castling % 2 ? 2 : 6);
|
|
46
|
+
const flags = castling >= 0 ? (castling % 2 ? "q" : "k") : (ep ? "e" : capture ? "c" : role === 0 && Math.abs(to - from) === 16 ? "b" : "n") + (promo ? "p" : "");
|
|
47
|
+
const result = { color, from: squareName(from), to: squareName(landing), piece: ROLE_CHARS[role], flags, san, lan: squareName(from) + squareName(landing) + (promo ? ROLE_CHARS[promo] : ""), before, after: end };
|
|
48
|
+
if (ep || capture)
|
|
49
|
+
result.captured = ep ? "p" : ROLE_CHARS[target];
|
|
50
|
+
if (promo)
|
|
51
|
+
result.promotion = ROLE_CHARS[promo];
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
export class Chess {
|
|
55
|
+
constructor(fen = INITIAL_FEN) {
|
|
56
|
+
_Chess_instances.add(this);
|
|
57
|
+
_Chess_board.set(this, void 0);
|
|
58
|
+
_Chess_history.set(this, []);
|
|
59
|
+
_Chess_startFen.set(this, void 0);
|
|
60
|
+
__classPrivateFieldSet(this, _Chess_board, Board96.fromFen(fen), "f");
|
|
61
|
+
__classPrivateFieldSet(this, _Chess_startFen, this.fen(), "f");
|
|
62
|
+
}
|
|
63
|
+
load(fen) { const b = Board96.fromFen(fen); __classPrivateFieldSet(this, _Chess_board, b, "f"); __classPrivateFieldSet(this, _Chess_history, [], "f"); __classPrivateFieldSet(this, _Chess_startFen, this.fen(), "f"); }
|
|
64
|
+
reset() { this.load(INITIAL_FEN); }
|
|
65
|
+
fen() { return fenOf(__classPrivateFieldGet(this, _Chess_board, "f")); }
|
|
66
|
+
turn() { return __classPrivateFieldGet(this, _Chess_board, "f").turn ? "w" : "b"; }
|
|
67
|
+
moveNumber() { return __classPrivateFieldGet(this, _Chess_board, "f").fullmove; }
|
|
68
|
+
get boardInstance() { return __classPrivateFieldGet(this, _Chess_board, "f").clone(); }
|
|
69
|
+
get startFen() { return __classPrivateFieldGet(this, _Chess_startFen, "f"); }
|
|
70
|
+
get historyEntries() { return __classPrivateFieldGet(this, _Chess_history, "f").map(h => ({ ...h, before: h.before.clone(), after: h.after.clone(), verbose: { ...h.verbose } })); }
|
|
71
|
+
move(input) {
|
|
72
|
+
const b = __classPrivateFieldGet(this, _Chess_board, "f");
|
|
73
|
+
let word = null;
|
|
74
|
+
if (typeof input === "string") {
|
|
75
|
+
const token = input.trim();
|
|
76
|
+
word = b.parseSan(token, false) ?? b.parseUci(token);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const f = parseSquare(input.from), t = parseSquare(input.to);
|
|
80
|
+
if (f === undefined || t === undefined)
|
|
81
|
+
return null;
|
|
82
|
+
const p = input.promotion ? " nbrq".indexOf(input.promotion.toLowerCase()) : b.roleAt(f) === 0 && (t >>> 3) === (b.turn ? 7 : 0) ? 4 : 0;
|
|
83
|
+
if (p < 0)
|
|
84
|
+
return null;
|
|
85
|
+
word = b.parseUci(squareName(f) + squareName(t) + (p ? " nbrq"[p] : ""));
|
|
86
|
+
}
|
|
87
|
+
return word === null ? null : __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_apply).call(this, word);
|
|
88
|
+
}
|
|
89
|
+
moves(options) {
|
|
90
|
+
const b = __classPrivateFieldGet(this, _Chess_board, "f"), f = options?.square === undefined ? undefined : parseSquare(options.square);
|
|
91
|
+
if (options?.square !== undefined && f === undefined)
|
|
92
|
+
return [];
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const w of b.legalMoves()) {
|
|
95
|
+
if (f !== undefined && (w & 63) !== f)
|
|
96
|
+
continue;
|
|
97
|
+
const san = b.toSan(w);
|
|
98
|
+
if (options?.verbose) {
|
|
99
|
+
const c = b.clone();
|
|
100
|
+
c.playTrusted(w);
|
|
101
|
+
out.push(describe(b, w, c, san));
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
out.push(san);
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
history(options) { return options?.verbose ? __classPrivateFieldGet(this, _Chess_history, "f").map(h => ({ ...h.verbose })) : __classPrivateFieldGet(this, _Chess_history, "f").map(h => h.san); }
|
|
109
|
+
undo() { const h = __classPrivateFieldGet(this, _Chess_history, "f").pop(); if (!h)
|
|
110
|
+
return null; __classPrivateFieldSet(this, _Chess_board, h.before, "f"); return { ...h.verbose }; }
|
|
111
|
+
isCheck() { return __classPrivateFieldGet(this, _Chess_board, "f").inCheck(); }
|
|
112
|
+
inCheck() { return this.isCheck(); }
|
|
113
|
+
isCheckmate() { return __classPrivateFieldGet(this, _Chess_board, "f").isCheckmate(); }
|
|
114
|
+
isStalemate() { return __classPrivateFieldGet(this, _Chess_board, "f").isStalemate(); }
|
|
115
|
+
isDrawByFiftyMoves() { return __classPrivateFieldGet(this, _Chess_board, "f").isFiftyMoveDraw(); }
|
|
116
|
+
isInsufficientMaterial() { return __classPrivateFieldGet(this, _Chess_board, "f").isInsufficientMaterial(); }
|
|
117
|
+
isThreefoldRepetition() { let n = 1; for (const h of __classPrivateFieldGet(this, _Chess_history, "f"))
|
|
118
|
+
if (__classPrivateFieldGet(this, _Chess_board, "f").equalsForRepetition(h.before) && ++n >= 3)
|
|
119
|
+
return true; return false; }
|
|
120
|
+
isDraw() { return this.isStalemate() || this.isDrawByFiftyMoves() || this.isInsufficientMaterial() || this.isThreefoldRepetition(); }
|
|
121
|
+
isGameOver() { return this.isCheckmate() || this.isDraw(); }
|
|
122
|
+
get(square) { const i = parseSquare(square); if (i === undefined)
|
|
123
|
+
return; const p = __classPrivateFieldGet(this, _Chess_board, "f").pieceAt(i); return p ? { type: ROLE_CHARS[p.role], color: p.color ? "w" : "b" } : undefined; }
|
|
124
|
+
board() {
|
|
125
|
+
const bytes = new Uint8Array(64);
|
|
126
|
+
__classPrivateFieldGet(this, _Chess_board, "f").readPieces(bytes);
|
|
127
|
+
return Array.from({ length: 8 }, (_, r) => Array.from({ length: 8 }, (_, f) => { const i = (7 - r) * 8 + f, p = bytes[i]; return p ? { square: squareName(i), type: ROLE_CHARS[(p - 1) % 6], color: p <= 6 ? "w" : "b" } : null; }));
|
|
128
|
+
}
|
|
129
|
+
squareColor(square) { const s = parseSquare(square); return s === undefined ? undefined : ((s & 7) + (s >>> 3)) & 1 ? "light" : "dark"; }
|
|
130
|
+
perft(depth) { return __classPrivateFieldGet(this, _Chess_board, "f").perft(depth); }
|
|
131
|
+
dests(square) { const f = typeof square === "number" ? square : parseSquare(square); let lo = 0, hi = 0; for (const w of __classPrivateFieldGet(this, _Chess_board, "f").legalMoves())
|
|
132
|
+
if ((w & 63) === f) {
|
|
133
|
+
const t = (w >>> 6) & 63;
|
|
134
|
+
if (t < 32)
|
|
135
|
+
lo |= 1 << t;
|
|
136
|
+
else
|
|
137
|
+
hi |= 1 << (t - 32);
|
|
138
|
+
} return { lo: lo >>> 0, hi: hi >>> 0 }; }
|
|
139
|
+
allDests() { const out = new Map(); for (const w of __classPrivateFieldGet(this, _Chess_board, "f").legalMoves()) {
|
|
140
|
+
const f = w & 63, t = (w >>> 6) & 63, d = out.get(f) ?? { lo: 0, hi: 0 };
|
|
141
|
+
out.set(f, { lo: (d.lo | (t < 32 ? 1 << t : 0)) >>> 0, hi: (d.hi | (t >= 32 ? 1 << (t - 32) : 0)) >>> 0 });
|
|
142
|
+
} return out; }
|
|
143
|
+
isLegal(move) { return Number.isInteger(move.from) && Number.isInteger(move.to) && move.from >= 0 && move.from < 64 && move.to >= 0 && move.to < 64 && (move.promotion == null || [1, 2, 3, 4].includes(move.promotion)) && __classPrivateFieldGet(this, _Chess_board, "f").isLegal(packOf(move)); }
|
|
144
|
+
play(move) { if (!this.isLegal(move))
|
|
145
|
+
throw Error("Illegal move"); __classPrivateFieldGet(this, _Chess_instances, "m", _Chess_apply).call(this, packOf(move)); return this; }
|
|
146
|
+
zobrist() { return zobristTablesLoaded() ? __classPrivateFieldGet(this, _Chess_board, "f").zobrist() : { lo: 0, hi: 0 }; }
|
|
147
|
+
zobristHex() { return zobristTablesLoaded() ? __classPrivateFieldGet(this, _Chess_board, "f").zobristHex() : "0000000000000000"; }
|
|
148
|
+
toMoves2() { return Uint16Array.from(__classPrivateFieldGet(this, _Chess_history, "f").map(h => h.word)); }
|
|
149
|
+
loadMoves2(input, fen = INITIAL_FEN) {
|
|
150
|
+
const candidate = new Chess(fen);
|
|
151
|
+
if (input instanceof Uint8Array && input.byteLength % 2)
|
|
152
|
+
throw Error("moves2: truncated word");
|
|
153
|
+
const words = input instanceof Uint16Array ? input : Uint16Array.from({ length: input.byteLength / 2 }, (_, i) => new DataView(input.buffer, input.byteOffset, input.byteLength).getUint16(i * 2, true));
|
|
154
|
+
for (let i = 0; i < words.length; i++) {
|
|
155
|
+
const w = words[i];
|
|
156
|
+
if (!__classPrivateFieldGet(candidate, _Chess_board, "f").isLegal(w))
|
|
157
|
+
throw Error("moves2: illegal ply " + (i + 1));
|
|
158
|
+
__classPrivateFieldGet(candidate, _Chess_instances, "m", _Chess_apply).call(candidate, w);
|
|
159
|
+
}
|
|
160
|
+
__classPrivateFieldSet(this, _Chess_board, __classPrivateFieldGet(candidate, _Chess_board, "f"), "f");
|
|
161
|
+
__classPrivateFieldSet(this, _Chess_history, __classPrivateFieldGet(candidate, _Chess_history, "f"), "f");
|
|
162
|
+
__classPrivateFieldSet(this, _Chess_startFen, __classPrivateFieldGet(candidate, _Chess_startFen, "f"), "f");
|
|
163
|
+
}
|
|
164
|
+
static fromMoves2(input, fen = INITIAL_FEN) { const c = new Chess(fen); c.loadMoves2(input, fen); return c; }
|
|
165
|
+
static default() { return new Chess(); }
|
|
166
|
+
pgn() {
|
|
167
|
+
const tags = [["Event", "?"], ["Site", "?"], ["Date", "????.??.??"], ["Round", "?"], ["White", "?"], ["Black", "?"], ["Result", "*"]];
|
|
168
|
+
if (__classPrivateFieldGet(this, _Chess_startFen, "f") !== INITIAL_FEN)
|
|
169
|
+
tags.push(["SetUp", "1"], ["FEN", __classPrivateFieldGet(this, _Chess_startFen, "f")]);
|
|
170
|
+
let n = Number(__classPrivateFieldGet(this, _Chess_startFen, "f").split(" ")[5]), white = __classPrivateFieldGet(this, _Chess_startFen, "f").split(" ")[1] === "w", text = "";
|
|
171
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Chess_history, "f").length; i++) {
|
|
172
|
+
if (white)
|
|
173
|
+
text += n + ". ";
|
|
174
|
+
else if (i === 0)
|
|
175
|
+
text += n + "... ";
|
|
176
|
+
text += __classPrivateFieldGet(this, _Chess_history, "f")[i].san + " ";
|
|
177
|
+
if (!white)
|
|
178
|
+
n++;
|
|
179
|
+
white = !white;
|
|
180
|
+
}
|
|
181
|
+
return tags.map(([k, v]) => '[' + k + ' "' + v + '"]').join("\n") + "\n\n" + text + "*";
|
|
182
|
+
}
|
|
183
|
+
toTree() { const root = { id: "", ply: 0, fen: __classPrivateFieldGet(this, _Chess_startFen, "f"), uci: "", children: [] }; let node = root, ply = 0; for (const h of __classPrivateFieldGet(this, _Chess_history, "f")) {
|
|
184
|
+
const child = { id: "AA", ply: ++ply, fen: h.after.toFen(), san: h.san, uci: h.before.toUci(h.word), children: [] };
|
|
185
|
+
node.children.push(child);
|
|
186
|
+
node = child;
|
|
187
|
+
} return buildTreeWrapper(root); }
|
|
188
|
+
loadTree(pgn) { const root = pgnImportData(pgn).treeParts[0]; this.load(root?.fen ?? INITIAL_FEN); let node = root?.children[0]; while (node) {
|
|
189
|
+
if (node.san)
|
|
190
|
+
this.move(node.san);
|
|
191
|
+
node = node.children[0];
|
|
192
|
+
} return buildTreeWrapper(root ?? { id: "", ply: 0, fen: INITIAL_FEN, uci: "", children: [] }); }
|
|
193
|
+
}
|
|
194
|
+
_Chess_board = new WeakMap(), _Chess_history = new WeakMap(), _Chess_startFen = new WeakMap(), _Chess_instances = new WeakSet(), _Chess_apply = function _Chess_apply(word) {
|
|
195
|
+
const before = __classPrivateFieldGet(this, _Chess_board, "f"), after = before.clone(), san = before.toSan(word);
|
|
196
|
+
after.playTrusted(word);
|
|
197
|
+
const verbose = describe(before, word, after, san);
|
|
198
|
+
__classPrivateFieldGet(this, _Chess_history, "f").push({ before, after, word, san, verbose });
|
|
199
|
+
__classPrivateFieldSet(this, _Chess_board, after, "f");
|
|
200
|
+
return { ...verbose };
|
|
201
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeMovegen96.d.ts","sourceRoot":"","sources":["../src/nativeMovegen96.ts"],"names":[],"mappings":"AA0EA,wBAAgB,eAAe,CAAC,CAAC,EAAC,WAAW,EAAE,GAAG,EAAC,WAAW,GAAG,WAAW,GAAG,IAAI,GAAE,MAAM,CAoM1F"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Color } from "./types.js";
|
|
2
1
|
import * as a from "./attacks.js";
|
|
3
|
-
import {
|
|
2
|
+
import { castleLegal } from "./nativeBoard96.js";
|
|
3
|
+
import { popcountParts } from "./squareSet.js";
|
|
4
4
|
const bitLo = Int32Array.from({ length: 64 }, (_, s) => s < 32 ? 1 << s : 0);
|
|
5
5
|
const bitHi = Int32Array.from({ length: 64 }, (_, s) => s >= 32 ? 1 << (s - 32) : 0);
|
|
6
|
-
const rr =
|
|
7
|
-
const br =
|
|
6
|
+
const rr = a.emptyRookRays;
|
|
7
|
+
const br = a.emptyBishopRays;
|
|
8
8
|
const KLO = new Int32Array(64), KHI = new Int32Array(64), NLO = new Int32Array(64), NHI = new Int32Array(64), PLO = new Int32Array(128), PHI = new Int32Array(128);
|
|
9
9
|
for (let i = 0; i < 64; i++) {
|
|
10
10
|
const k = a.kingAttacks(i), n = a.knightAttacks(i);
|
|
@@ -37,6 +37,8 @@ function threatened(m, us, target, occ, removedLo = 0, removedHi = 0) {
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
function emit(out, count, from, lo, hi) {
|
|
40
|
+
if (!out)
|
|
41
|
+
return count + popcountParts(lo, hi);
|
|
40
42
|
while (lo) {
|
|
41
43
|
out[count++] = from | ((31 - Math.clz32(lo & -lo)) << 6);
|
|
42
44
|
lo &= lo - 1;
|
|
@@ -48,6 +50,8 @@ function emit(out, count, from, lo, hi) {
|
|
|
48
50
|
return count;
|
|
49
51
|
}
|
|
50
52
|
function emitPromotion(out, count, from, lo, hi) {
|
|
53
|
+
if (!out)
|
|
54
|
+
return count + 4 * popcountParts(lo, hi);
|
|
51
55
|
let bits = lo || hi, offset = lo ? 31 : 63;
|
|
52
56
|
while (bits) {
|
|
53
57
|
const w = from | ((offset - Math.clz32(bits & -bits)) << 6);
|
|
@@ -59,27 +63,14 @@ function emitPromotion(out, count, from, lo, hi) {
|
|
|
59
63
|
}
|
|
60
64
|
return count;
|
|
61
65
|
}
|
|
62
|
-
export function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
((b.king.lo & ownLo & ~bitLo[ks]) | (b.king.hi & ownHi & ~bitHi[ks])) !== 0 ||
|
|
71
|
-
(b.pawn.lo & 255) || (b.pawn.hi & 0xff000000))
|
|
72
|
-
return undefined;
|
|
73
|
-
const ep = pos.epSquare ?? -1, step = us ? -8 : 8, cap = ep - step;
|
|
74
|
-
if (ep >= 0 && (!Number.isInteger(ep) || ep > 63 || (ep >> 3) !== (us ? 2 : 5) ||
|
|
75
|
-
((bitLo[ep] & occ.lo) | (bitHi[ep] & occ.hi)) !== 0 ||
|
|
76
|
-
((bitLo[cap] & b.pawn.lo & enemyLo) | (bitHi[cap] & b.pawn.hi & enemyHi)) === 0))
|
|
77
|
-
return undefined;
|
|
78
|
-
const m = { pLo: enemyLo & b.pawn.lo, pHi: enemyHi & b.pawn.hi, nLo: enemyLo & b.knight.lo, nHi: enemyHi & b.knight.hi,
|
|
79
|
-
kLo: enemyLo & b.king.lo, kHi: enemyHi & b.king.hi, bLo: enemyLo & (b.bishop.lo | b.queen.lo), bHi: enemyHi & (b.bishop.hi | b.queen.hi),
|
|
80
|
-
rLo: enemyLo & (b.rook.lo | b.queen.lo), rHi: enemyHi & (b.rook.hi | b.queen.hi) };
|
|
81
|
-
if ((m.kLo | m.kHi) === 0 || (m.kLo !== 0 && m.kHi !== 0) || ((m.kLo | m.kHi) & ((m.kLo | m.kHi) - 1)) !== 0)
|
|
82
|
-
return undefined;
|
|
66
|
+
export function nativeMovesInto(w, out) {
|
|
67
|
+
const meta = w;
|
|
68
|
+
const side = ((meta[(70) >>> 2] >>> (((70) & 3) * 8)) & 255), us = (1 - side), own = 12 + side * 2, enemy = 12 + (1 - side) * 2;
|
|
69
|
+
const ownLo = w[own], ownHi = w[own + 1], enemyLo = w[enemy], enemyHi = w[enemy + 1], occ = { lo: ownLo | enemyLo, hi: ownHi | enemyHi };
|
|
70
|
+
const ks = ((meta[(64 + side) >>> 2] >>> (((64 + side) & 3) * 8)) & 255), ep0 = ((meta[(72) >>> 2] >>> (((72) & 3) * 8)) & 255), ep = ep0 === 255 ? -1 : ep0, step = us ? -8 : 8, cap = ep - step;
|
|
71
|
+
const m = { pLo: enemyLo & w[0], pHi: enemyHi & w[1], nLo: enemyLo & w[2], nHi: enemyHi & w[3],
|
|
72
|
+
kLo: enemyLo & w[10], kHi: enemyHi & w[11], bLo: enemyLo & (w[4] | w[8]), bHi: enemyHi & (w[5] | w[9]),
|
|
73
|
+
rLo: enemyLo & (w[6] | w[8]), rHi: enemyHi & (w[7] | w[9]) };
|
|
83
74
|
const pidx = (us << 6) | ks;
|
|
84
75
|
let cl = (PLO[pidx] & m.pLo) | (NLO[ks] & m.nLo) | (KLO[ks] & m.kLo), ch = (PHI[pidx] & m.pHi) | (NHI[ks] & m.nHi) | (KHI[ks] & m.kHi);
|
|
85
76
|
// Direct slider checks and pins from the same empty-board ray candidates.
|
|
@@ -103,10 +94,6 @@ export function standardMovesInto(pos, out) {
|
|
|
103
94
|
}
|
|
104
95
|
}
|
|
105
96
|
}
|
|
106
|
-
// Existing Board may represent an illegal position; use its cached
|
|
107
|
-
// checkers contract whenever the fused analysis disagrees.
|
|
108
|
-
if (pos.checkers && ((cl >>> 0) !== (pos.checkers.lo >>> 0) || (ch >>> 0) !== (pos.checkers.hi >>> 0)))
|
|
109
|
-
return undefined;
|
|
110
97
|
const ko = { lo: occ.lo & ~bitLo[ks], hi: occ.hi & ~bitHi[ks] };
|
|
111
98
|
let kl = KLO[ks] & ~ownLo, kh = KHI[ks] & ~ownHi;
|
|
112
99
|
for (let h = 0; h < 2; h++) {
|
|
@@ -122,16 +109,16 @@ export function standardMovesInto(pos, out) {
|
|
|
122
109
|
}
|
|
123
110
|
}
|
|
124
111
|
}
|
|
125
|
-
if ((cl | ch) === 0
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
if ((cl | ch) === 0) {
|
|
113
|
+
const rights = ((meta[(71) >>> 2] >>> (((71) & 3) * 8)) & 255), base = side ? 0 : 2;
|
|
114
|
+
for (let i = base; i < base + 2; i++)
|
|
115
|
+
if (rights & (1 << i)) {
|
|
116
|
+
const to = ((meta[(66 + i) >>> 2] >>> (((66 + i) & 3) * 8)) & 255);
|
|
117
|
+
if (castleLegal(w, w, side, ks, to, i)) {
|
|
118
|
+
kl |= bitLo[to];
|
|
119
|
+
kh |= bitHi[to];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
135
122
|
}
|
|
136
123
|
let count = emit(out, 0, ks, kl, kh);
|
|
137
124
|
let maskLo = ~ownLo, maskHi = ~ownHi;
|
|
@@ -142,8 +129,50 @@ export function standardMovesInto(pos, out) {
|
|
|
142
129
|
maskLo &= bt.lo | cl;
|
|
143
130
|
maskHi &= bt.hi | ch;
|
|
144
131
|
}
|
|
132
|
+
// Count-only pawn batches. EP has an exceptional two-pawn removal
|
|
133
|
+
// legality rule; retain the individual path for that position. Ordinary
|
|
134
|
+
// pinned pawns also retain exact line masking and promotion semantics.
|
|
135
|
+
const batchPawns = !out && ep < 0;
|
|
136
|
+
if (batchPawns) {
|
|
137
|
+
const l = w[0] & ownLo & ~pinLo, h = w[1] & ownHi & ~pinHi;
|
|
138
|
+
const westL = l & ~0x01010101, westH = h & ~0x01010101, eastL = l & ~0x80808080, eastH = h & ~0x80808080;
|
|
139
|
+
let oneL, oneH, twoL = 0, twoH = 0, leftL, leftH, rightL, rightH;
|
|
140
|
+
if (side) {
|
|
141
|
+
oneL = (l << 8) & ~occ.lo;
|
|
142
|
+
oneH = ((h << 8) | (l >>> 24)) & ~occ.hi;
|
|
143
|
+
twoL = ((oneL & 0x00ff0000) << 8) & ~occ.lo;
|
|
144
|
+
leftL = (westL << 7) & enemyLo;
|
|
145
|
+
leftH = ((westH << 7) | (westL >>> 25)) & enemyHi;
|
|
146
|
+
rightL = (eastL << 9) & enemyLo;
|
|
147
|
+
rightH = ((eastH << 9) | (eastL >>> 23)) & enemyHi;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
oneL = ((l >>> 8) | (h << 24)) & ~occ.lo;
|
|
151
|
+
oneH = (h >>> 8) & ~occ.hi;
|
|
152
|
+
twoH = ((oneH & 0xff00) >>> 8) & ~occ.hi;
|
|
153
|
+
leftL = ((westL >>> 9) | (westH << 23)) & enemyLo;
|
|
154
|
+
leftH = (westH >>> 9) & enemyHi;
|
|
155
|
+
rightL = ((eastL >>> 7) | (eastH << 25)) & enemyLo;
|
|
156
|
+
rightH = (eastH >>> 7) & enemyHi;
|
|
157
|
+
}
|
|
158
|
+
oneL &= maskLo;
|
|
159
|
+
oneH &= maskHi;
|
|
160
|
+
twoL &= maskLo;
|
|
161
|
+
twoH &= maskHi;
|
|
162
|
+
leftL &= maskLo;
|
|
163
|
+
leftH &= maskHi;
|
|
164
|
+
rightL &= maskLo;
|
|
165
|
+
rightH &= maskHi;
|
|
166
|
+
count += popcountParts(oneL, oneH) + popcountParts(twoL, twoH) + popcountParts(leftL, leftH) + popcountParts(rightL, rightH);
|
|
167
|
+
if (side && (h & 0xff0000))
|
|
168
|
+
count += 3 * (popcountParts(0, oneH & 0xff000000) + popcountParts(0, leftH & 0xff000000) + popcountParts(0, rightH & 0xff000000));
|
|
169
|
+
if (!side && (l & 0xff00))
|
|
170
|
+
count += 3 * (popcountParts(oneL & 255, 0) + popcountParts(leftL & 255, 0) + popcountParts(rightL & 255, 0));
|
|
171
|
+
}
|
|
145
172
|
for (let h = 0; h < 2; h++) {
|
|
146
|
-
let bits = (h === 0 ?
|
|
173
|
+
let bits = (h === 0 ? w[0] & ownLo : w[1] & ownHi);
|
|
174
|
+
if (batchPawns)
|
|
175
|
+
bits &= h === 0 ? pinLo : pinHi;
|
|
147
176
|
while (bits) {
|
|
148
177
|
const bit = bits & -bits, from = h * 32 + 31 - Math.clz32(bit);
|
|
149
178
|
bits &= bits - 1;
|
|
@@ -179,9 +208,9 @@ export function standardMovesInto(pos, out) {
|
|
|
179
208
|
}
|
|
180
209
|
}
|
|
181
210
|
{
|
|
182
|
-
const
|
|
211
|
+
const roleIndex = 2;
|
|
183
212
|
for (let h = 0; h < 2; h++) {
|
|
184
|
-
let bits = h === 0 ?
|
|
213
|
+
let bits = h === 0 ? w[roleIndex] & ownLo : w[roleIndex + 1] & ownHi;
|
|
185
214
|
while (bits) {
|
|
186
215
|
const bit = bits & -bits, from = h * 32 + 31 - Math.clz32(bit);
|
|
187
216
|
bits &= bits - 1;
|
|
@@ -196,9 +225,9 @@ export function standardMovesInto(pos, out) {
|
|
|
196
225
|
}
|
|
197
226
|
}
|
|
198
227
|
{
|
|
199
|
-
const
|
|
228
|
+
const roleIndex = 4;
|
|
200
229
|
for (let h = 0; h < 2; h++) {
|
|
201
|
-
let bits = h === 0 ?
|
|
230
|
+
let bits = h === 0 ? w[roleIndex] & ownLo : w[roleIndex + 1] & ownHi;
|
|
202
231
|
while (bits) {
|
|
203
232
|
const bit = bits & -bits, from = h * 32 + 31 - Math.clz32(bit);
|
|
204
233
|
bits &= bits - 1;
|
|
@@ -214,9 +243,9 @@ export function standardMovesInto(pos, out) {
|
|
|
214
243
|
}
|
|
215
244
|
}
|
|
216
245
|
{
|
|
217
|
-
const
|
|
246
|
+
const roleIndex = 6;
|
|
218
247
|
for (let h = 0; h < 2; h++) {
|
|
219
|
-
let bits = h === 0 ?
|
|
248
|
+
let bits = h === 0 ? w[roleIndex] & ownLo : w[roleIndex + 1] & ownHi;
|
|
220
249
|
while (bits) {
|
|
221
250
|
const bit = bits & -bits, from = h * 32 + 31 - Math.clz32(bit);
|
|
222
251
|
bits &= bits - 1;
|
|
@@ -232,9 +261,9 @@ export function standardMovesInto(pos, out) {
|
|
|
232
261
|
}
|
|
233
262
|
}
|
|
234
263
|
{
|
|
235
|
-
const
|
|
264
|
+
const roleIndex = 8;
|
|
236
265
|
for (let h = 0; h < 2; h++) {
|
|
237
|
-
let bits = h === 0 ?
|
|
266
|
+
let bits = h === 0 ? w[roleIndex] & ownLo : w[roleIndex + 1] & ownHi;
|
|
238
267
|
while (bits) {
|
|
239
268
|
const bit = bits & -bits, from = h * 32 + 31 - Math.clz32(bit);
|
|
240
269
|
bits &= bits - 1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativePublicTypes.d.ts","sourceRoot":"","sources":["../src/nativePublicTypes.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/perftCompact.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { Position } from "./types.js";
|
|
2
|
+
import type { SquareSet } from "./squareSet.js";
|
|
3
|
+
export declare const rookRay: SquareSet[];
|
|
4
|
+
export declare const bishopRay: SquareSet[];
|
|
2
5
|
export declare function compactPerft(pos: Position, depth: number): number | undefined;
|
|
6
|
+
/** Private perft adapter consumes native Board96 words directly. The
|
|
7
|
+
* compact depth workspace intentionally omits clocks/hash and uses its
|
|
8
|
+
* measured standard-only traversal. No legacy Board is constructed. */
|
|
9
|
+
export declare function compactPerft96(w: Uint32Array, depth: number): number | undefined;
|
|
3
10
|
//# sourceMappingURL=perftCompact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perftCompact.d.ts","sourceRoot":"","sources":["../src/perftCompact.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"perftCompact.d.ts","sourceRoot":"","sources":["../src/perftCompact.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAShD,eAAO,MAAM,OAAO,aAAkB,CAAC;AACvC,eAAO,MAAM,SAAS,aAAoB,CAAC;AA0S3C,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAqD7E;AAED;;uEAEuE;AACvE,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAShF"}
|