Several small improvements + integrate options + first working draft of Cwda
[vchess.git] / client / src / variants / Minixiangqi.js
index c027aed..d8f6ebb 100644 (file)
@@ -31,17 +31,6 @@ export class MinixiangqiRules extends XiangqiRules {
     return { x: 7, y: 7};
   }
 
-  getPotentialMovesFrom(sq) {
-    switch (this.getPiece(sq[0], sq[1])) {
-      case V.PAWN: return this.getPotentialPawnMoves(sq);
-      case V.ROOK: return super.getPotentialRookMoves(sq);
-      case V.KNIGHT: return super.getPotentialKnightMoves(sq);
-      case V.KING: return super.getPotentialKingMoves(sq);
-      case V.CANNON: return super.getPotentialCannonMoves(sq);
-    }
-    return []; //never reached
-  }
-
   getPotentialPawnMoves([x, y]) {
     const c = this.getColor(x, y);
     const shiftX = (c == 'w' ? -1 : 1);
@@ -50,7 +39,7 @@ export class MinixiangqiRules extends XiangqiRules {
     if (!lastRank) steps.push([shiftX, 0]);
     if (y > 0) steps.push([0, -1]);
     if (y < 9) steps.push([0, 1]);
-    return super.getSlideNJumpMoves([x, y], steps, "oneStep");
+    return super.getSlideNJumpMoves([x, y], steps, 1);
   }
 
   insidePalace(x, y, c) {
@@ -78,13 +67,19 @@ export class MinixiangqiRules extends XiangqiRules {
     let evaluation = 0;
     for (let i = 0; i < V.size.x; i++) {
       for (let j = 0; j < V.size.y; j++) {
-        if (this.board[i][j] != V.EMPTY)
-          evaluation += (c == 'w' ? 1 : -1) * V.VALUES[this.getPiece(i, j)];
+        if (this.board[i][j] != V.EMPTY) {
+          const sign = this.getColor(i, j) == "w" ? 1 : -1;
+          evaluation += sign * V.VALUES[this.getPiece(i, j)];
+        }
       }
     }
     return evaluation;
   }
 
+  static get SEARCH_DEPTH() {
+    return 3;
+  }
+
   // Also no randomization here
   static GenRandInitFen() {
     return "rcnkncr/p1ppp1p/7/7/7/P1PPP1P/RCNKNCR w 0";