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 return "4k3/8" + baseFen
.substring(17, 50) + " -"; //TODO: + flags 1188
32 setOtherVariables(fenParsed
) {
33 super.setOtherVariables(fenParsed
);
34 this.reserve
= { b: { p: 1 } };
37 // Just do not update any reserve (infinite supply)
40 getCastleMoves([x
, y
]) {
41 if (this.GetColor(x
, y
) == 'b')
43 return super.getCastleMoves([x
, y
]);
46 getCurrentScore(move) {
47 const score
= super.getCurrentScore(move);
50 // Check pawns connection:
51 for (let i
= 0; i
< this.size
.x
; i
++) {
52 for (let j
= 0; j
< this.size
.y
; j
++) {
54 this.board
[i
][j
] != "" &&
55 this.getColor(i
, j
) == 'b' &&
56 this.getPiece(i
, j
) == 'p'
58 // Exploration "rightward + downward" is enough
59 for (let step
of [[1, 0], [0, 1], [1, 1], [-1, 1]]) {
60 let [ii
, jj
] = [i
+ step
[0], j
+ step
[1]];
63 this.onBoard(ii
, jj
) &&
64 this.board
[ii
][jj
] != "" &&
65 this.getColor(ii
, jj
) == 'b' &&
66 this.getPiece(ii
, jj
) == 'p'