super.setOtherVariables(fen);
// Local stack of non-capturing checkered moves:
this.cmoves = [];
- const cmove = fen.split(" ")[5];
+ const cmove = V.ParseFen(fen).cmove;
if (cmove == "-") this.cmoves.push(null);
else {
this.cmoves.push({
static IsGoodFlags(flags) {
// 4 for castle + 16 for pawns
- return !!flags.match(/^[01]{20,20}$/);
+ return !!flags.match(/^[a-z]{4,4}[01]{16,16}$/);
}
setFlags(fenflags) {
w: [...Array(8).fill(true)], //pawns can move 2 squares?
b: [...Array(8).fill(true)]
};
- const flags = fenflags.substr(4); //skip first 4 digits, for castle
+ const flags = fenflags.substr(4); //skip first 4 letters, for castle
for (let c of ["w", "b"]) {
for (let i = 0; i < 8; i++)
this.pawnFlags[c][i] = flags.charAt((c == "w" ? 0 : 8) + i) == "1";
const oppCol = V.GetOppCol(this.turn);
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
- // NOTE: just testing == color isn't enough because of checkred pieces
+ // NOTE: just testing == color isn't enough because of checkered pieces
if (this.board[i][j] != V.EMPTY && this.getColor(i, j) != oppCol) {
const moves = this.getPotentialMovesFrom([i, j]);
if (moves.length > 0) {
return res;
}
- updateVariables(move) {
- super.updateVariables(move);
+ postPlay(move) {
+ super.postPlay(move);
// Does this move turn off a 2-squares pawn flag?
- const secondRank = [1, 6];
- if (secondRank.includes(move.start.x) && move.vanish[0].p == V.PAWN)
+ if ([1, 6].includes(move.start.x) && move.vanish[0].p == V.PAWN)
this.pawnFlags[move.start.x == 6 ? "w" : "b"][move.start.y] = false;
+ this.cmoves.push(this.getCmove(move));
+ }
+
+ postUndo(move) {
+ super.postUndo(move);
+ this.cmoves.pop();
}
getCurrentScore() {
}
static GenRandInitFen(randomness) {
+ // Add 16 pawns flags + empty cmove:
return ChessRules.GenRandInitFen(randomness)
- // Add 16 pawns flags + empty cmove:
- .replace(" w 0 1111", " w 0 11111111111111111111 -");
+ .slice(0, -2) + "1111111111111111 - -";
}
static ParseFen(fen) {
return fen;
}
- // TODO (design): this cmove update here or in (un)updateVariables ?
- play(move) {
- this.cmoves.push(this.getCmove(move));
- super.play(move);
- }
-
- undo(move) {
- this.cmoves.pop();
- super.undo(move);
+ static get SEARCH_DEPTH() {
+ return 2;
}
getNotation(move) {