+ atLeastOneMove() {
+ const color = this.turn;
+ 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 && this.getColor(i, j) == color) {
+ const moves = this.getPotentialMovesFrom([i, j]);
+ if (moves.length > 0) {
+ for (let k = 0; k < moves.length; k++) {
+ const m = moves[k];
+ // NOTE: not using play() here (=> infinite loop)
+ V.PlayOnBoard(this.board, m);
+ if (m.vanish[0].p == V.KING)
+ this.kingPos[color] = [m.appear[0].x, m.appear[0].y];
+ const res = !this.underCheck(color);
+ V.UndoOnBoard(this.board, m);
+ if (m.vanish[0].p == V.KING)
+ this.kingPos[color] = [m.start.x, m.start.y];
+ if (res) return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+