static IsGoodFlags(flags) {
// 4 for castle + 2 for checks (0,1 or 2)
return !!flags.match(/^[01]{4,4}[012]{2,2}$/);
static IsGoodFlags(flags) {
// 4 for castle + 2 for checks (0,1 or 2)
return !!flags.match(/^[01]{4,4}[012]{2,2}$/);
this.checkFlags = { w: 0, b: 0 };
const flags = fenflags.substr(4); //skip first 4 digits, for castle
for (let c of ["w", "b"]) {
this.checkFlags = { w: 0, b: 0 };
const flags = fenflags.substr(4); //skip first 4 digits, for castle
for (let c of ["w", "b"]) {
// Does this move give check?
const oppCol = this.turn;
if (this.underCheck(oppCol))
// Does this move give check?
const oppCol = this.turn;
if (this.underCheck(oppCol))
- return ChessRules.GenRandInitFen(randomness)
- // Add check flags (at 0)
- .replace(" w 0 1111", " w 0 111100");
+ // Add check flags (at 0)
+ return ChessRules.GenRandInitFen(randomness).slice(0, -2) + "00";
// Take number of checks into account
return baseEval/5 - this.checkFlags["w"] + this.checkFlags["b"];
}
// Take number of checks into account
return baseEval/5 - this.checkFlags["w"] + this.checkFlags["b"];
}