1 import { ChessRules
} from "@/base_rules";
3 export class ChecklessRules
extends ChessRules
{
4 // Cannot use super.atLeastOneMove: lead to infinite recursion
6 const color
= this.turn
;
7 const oppCol
= V
.GetOppCol(color
);
8 for (let i
= 0; i
< V
.size
.x
; i
++) {
9 for (let j
= 0; j
< V
.size
.y
; j
++) {
10 if (this.getColor(i
, j
) == color
) {
11 const moves
= this.getPotentialMovesFrom([i
, j
]);
12 if (moves
.length
> 0) {
13 for (let k
= 0; k
< moves
.length
; k
++) {
16 res
= !this.underCheck(color
) && !this.underCheck(oppCol
);
28 if (moves
.length
== 0) return [];
29 const color
= this.turn
;
30 const oppCol
= V
.GetOppCol(color
);
31 return moves
.filter(m
=> {
33 // Move shouldn't result in self-check:
34 let res
= !this.underCheck(color
);
36 const checkOpp
= this.underCheck(oppCol
);
37 // If checking the opponent, he shouldn't have any legal move:
38 res
= !checkOpp
|| checkOpp
&& !this.atLeastOneMove_aux();
45 static get SEARCH_DEPTH() {