| 1 | import { ChessRules } from "@/base_rules"; |
| 2 | |
| 3 | export class KothRules extends ChessRules { |
| 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 | ]; |
| 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 | } |
| 23 | return super.getCurrentScore(); |
| 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 | }; |