return this.getColor(x1, y1) !== this.getColor(x2, y2);
}
+ // TODO: currently unused, but makes sense?
+ canSelfTake([x1, y1], [x2, y2]) {
+ return true;
+ }
+
canStepOver(i, j, p) {
// In some variants, objects on boards don't stop movement (Chakart)
return this.board[i][j] == "";
}
return squares.map(s => {
let mv = this.getBasicMove([x, y], s.sq);
- if (this.options["cylinder"] && s.segments.length >= 2)
+ if (this.options["cylinder"] && !!s.segments && s.segments.length >= 2)
mv.segments = s.segments;
return mv;
});
const addSquare = ([i, j]) => {
let elt = {sq: [i, j]};
if (o.segments)
- elt.segments = this.getSegments(segments, segStart, end);
+ elt.segments = this.getSegments(segments, segStart, [i, j]);
res.push(elt);
};
const exploreSteps = (stepArray, mode) => {
// {name: 'Racingkings', desc: 'Kings cross the 8x8 board', disp: 'Racing Kings'},
// {name: 'Rampage', desc: 'Move under cover'},
// {name: 'Relayup', desc: 'Upgrade pieces', disp: 'Relay-up'},
- {name: 'Rifle', desc: 'Shoot pieces'},
{name: 'Recycle', desc: 'Reuse pieces'},
{name: 'Refusal', desc: 'Do not play that!'},
+ {name: 'Rifle', desc: 'Shoot pieces'},
// {name: 'Rollerball', desc: 'As in the movie'},
// {name: 'Rococo', desc: 'Capture on the edge'},
// {name: 'Royalrace', desc: 'Kings cross the 11x11 board', disp: 'Royal Race'},
// is piece on square x,y mated by color?
isMated(x, y, color) {
const myColor = C.GetOppTurn(color);
- if (!super.underAttack([x, y], color))
+ if (!super.underAttack([x, y], [color]))
return false;
for (let i=0; i<this.size.x; i++) {
for (let j=0; j<this.size.y; j++) {
if (i == x && j == y) {
// The mated-candidate has moved itself
testSquare = [move.end.x, move.end.y]; }
- const res = this.underAttack(testSquare, color);
+ const res = this.underAttack(testSquare, [color]);
this.undoOnBoard(move);
if (!res)
return false;
pieces(color, x, y) {
let res = super.pieces(color, x, y);
- res['p'] = BerolinaPawnSpec(color);
+ res['p'] = BerolinaPawnSpec(color); //no 2-squares moves
return res;
}
},
([i1, j1], [i2, j2]) => {
return (
- super.canTake([i1, j1], [i2, j2]) &&
+ this.getColor(i2, j2) == oppCol &&
(!this.options["zen"] || this.getPiece(i2, j2) == 'k')
);
}
byCol: [oppCol],
segments: this.options["cylinder"]
},
- ([i1, j1], [i2, j2]) =>
- this.getPiece(i1, j1) != 'k' && super.canTake([i2, j2], [i1, j1])
+ ([i1, j1], [i2, j2]) => this.getPiece(i1, j1) != 'k'
);
Array.prototype.push.apply(attacks, zenAttacks);
}
pieces(color, x, y) {
let res = super.pieces(color, x, y);
- res['p'] = BerolinaPawnSpec(color);
+ const initRank = ((color == 'w' && x == 6) || (color == 'b' && x == 1));
+ res['p'] = BerolinaPawnSpec(color, initRank);
return res;
}
-<p>TODO</p>
+<p>Pawns movements are reversed: they capture forward, and move diagonally. From the initial rank they can move two squares in diagonal. <a href="https://www.chessvariants.com/piececlopedia.dir/berolina.html">See also</a>.</p>
+
+<p class="author">Edmund Nebermann (1926).</p>
export default class BicolourRules extends ChessRules {
+ static get Options() {
+ return {
+ select: C.Options.select,
+ input: [
+ {
+ label: "King takes all",
+ variable: "takeboth",
+ type: "checkbox",
+ defaut: true
+ },
+ {
+ label: "Capture king",
+ variable: "taking",
+ type: "checkbox",
+ defaut: false
+ }
+ ],
+ styles: ["balance", "capture", "cylinder", "dark",
+ "doublemove", "madrasi", "progressive", "zen"]
+ };
+ }
+
get hasFlags() {
return false;
}
canTake([x1, y1], [x2, y2]) {
- return (this.getPiece(x2, y2) == 'k' || super.canTake([x1, y1], [x2, y2]));
+ return (
+ this.getPiece(x2, y2) == 'k' ||
+ (this.getPiece(x1, y1) == 'k' && this.options["takeboth"]) ||
+ super.canTake([x1, y1], [x2, y2])
+ );
}
genRandInitBaseFen() {
}
underCheck(square_s) {
- return (
- this.underAttack(square_s[0], 'w') ||
- this.underAttack(square_s[0], 'b')
- );
+ return super.underCheck(square_s, ['w', 'b']);
}
};
-<p>TODO</p>
+<p>
+ Kings are attacked by all pieces (enemy or friendly),
+ and can capture any of them - by default.
+ You can remove this last option in a customized game.
+</p>
+
+<p class="author">Gabriel Authier and Roméo Bédoni (1958).</p>
const coords = getRandomPiece(oldColor);
if (coords) {
const piece = this.getPiece(coords[0], coords[1]);
+ if (coords[0] == move.start.x && coords[1] == move.start.y) {
+ // Moving piece change color: fix coords
+ coords = [move.end.x, move.end.y];
+ }
em = new Move({
appear: [
new PiPo({x: coords[0], y: coords[1], c: newColor, p: piece})
square_s.forEach(sq => {
switch (this.getPiece(sq[0], sq[1])) {
case 'k':
- res ||= super.underAttack(sq, color);
+ res ||= super.underAttack(sq, [color]);
break;
case 'a':
- res ||= !super.underAttack(sq, color);
+ res ||= !super.underAttack(sq, [color]);
break;
}
});
-export default function (color) {
+export default function (color, initRank) {
const pawnShift = (color == "w" ? -1 : 1);
return {
moves: [
{
steps: [[pawnShift, 1], [pawnShift, -1]],
- range: 1
+ range: (initRank ? 2 : 1)
}
],
attack: [
// Modify capturing moves among listed pincer moves
addPincerCaptures(moves, byChameleon) {
const steps = this.pieces()['p'].moves[0].steps;
- const color = this.turn;
+ const color = moves[0].vanish[0].c;
const oppCol = C.GetOppTurn(color);
moves.forEach(m => {
if (byChameleon && m.start.x != m.end.x && m.start.y != m.end.y)
}
addCoordinatorCaptures(moves, byChameleon) {
- const color = this.turn;
+ const color = moves[0].vanish[0].c;
const oppCol = V.GetOppTurn(color);
const kp = this.searchKingPos(color)[0];
moves.forEach(m => {
getLeaperCaptures([x, y], byChameleon, onlyOne) {
// Look in every direction for captures
const steps = this.pieces()['r'].moves[0].steps;
- const color = this.turn;
+ const color = this.getColor(x, y);
const oppCol = C.GetOppTurn(color);
let moves = [];
outerLoop: for (let step of steps) {
// type: nothing (freely, capture all), or pull or push, or "exclusive"
addPushmePullyouCaptures(moves, byChameleon, type) {
- if (moves.length == 0)
- return;
const [sx, sy] = [moves[0].start.x, moves[0].start.y];
const adjacentSteps = this.pieces()['r'].moves[0].steps;
let capturingPullDir = {};
- const color = this.turn;
+ const color = moves[0].vanish[0].c;
const oppCol = C.GetOppTurn(color);
if (type != "push") {
adjacentSteps.forEach(step => {
});
}
- underAttack([x, y], oppCol) {
+ underAttack([x, y], oppCols) {
// Generate all potential opponent moves, check if king captured.
// TODO: do it more efficiently.
const color = this.getColor(x, y);
for (let i = 0; i < this.size.x; i++) {
for (let j = 0; j < this.size.y; j++) {
if (
- this.board[i][j] != "" && this.getColor(i, j) == oppCol &&
+ this.board[i][j] != "" && oppCols.includes(this.getColor(i, j)) &&
this.getPotentialMovesFrom([i, j]).some(m => {
return (
m.vanish.length >= 2 &&