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();
30 fen: baseFen
.fen
.replace("rnbqkbnr/pppppppp", "4k3/8"),
31 o: {flags: baseFen
.o
.flags
.substr(0, 2) + "88"}
36 this.reserve
= { b: { p: 1 } };
39 // Just do not update any reserve (infinite supply)
42 getCurrentScore(move_s
) {
43 const score
= super.getCurrentScore(move_s
);
46 // Check pawns connection:
47 for (let i
= 0; i
< this.size
.x
; i
++) {
48 for (let j
= 0; j
< this.size
.y
; j
++) {
50 this.board
[i
][j
] != "" &&
51 this.getColor(i
, j
) == 'b' &&
52 this.getPiece(i
, j
) == 'p'
54 // Exploration "rightward + downward" is enough
55 for (let step
of [[1, 0], [0, 1], [1, 1], [-1, 1]]) {
56 let [ii
, jj
] = [i
+ step
[0], j
+ step
[1]];
59 this.onBoard(ii
, jj
) &&
60 this.board
[ii
][jj
] != "" &&
61 this.getColor(ii
, jj
) == 'b' &&
62 this.getPiece(ii
, jj
) == 'p'