1 import { ChessRules
} from "@/base_rules";
4 // Stage 1 {w, b} : 2 kings on board, value 5.
5 // Stage 2: only one, get mated and all that, value 1000
6 // ...But the middle king will be captured quickly...
8 export class DoublearmyRules
extends ChessRules
{
10 static get COMMONER() {
15 return ChessRules
.PIECES
.concat([V
.COMMONER
]);
19 return (b
[1] == V
.COMMONER
? "Doublearmy/" : "") + b
;
22 static GenRandInitFen(randomness
) {
23 const fen
= ChessRules
.GenRandInitFen(randomness
);
24 const rows
= fen
.split(" ")[0].split("/");
28 rows
[0].replace('k', 'c') + "/" +
31 rows
[7].replace('K', 'C') + "/" +
33 rows
[7] + fen
.slice(-11)
37 getPotentialMovesFrom([x
, y
]) {
38 switch (this.getPiece(x
, y
)) {
40 return this.getPotentialCommonerMoves([x
, y
]);
42 return super.getPotentialMovesFrom([x
, y
]);
46 getPotentialCommonerMoves(sq
) {
47 return this.getSlideNJumpMoves(
49 V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]),
54 isAttacked(sq
, color
) {
56 super.isAttacked(sq
, color
) ||
57 this.isAttackedByCommoner(sq
, color
)
61 isAttackedByCommoner(sq
, color
) {
62 return this.isAttackedBySlideNJump(
66 V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]),
79 static get SEARCH_DEPTH() {