+ static GenRandInitFen(randomness) {
+ if (randomness == 0) {
+ return (
+ "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL " +
+ "w 0 00000000000000"
+ );
+ }
+ let pieces = { w: new Array(9), b: new Array(9) };
+ for (let c of ["w", "b"]) {
+ if (c == 'b' && randomness == 1) {
+ pieces['b'] = pieces['w'];
+ break;
+ }
+ let positions = shuffle(ArrayFun.range(9));
+ const composition = ['l', 'l', 'n', 'n', 's', 's', 'g', 'g', 'k'];
+ for (let i = 0; i < 9; i++) pieces[c][positions[i]] = composition[i];
+ }