+ if (randomness == 0) {
+ return (
+ "rnbqkmcbnr/pppppppppp/91/91/91/91/91/91/PPPPPPPPPP/RNBQKMCBNR " +
+ "w 0 ajaj - 00000000000000"
+ );
+ }
+
+ let pieces = { w: new Array(10), b: new Array(10) };
+ let flags = "";
+ for (let c of ["w", "b"]) {
+ if (c == 'b' && randomness == 1) {
+ pieces['b'] = pieces['w'];
+ flags += flags;
+ break;
+ }
+
+ let positions = ArrayFun.range(10);
+
+ // Get random squares for bishops (different colors)
+ let randIndex = 2 * randInt(5);
+ let bishop1Pos = positions[randIndex];
+ let randIndex_tmp = 2 * randInt(5) + 1;
+ let bishop2Pos = positions[randIndex_tmp];
+ positions.splice(Math.max(randIndex, randIndex_tmp), 1);
+ positions.splice(Math.min(randIndex, randIndex_tmp), 1);
+
+ randIndex = randInt(8);
+ let knight1Pos = positions[randIndex];
+ positions.splice(randIndex, 1);
+ randIndex = randInt(7);
+ let knight2Pos = positions[randIndex];
+ positions.splice(randIndex, 1);
+
+ randIndex = randInt(6);
+ let queenPos = positions[randIndex];
+ positions.splice(randIndex, 1);
+
+ // Random squares for cardinal + marshal
+ randIndex = randInt(5);
+ let cardinalPos = positions[randIndex];
+ positions.splice(randIndex, 1);
+ randIndex = randInt(4);
+ let marshalPos = positions[randIndex];
+ positions.splice(randIndex, 1);
+
+ let rook1Pos = positions[0];
+ let kingPos = positions[1];
+ let rook2Pos = positions[2];
+
+ pieces[c][rook1Pos] = "r";
+ pieces[c][knight1Pos] = "n";
+ pieces[c][bishop1Pos] = "b";
+ pieces[c][queenPos] = "q";
+ pieces[c][kingPos] = "k";
+ pieces[c][marshalPos] = "m";
+ pieces[c][cardinalPos] = "c";
+ pieces[c][bishop2Pos] = "b";
+ pieces[c][knight2Pos] = "n";
+ pieces[c][rook2Pos] = "r";
+ flags += V.CoordToColumn(rook1Pos) + V.CoordToColumn(rook2Pos);
+ }