- if (this.options["randomness"] == 0)
- return "rnbkqbnm/pppppppp/8/8/8/8/PPPPPPPP/MNBQKBNR";
- const options = Object.assign({mode: "suicide"}, this.options);
- const gr = new GiveawayRules({options: options, genFenOnly: true});
- let res = gr.genRandInitBaseFen();
- let immPos = {};
- for (let c of ['w', 'b']) {
- const rookChar = (c == 'w' ? 'R' : 'r');
- switch (Random.randInt(2)) {
- case 0:
- immPos[c] = res.fen.indexOf(rookChar);
- break;
- case 1:
- immPos[c] = res.fen.lastIndexOf(rookChar);
- break;
- }
+ const s = FenUtil.setupPieces(
+ ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'i'], {diffCol: ['b']});
+ if (this.options["randomness"] <= 1) {
+ // Fix immobilizers/rooks pattern
+ const toExchange1 = s.w.indexOf('r'),
+ toExchange2 = s.w.indexOf('i');
+ s.w[toExchange1] = 'i';
+ s.w[toExchange2] = 'r';