static get steps() {
return Object.assign(
- ChessRules.steps, //add camel moves:
+ {},
+ ChessRules.steps,
+ // Add camel moves:
{
c: [
[-3, -1],
}
static IsGoodEnpassant(enpassant) {
- if (enpassant != "-") {
- const squares = enpassant.split(",");
- if (squares.length > 2) return false;
- for (let sq of squares) {
- const ep = V.SquareToCoords(sq);
- if (isNaN(ep.x) || !V.OnBoard(ep)) return false;
- }
- }
+ if (enpassant != "-") return !!enpassant.match(/^([a-j][0-9]{1,2},?)+$/);
return true;
}
// En passant
const Lep = this.epSquares.length;
const epSquare = this.epSquares[Lep - 1];
- if (epSquare) {
+ if (!!epSquare) {
for (let epsq of epSquare) {
// TODO: some redundant checks
if (epsq.x == x + shiftX && Math.abs(epsq.y - y) == 1) {
static GenRandInitFen(randomness) {
if (!randomness) randomness = 2;
- if (randomness == 0)
- return "rnccwkqbbnr/ppppppppppp/11/11/11/11/11/11/PPPPPPPPPPP/RNBBQKWCCNR w 0 akak -";
+ if (randomness == 0) {
+ return (
+ "rnccwkqbbnr/ppppppppppp/92/92/92/92/92/92/PPPPPPPPPPP/RNBBQKWCCNR " +
+ "w 0 akak -"
+ );
+ }
- let pieces = { w: new Array(10), b: new Array(10) };
+ let pieces = { w: new Array(11), b: new Array(11) };
let flags = "";
for (let c of ["w", "b"]) {
if (c == 'b' && randomness == 1) {
}
return (
pieces["b"].join("") +
- "/ppppppppppp/11/11/11/11/11/11/PPPPPPPPPPP/" +
+ "/ppppppppppp/92/92/92/92/92/92/PPPPPPPPPPP/" +
pieces["w"].join("").toUpperCase() +
" w 0 " + flags + " -"
);