Commit | Line | Data |
---|---|---|
236485b5 BA |
1 | import { ChessRules } from "@/base_rules"; |
2 | ||
3 | export class KothRules extends ChessRules { | |
7e8a7ea1 | 4 | |
107dc1bd BA |
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 | ]; | |
236485b5 BA |
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 | } | |
107dc1bd | 24 | return super.getCurrentScore(); |
236485b5 BA |
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 | } | |
7e8a7ea1 | 43 | |
236485b5 | 44 | }; |