+ getPotentialMovesFrom([x,y])
+ {
+ let moves = super.getPotentialMovesFrom([x,y]);
+ // Add switches:
+ const V = VariantRules;
+ const color = this.turn;
+ const piece = this.getPiece(x,y);
+ const [sizeX,sizeY] = V.size;
+ const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
+ const kp = this.kingPos[color];
+ const oppCol = this.getOppCol(color);
+ for (let step of steps)
+ {
+ let [i,j] = [x+step[0],y+step[1]];
+ if (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j]!=V.EMPTY
+ && this.getColor(i,j)==color && this.getPiece(i,j)!=piece
+ // No switching under check (theoretically non-king pieces could, but not)
+ && !this.isAttacked(kp, [oppCol]))
+ {
+ let switchMove_s = this.getSwitchMove_s([x,y],[i,j]);
+ if (switchMove_s.length == 1)
+ moves.push(switchMove_s[0]);
+ else //promotion
+ moves = moves.concat(switchMove_s);
+ }
+ }
+ return moves;
+ }
+
+ static get SEARCH_DEPTH() { return 2; } //branching factor is quite high