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 genRandInitFen(seed
) {
28 const baseFen
= super.genRandInitFen(seed
);
29 const fen
= baseFen
.replace("rnbqkbnr/pppppppp", "4k3/8");
30 const fenParts
= baseFen
.split(" ");
31 let others
= JSON
.parse(fenParts
[3]);
32 others
["flags"] = others
["flags"].substr(0, 2) + "88";
33 return fenParts
.slice(0, 3).join(" ") + " " + JSON
.stringify(others
);
37 this.reserve
= { b: { p: 1 } };
40 // Just do not update any reserve (infinite supply)
43 getCurrentScore(move) {
44 const score
= super.getCurrentScore(move);
47 // Check pawns connection:
48 for (let i
= 0; i
< this.size
.x
; i
++) {
49 for (let j
= 0; j
< this.size
.y
; j
++) {
51 this.board
[i
][j
] != "" &&
52 this.getColor(i
, j
) == 'b' &&
53 this.getPiece(i
, j
) == 'p'
55 // Exploration "rightward + downward" is enough
56 for (let step
of [[1, 0], [0, 1], [1, 1], [-1, 1]]) {
57 let [ii
, jj
] = [i
+ step
[0], j
+ step
[1]];
60 this.onBoard(ii
, jj
) &&
61 this.board
[ii
][jj
] != "" &&
62 this.getColor(ii
, jj
) == 'b' &&
63 this.getPiece(ii
, jj
) == 'p'