1 import { ChessRules
} from "@/base_rules";
3 export class KothRules
extends ChessRules
{
5 if (moves
.length
== 0) return [];
6 const color
= this.turn
;
7 const oppCol
= V
.GetOppCol(color
);
8 return moves
.filter(m
=> {
10 // Giving check is forbidden as well:
11 const res
= !this.underCheck(color
) && !this.underCheck(oppCol
);
19 const color
= V
.GetOppCol(this.turn
);
21 [3,4].includes(this.kingPos
[color
][0]) &&
22 [3,4].includes(this.kingPos
[color
][1])
24 // The middle is reached!
25 return color
== "w" ? "1-0" : "0-1";
27 if (this.atLeastOneMove()) return "*";
28 // Stalemate (will probably never happen)
34 let evaluation
= super.evalPosition();
35 // Ponder with king position:
39 Math
.abs(this.kingPos
["w"][0] - 3.5) +
40 Math
.abs(this.kingPos
["w"][1] - 3.5)
43 Math
.abs(this.kingPos
["b"][0] - 3.5) +
44 Math
.abs(this.kingPos
["b"][1] - 3.5)