Experimental symmetric randomness + deterministic option
[vchess.git] / client / src / variants / Antiking.js
index 3b1b36e..1c062bb 100644 (file)
@@ -3,10 +3,6 @@ import { ArrayFun } from "@/utils/array";
 import { randInt } from "@/utils/alea";
 
 export const VariantRules = class AntikingRules extends ChessRules {
-  static getPpath(b) {
-    return b[1] == "a" ? "Antiking/" + b : b;
-  }
-
   static get ANTIKING() {
     return "a";
   }
@@ -15,6 +11,10 @@ export const VariantRules = class AntikingRules extends ChessRules {
     return ChessRules.PIECES.concat([V.ANTIKING]);
   }
 
+  getPpath(b) {
+    return b[1] == "a" ? "Antiking/" + b : b;
+  }
+
   setOtherVariables(fen) {
     super.setOtherVariables(fen);
     this.antikingPos = { w: [-1, -1], b: [-1, -1] };
@@ -145,13 +145,25 @@ export const VariantRules = class AntikingRules extends ChessRules {
   }
 
   static get VALUES() {
-    return Object.assign(ChessRules.VALUES, { a: 1000 });
+    return Object.assign(
+      { a: 1000 },
+      ChessRules.VALUES
+    );
   }
 
-  static GenRandInitFen() {
+  static GenRandInitFen(randomness) {
+    if (!randomness) randomness = 2;
+    if (randomness == 0)
+      return "rnbqkbnr/pppppppp/3A4/8/8/3a4/PPPPPPPP/RNBQKBNR w 0 1111 -";
+
     let pieces = { w: new Array(8), b: new Array(8) };
     let antikingPos = { w: -1, b: -1 };
     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, but avoid corners; because,