Experimental symmetric randomness + deterministic option
[vchess.git] / client / src / variants / Arena.js
index b92be1e..f3713e2 100644 (file)
@@ -5,8 +5,10 @@ export const VariantRules = class ArenaRules extends ChessRules {
     return false;
   }
 
-  static GenRandInitFen() {
-    return ChessRules.GenRandInitFen().replace("w 1111 -", "w -");
+  static GenRandInitFen(randomness) {
+    return ChessRules
+      .GenRandInitFen(randomness)
+      .replace("w 0 1111 -", "w 0 -");
   }
 
   static InArena(x) {
@@ -47,15 +49,17 @@ export const VariantRules = class ArenaRules extends ChessRules {
         moves.push(this.getBasicMove([x, y], [x + 2 * shiftX, y]));
       }
     }
-    // Captures
+    // Captures: also possible backward
     for (let shiftY of [-1, 1]) {
-      if (
-        y + shiftY >= 0 &&
-        y + shiftY < sizeY &&
-        this.board[x + shiftX][y + shiftY] != V.EMPTY &&
-        this.canTake([x, y], [x + shiftX, y + shiftY])
-      ) {
-        moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY]));
+      if (y + shiftY >= 0 && y + shiftY < sizeY) {
+        for (let direction of [-1,1]) {
+          if (
+            this.board[x + direction][y + shiftY] != V.EMPTY &&
+            this.canTake([x, y], [x + direction, y + shiftY])
+          ) {
+            moves.push(this.getBasicMove([x, y], [x + direction, y + shiftY]));
+          }
+        }
       }
     }