d8f6ebba0d2c9de2a8c0dba716ad2b0e38b41976
1 import { ChessRules
, PiPo
, Move
} from "@/base_rules";
2 import { XiangqiRules
} from "@/variants/Xiangqi"
4 export class MinixiangqiRules
extends XiangqiRules
{
8 // Draw all inter-squares lines, shifted:
9 for (let i
= 0; i
< V
.size
.x
; i
++)
10 lines
.push([[i
+0.5, 0.5], [i
+0.5, V
.size
.y
-0.5]]);
11 for (let j
= 0; j
< V
.size
.y
; j
++)
12 lines
.push([[0.5, j
+0.5], [V
.size
.x
-0.5, j
+0.5]]);
14 lines
.push([[0.5, 2.5], [2.5, 4.5]]);
15 lines
.push([[0.5, 4.5], [2.5, 2.5]]);
16 lines
.push([[4.5, 2.5], [6.5, 4.5]]);
17 lines
.push([[4.5, 4.5], [6.5, 2.5]]);
21 // No elephants or advisors
23 return [V
.PAWN
, V
.ROOK
, V
.KNIGHT
, V
.KING
, V
.CANNON
];
27 return "Xiangqi/" + b
;
34 getPotentialPawnMoves([x
, y
]) {
35 const c
= this.getColor(x
, y
);
36 const shiftX
= (c
== 'w' ? -1 : 1);
37 const lastRank
= (c
== 'w' && x
== 0 || c
== 'b' && x
== 6);
39 if (!lastRank
) steps
.push([shiftX
, 0]);
40 if (y
> 0) steps
.push([0, -1]);
41 if (y
< 9) steps
.push([0, 1]);
42 return super.getSlideNJumpMoves([x
, y
], steps
, 1);
45 insidePalace(x
, y
, c
) {
49 (c
== 'w' && x
>= 4) ||
65 // Back to ChessRules method:
68 for (let i
= 0; i
< V
.size
.x
; i
++) {
69 for (let j
= 0; j
< V
.size
.y
; j
++) {
70 if (this.board
[i
][j
] != V
.EMPTY
) {
71 const sign
= this.getColor(i
, j
) == "w" ? 1 : -1;
72 evaluation
+= sign
* V
.VALUES
[this.getPiece(i
, j
)];
79 static get SEARCH_DEPTH() {
83 // Also no randomization here
84 static GenRandInitFen() {
85 return "rcnkncr/p1ppp1p/7/7/7/P1PPP1P/RCNKNCR w 0";