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(options
) {
23 const fen
= ChessRules
.GenRandInitFen(options
);
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(
48 sq
, V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]), 1);
51 isAttacked(sq
, color
) {
53 super.isAttacked(sq
, color
) ||
54 this.isAttackedByCommoner(sq
, color
)
58 isAttackedByCommoner(sq
, color
) {
59 return this.isAttackedBySlideNJump(
60 sq
, color
, V
.COMMONER
, V
.steps
[V
.ROOK
].concat(V
.steps
[V
.BISHOP
]), 1);
70 static get SEARCH_DEPTH() {