f5b8f8364830dfff5ff2d3f180eb0adfde541b6a
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}
19 variable: "pawnfirst",
24 styles: ["atomic", "capture", "cylinder"]
35 genRandInitBaseFen() {
36 let baseFen
= super.genRandInitBaseFen();
38 fen: baseFen
.fen
.replace("rnbqkbnr/pppppppp", "4k3/8"),
39 o: {flags: baseFen
.o
.flags
.substr(0, 2) + "88"}
44 this.reserve
= { b: { p: 1 } };
47 // Just do not update any reserve (infinite supply)
50 canDrop([c
, p
], [i
, j
]) {
52 this.board
[i
][j
] == "" &&
54 p
!= "p" || this.options
["pawnfirst"] ||
55 (c
== 'w' && i
< this.size
.x
- 1) ||
61 getCurrentScore(move_s
) {
62 const score
= super.getCurrentScore(move_s
);
65 // Check pawns connection:
66 for (let i
= 0; i
< this.size
.x
; i
++) {
67 for (let j
= 0; j
< this.size
.y
; j
++) {
69 this.board
[i
][j
] != "" &&
70 this.getColor(i
, j
) == 'b' &&
71 this.getPiece(i
, j
) == 'p'
73 // Exploration "rightward + downward" is enough
74 for (let step
of [[1, 0], [0, 1], [1, 1], [-1, 1]]) {
75 let [ii
, jj
] = [i
+ step
[0], j
+ step
[1]];
78 this.onBoard(ii
, jj
) &&
79 this.board
[ii
][jj
] != "" &&
80 this.getColor(ii
, jj
) == 'b' &&
81 this.getPiece(ii
, jj
) == 'p'