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