- if (o.diffCol) {
- o.diffCol.forEach(p => {
- // Pieces of type p on different colors:
- const firstP = res.indexOf(p),
- lastP = res.lastIndexOf(p);
- if ((firstP - lastP) % 2 != 0) {
- const choice1 = Random.randBool() ? firstP : lastP;
- let choice2;
- do {
- choice2 = Random.randInt(arr.length);
+ if (o.randomness >= 1) {
+ if (o.diffCol) {
+ o.diffCol.forEach(p => {
+ // Pieces of type p on different colors:
+ const firstP = res.indexOf(p),
+ lastP = res.lastIndexOf(p);
+ if ((firstP - lastP) % 2 != 0) {
+ const choice1 = Random.randBool() ? firstP : lastP;
+ let choice2;
+ do {
+ choice2 = Random.randInt(arr.length);
+ }
+ while (
+ choice2 == choice1 ||
+ o.diffCol.includes(choice2) ||
+ (choice2 - choice1) % 2 != 0
+ );
+ res[choice1] = res[choice2];
+ res[choice2] = p;