import { ChessRules, Move, PiPo } from "@/base_rules";
-import { WildebeestRules } from "@/variants/Wildebeest";
import { ArrayFun } from "@/utils/array";
import { shuffle } from "@/utils/alea";
return Object.assign(
{},
ChessRules.PawnSpecs,
- { promotions: ChessRules.PawnSpecs.promotions.concat([V.WILDEBEEST]) }
+ { promotions: ChessRules.PawnSpecs.promotions.concat([V.CHAMPION]) }
);
}
static get HasFlags() {
return false;
}
- static get HasCastle() {
- return false;
- }
- static get WILDEBEEST() {
- return 'w';
+ static get CHAMPION() {
+ return 'c';
}
static get BALL() {
'p': 's',
'r': 'u',
'n': 'o',
- 'b': 'c',
+ 'b': 'd',
'q': 't',
'k': 'l',
- 'w': 'y'
+ 'c': 'h'
};
}
's': 'p',
'u': 'r',
'o': 'n',
- 'c': 'b',
+ 'd': 'b',
't': 'q',
'l': 'k',
- 'y': 'w'
+ 'h': 'c'
};
}
static get PIECES() {
return ChessRules.PIECES
- .concat([V.WILDEBEEST])
+ .concat([V.CHAMPION])
.concat(Object.keys(V.HAS_BALL_DECODE))
.concat(['a']);
}
let prefix = "";
const withPrefix =
Object.keys(V.HAS_BALL_DECODE)
- .concat([V.WILDEBEEST])
+ .concat([V.CHAMPION])
.concat(['a']);
if (withPrefix.includes(b[1])) prefix = "Ball/";
return prefix + b;
static GenRandInitFen(randomness) {
if (randomness == 0)
- return "rnbqkwnbr/ppppppppp/9/9/4a4/9/9/PPPPPPPPP/RNBQKWNBR w 0 -";
+ return "rnbcqcnbr/ppppppppp/9/9/4a4/9/9/PPPPPPPPP/RNBCQCNBR w 0 -";
let pieces = { w: new Array(9), b: new Array(9) };
for (let c of ["w", "b"]) {
// Get random squares for every piece, totally freely
let positions = shuffle(ArrayFun.range(9));
- const composition = ['b', 'b', 'r', 'r', 'n', 'n', 'k', 'q', 'w'];
+ const composition = ['b', 'b', 'r', 'r', 'n', 'n', 'c', 'c', 'q'];
const rem2 = positions[0] % 2;
if (rem2 == positions[1] % 2) {
// Fix bishops (on different colors)
);
}
- scanKings(fen) {}
+ scanKings() {}
static get size() {
return { x: 9, y: 9 };
}
static get steps() {
- return WildebeestRules.steps;
+ return Object.assign(
+ {},
+ ChessRules.steps,
+ // Add champion moves
+ {
+ c: [
+ [-2, -2],
+ [-2, 0],
+ [-2, 2],
+ [0, -2],
+ [0, 2],
+ [2, -2],
+ [2, 0],
+ [2, 2],
+ [-1, 0],
+ [1, 0],
+ [0, -1],
+ [0, 1]
+ ]
+ }
+ );
}
// Because of the ball, getPiece() could be wrong:
// So base implementation is fine.
getPotentialMovesFrom([x, y]) {
- if (this.getPiece(x, y) == V.WILDEBEEST)
- return this.getPotentialWildebeestMoves([x, y]);
+ if (this.getPiece(x, y) == V.CHAMPION)
+ return this.getPotentialChampionMoves([x, y]);
return super.getPotentialMovesFrom([x, y]);
}
- getPotentialWildebeestMoves(sq) {
- return this.getSlideNJumpMoves(
- sq,
- V.steps[V.KNIGHT].concat(V.steps[WildebeestRules.CAMEL]),
- "oneStep"
- );
+ // "Sliders": at most 2 steps
+ getSlideNJumpMoves([x, y], steps, oneStep) {
+ let moves = [];
+ outerLoop: for (let step of steps) {
+ let i = x + step[0];
+ let j = y + step[1];
+ let stepCount = 1;
+ while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
+ moves.push(this.getBasicMove([x, y], [i, j]));
+ if (oneStep || stepCount == 2) continue outerLoop;
+ i += step[0];
+ j += step[1];
+ stepCount++;
+ }
+ if (V.OnBoard(i, j) && this.canTake([x, y], [i, j]))
+ moves.push(this.getBasicMove([x, y], [i, j]));
+ }
+ return moves;
+ }
+
+ getPotentialChampionMoves(sq) {
+ return this.getSlideNJumpMoves(sq, V.steps[V.CHAMPION], "oneStep");
}
filterValid(moves) {
static get VALUES() {
return {
p: 1,
- r: 5,
- n: 3,
- b: 3,
- q: 9,
- w: 7,
- k: 5,
+ r: 3,
+ n: 4,
+ b: 2,
+ q: 5,
+ c: 4,
a: 0 //ball: neutral
};
}