import { sample, randInt } from "@/utils/alea";
export const VariantRules = class WildebeestRules extends ChessRules {
- static getPpath(b) {
- return ([V.CAMEL, V.WILDEBEEST].includes(b[1]) ? "Wildebeest/" : "") + b;
- }
-
static get size() {
return { x: 10, y: 11 };
}
return true;
}
+ getPpath(b) {
+ return ([V.CAMEL, V.WILDEBEEST].includes(b[1]) ? "Wildebeest/" : "") + b;
+ }
+
// There may be 2 enPassant squares (if pawn jump 3 squares)
getEnpassantFen() {
const L = this.epSquares.length;
const shiftX = color == "w" ? -1 : 1;
const startRanks = color == "w" ? [sizeX - 2, sizeX - 3] : [1, 2];
const lastRank = color == "w" ? 0 : sizeX - 1;
- const finalPieces =
- x + shiftX == lastRank ? [V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN] : [V.PAWN];
+ const finalPieces = x + shiftX == lastRank
+ ? [V.WILDEBEEST, V.QUEEN]
+ : [V.PAWN];
if (this.board[x + shiftX][y] == V.EMPTY) {
// One square forward
static get VALUES() {
return Object.assign(
- ChessRules.VALUES,
- { c: 3, w: 7 } //experimental
+ { c: 3, w: 7 }, //experimental
+ ChessRules.VALUES
);
}
return 2;
}
- static GenRandInitFen() {
+ static GenRandInitFen(randomness) {
+ if (!randomness) randomness = 2;
+ if (randomness == 0)
+ return "rnccwkqbbnr/ppppppppppp/11/11/11/11/11/11/PPPPPPPPPPP/RNBBQKWCCNR w 0 akak -";
+
let pieces = { w: new Array(10), b: new Array(10) };
+ let flags = "";
for (let c of ["w", "b"]) {
+ if (c == 'b' && randomness == 1) {
+ pieces['b'] = pieces['w'];
+ flags += flags;
+ break;
+ }
+
let positions = ArrayFun.range(11);
// Get random squares for bishops + camels (different colors)
for (let idx of randIndexes.concat(randIndexes_tmp).sort((a, b) => {
return b - a;
})) {
- //largest indices first
+ // Largest indices first
positions.splice(idx, 1);
}
pieces[c][bishop2Pos] = "b";
pieces[c][knight2Pos] = "n";
pieces[c][rook2Pos] = "r";
+ flags += V.CoordToColumn(rook1Pos) + V.CoordToColumn(rook2Pos);
}
return (
pieces["b"].join("") +
"/ppppppppppp/11/11/11/11/11/11/PPPPPPPPPPP/" +
pieces["w"].join("").toUpperCase() +
- " w 0 1111 -"
+ " w 0 " + flags + " -"
);
}
};