Fix Koopa promotions with captures, and Balakhlava: pawns move forward
[vchess.git] / client / src / variants / Koth.js
CommitLineData
236485b5
BA
1import { ChessRules } from "@/base_rules";
2
3export class KothRules extends ChessRules {
107dc1bd
BA
4 static get Lines() {
5 return [
6 [[3, 3], [3, 5]],
7 [[3, 3], [5, 3]],
8 [[3, 5], [5, 5]],
9 [[5, 3], [5, 5]]
10 ];
236485b5
BA
11 }
12
13 getCurrentScore() {
14 // Turn has changed:
15 const color = V.GetOppCol(this.turn);
16 if (
17 [3,4].includes(this.kingPos[color][0]) &&
18 [3,4].includes(this.kingPos[color][1])
19 ) {
20 // The middle is reached!
21 return color == "w" ? "1-0" : "0-1";
22 }
107dc1bd 23 return super.getCurrentScore();
236485b5
BA
24 }
25
26 evalPosition() {
27 // Count material:
28 let evaluation = super.evalPosition();
29 // Ponder with king position:
30 return (
31 evaluation/5 +
32 (
33 Math.abs(this.kingPos["w"][0] - 3.5) +
34 Math.abs(this.kingPos["w"][1] - 3.5)
35 ) / 2 -
36 (
37 Math.abs(this.kingPos["b"][0] - 3.5) +
38 Math.abs(this.kingPos["b"][1] - 3.5)
39 ) / 2
40 );
41 }
42};