X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=93772b9bd48958442730c768c64dfb35d4b7ee20;hp=5b335b0fab80877795a126c48306e0a6414b1214;hb=7ba4a5bc5b64e19a1e7f26aa232d5c50770d07ad;hpb=de520e01c680ca3d74364f73cd29c026b86a883d diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 5b335b0f..93772b9b 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -238,11 +238,21 @@ 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) randomness = 2; + 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