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