X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FRoyalrace.js;h=9318c1229a56336bee3e18f33323be63054cfa8d;hb=f35b9960e1c527fc400ebac85321bd4712459da3;hp=1ae531d5083fdb312861c265be0607c88a84f8ce;hpb=0ba6420d3515e278b34c29e5afa1e58f6e08e9eb;p=vchess.git diff --git a/client/src/variants/Royalrace.js b/client/src/variants/Royalrace.js index 1ae531d5..9318c122 100644 --- a/client/src/variants/Royalrace.js +++ b/client/src/variants/Royalrace.js @@ -19,10 +19,21 @@ export const VariantRules = class RoyalraceRules extends ChessRules { return { x: 11, y: 11 }; } - static GenRandInitFen() { + static GenRandInitFen(randomness) { + if (randomness == 0) + return "11/11/11/11/11/11/11/11/11/QRBNP1pnbrq/KRBNP1pnbrk w 0"; + let pieces = { w: new Array(10), b: new Array(10) }; // Shuffle pieces on first and second rank for (let c of ["w", "b"]) { + if (c == 'b' && randomness == 1) { + pieces['b'] = JSON.parse(JSON.stringify(pieces['w'])).reverse(); + pieces['b'] = + pieces['b'].splice(5,10).reverse().concat( + pieces['b'].splice(0,5).reverse()); + break; + } + // Reserve 4 and 5 which are pawns positions let positions = ArrayFun.range(10).filter(i => i != 4 && i != 5); @@ -84,9 +95,11 @@ export const VariantRules = class RoyalraceRules extends ChessRules { "11/11/11/11/11/11/11/11/11/" + whiteFen.substr(5).split("").reverse().join("") + "1" + - blackFen.substr(5).split("").reverse().join("") + + blackFen.substr(5).split("").join("") + "/" + - whiteFen.substr(0,5) + "1" + blackFen.substr(0,5) + + whiteFen.substr(0,5) + + "1" + + blackFen.substr(0,5).split("").reverse().join("") + " w 0" ); } @@ -99,15 +112,16 @@ export const VariantRules = class RoyalraceRules extends ChessRules { return m.vanish.length == 1; }); - // Captures - const shiftX = -1; - for (let shiftY of [-1, 1]) { - if ( - V.OnBoard(x + shiftX, y + shiftY) && - this.board[x + shiftX][y + shiftY] != V.EMPTY && - this.canTake([x, y], [x + shiftX, y + shiftY]) - ) { - moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY])); + // Captures (in both directions) + for (let shiftX of [-1, 1]) { + for (let shiftY of [-1, 1]) { + if ( + V.OnBoard(x + shiftX, y + shiftY) && + this.board[x + shiftX][y + shiftY] != V.EMPTY && + this.canTake([x, y], [x + shiftX, y + shiftY]) + ) { + moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY])); + } } } @@ -175,7 +189,10 @@ export const VariantRules = class RoyalraceRules extends ChessRules { if (this.kingPos[color][0] == 0) // The opposing edge is reached! return color == "w" ? "1-0" : "0-1"; - return "*"; + if (this.atLeastOneMove()) + return "*"; + // Stalemate (will probably never happen) + return "1/2"; } static get SEARCH_DEPTH() {