1 import { ArrayFun
} from "@/utils/array";
2 import { randInt
, shuffle
} from "@/utils/alea";
3 import { ChessRules
, PiPo
, Move
} from "@/base_rules";
5 export const VariantRules
= class EightpiecesRules
extends ChessRules
{
17 return ChessRules
.PIECES
.concat([V
.JAILER
, V
.SENTRY
, V
.LANCER
]);
21 // TODO: more subtle, path depends on the orientations
22 // lancerOrientations should probably be a 8x8 array, for speed.
24 ([V
.JAILER
, V
.SENTRY
, V
.LANCER
].includes(b
[1])
25 ? "Eightpieces/" : "") + b
29 static IsGoodFen(fen
) {
30 if (!ChessRules
.IsGoodFen(fen
)) return false;
31 const fenParsed
= V
.ParseFen(fen
);
32 // 5) Check lancers orientations (if there are any left)
36 fenParsed
.lancers
!= "-" &&
37 !fenParsed
.lancers
.match(/^([a-h][1-8][0-7],?)+$/)
45 static ParseFen(fen
) {
46 const fenParts
= fen
.split(" ");
47 return Object
.assign(ChessRules
.ParseFen(fen
), {
52 static GenRandInitFen(randomness
) {
53 // TODO: special conditions
58 super.getFen() + " " + this.getLancersFen()
64 this.getBaseFen() + "_" +
65 this.getTurnFen() + "_" +
66 this.getFlagsFen() + "_" +
67 this.getEnpassantFen() + "_" +
74 this.lancerOrientations
.forEach(o
=> {
75 res
+= V
.CoordsToSquare(o
.sq
) + o
.dir
+ ",";
77 res
= res
.slice(0, -1);
81 setOtherVariables(fen
) {
82 super.setOtherVariables(fen
);
83 const fenParsed
= V
.ParseFen(fen
);
84 // Also init lancer orientations (from FEN):
85 this.lancerOrientations
= 32; // TODO
88 // getPotentialMoves, isAttacked: TODO
90 // updatedVariables: update lancers' orientations
92 // subTurn : if sentry moved to some enemy piece.
96 { l: 5, s: 4, j: 5 }, //experimental