-class UpsidedownRules extends ChessRules
+import { ChessRules } from "@/base_rules";
+import { randInt } from "@/utils/alea";
+import { ArrayFun } from "@/utils/array";
+
+export const VariantRules = class UpsidedownRules extends ChessRules
{
static get HasFlags() { return false; }
let pieces = { "w": new Array(8), "b": new Array(8) };
for (let c of ["w","b"])
{
- let positions = range(8);
+ let positions = ArrayFun.range(8);
- let randIndex = random(8);
+ let randIndex = randInt(8);
const kingPos = positions[randIndex];
positions.splice(randIndex, 1);
positions.splice(knight1Index, 1);
// King+knight1 are on two consecutive squares: one light, one dark
- randIndex = 2 * random(3);
+ randIndex = 2 * randInt(3);
const bishop1Pos = positions[randIndex];
- let randIndex_tmp = 2 * random(3) + 1;
+ let randIndex_tmp = 2 * randInt(3) + 1;
const bishop2Pos = positions[randIndex_tmp];
positions.splice(Math.max(randIndex,randIndex_tmp), 1);
positions.splice(Math.min(randIndex,randIndex_tmp), 1);
- randIndex = random(4);
+ randIndex = randInt(4);
const knight2Pos = positions[randIndex];
positions.splice(randIndex, 1);
- randIndex = random(3);
+ randIndex = randInt(3);
const queenPos = positions[randIndex];
positions.splice(randIndex, 1);
return pieces["w"].join("").toUpperCase() +
"/PPPPPPPP/8/8/8/8/pppppppp/" +
pieces["b"].join("") +
- " w"; //no castle, no en-passant
+ " w 0"; //no castle, no en-passant
}
}