-
Notifications
You must be signed in to change notification settings - Fork 0
/
bit-board.js
29 lines (29 loc) · 936 Bytes
/
bit-board.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Check if the code is running in Node.js
if (typeof window === "undefined") {
// Use dynamic import in Node.js
import("./zobrist.js")
.then((pkg) => {
ZobristHash = pkg.ZobristHash;
})
.catch((err) => {
console.error("Failed to load the board module:", err);
});
}
class BitBoard {
constructor(squares, enPassantFile, castlingRights, color) {
this.squares = squares;
this.enPassantFile = enPassantFile || undefined;
this.castlingRights = castlingRights || new Set(["K", "Q", "k", "q"]);
this.colorToMove = color;
if (this.colorToMove === undefined) throw new Error("Color is not defined for bitboard")
this.halfMoveCounter = 0;
this.nextFullMoveCounter = 1;
this.zobristHash = ZobristHash().computeHash(
this.squares,
this.colorToMove,
this.castlingRights,
this.enPassantFile
);
//console.log("Zobrist-Hash=" + this.zobristHash);
}
}