ce5700d48bb74ef02fab141bfdb1aafe5f1197fb
1 import ChessRules
from "/base_rules.js";
3 export default class Align4Rules
extends ChessRules
{
9 variable: "randomness",
12 {label: "Deterministic", value: 0},
13 {label: "Random", value: 1}
16 styles: ["atomic", "capture", "cylinder"]
27 genRandInitBaseFen() {
28 let baseFen
= super.genRandInitBaseFen();
29 return { fen: baseFen
.fen
.replace("rnbqkbnr/pppppppp", "4k3/8"), o: {} };
33 let parts
= super.getPartFen(o
);
34 parts
["flags"] = parts
["flags"].substr(0, 2) + "88";
39 this.reserve
= { b: { p: 1 } };
42 // Just do not update any reserve (infinite supply)
45 getCurrentScore(move_s
) {
46 const score
= super.getCurrentScore(move_s
);
49 // Check pawns connection:
50 for (let i
= 0; i
< this.size
.x
; i
++) {
51 for (let j
= 0; j
< this.size
.y
; j
++) {
53 this.board
[i
][j
] != "" &&
54 this.getColor(i
, j
) == 'b' &&
55 this.getPiece(i
, j
) == 'p'
57 // Exploration "rightward + downward" is enough
58 for (let step
of [[1, 0], [0, 1], [1, 1], [-1, 1]]) {
59 let [ii
, jj
] = [i
+ step
[0], j
+ step
[1]];
62 this.onBoard(ii
, jj
) &&
63 this.board
[ii
][jj
] != "" &&
64 this.getColor(ii
, jj
) == 'b' &&
65 this.getPiece(ii
, jj
) == 'p'