X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=d2b8a7fd98e1dab4d6531d6522687afd1fd37b7a;hb=efdfb4c70f4a4391b8571726d924cdf58baba41c;hp=5b335b0fab80877795a126c48306e0a6414b1214;hpb=b627d118ab41dccbda68f4523de8f063d0fa89df;p=vchess.git diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 5b335b0f..d2b8a7fd 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -238,11 +238,20 @@ export const ChessRules = class ChessRules { ///////////// // FEN UTILS - // Setup the initial random (assymetric) position - static GenRandInitFen() { + // Setup the initial random (asymmetric) position + static GenRandInitFen(randomness) { + if (randomness == 0) + // Deterministic: + return "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 0 1111 -"; + let pieces = { w: new Array(8), b: new Array(8) }; - // Shuffle pieces on first and last rank + // Shuffle pieces on first (and last rank if randomness == 2) for (let c of ["w", "b"]) { + if (c == 'b' && randomness == 1) { + pieces['b'] = pieces['w']; + break; + } + let positions = ArrayFun.range(8); // Get random squares for bishops