// Setup the initial random (asymmetric) position
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
// Deterministic:
return "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 0 1111 -";
if (!game) {
game = {
vname: this.gameInfo.vname,
- fenStart: V.GenRandInitFen(),
+ fenStart: V.GenRandInitFen(this.st.settings.randomness),
moves: []
};
game.fen = game.fenStart;
type="checkbox"
v-model="st.settings.sound"
)
+ fieldset
+ label(for="setRandomness") {{ st.tr["Randomness against computer"] }}
+ select#setRandomness(v-model="st.settings.randomness")
+ option(value="0") {{ st.tr["Deterministic"] }}
+ option(value="1") {{ st.tr["Symmetric random"] }}
+ option(value="2") {{ st.tr["Asymmetric random"] }}
</template>
<script>
const propName = event.target.id
.substr(3)
.replace(/^\w/, c => c.toLowerCase());
- const value = propName == "bcolor"
+ const value = ["bcolor","randomness"].includes(propName)
? event.target.value
: event.target.checked;
store.updateSetting(propName, value);
bcolor: localStorage.getItem("bcolor") || "lichess",
sound: getItemDefaultTrue("sound"),
hints: getItemDefaultTrue("hints"),
- highlight: getItemDefaultTrue("highlight")
+ highlight: getItemDefaultTrue("highlight"),
+ randomness: parseInt(localStorage.getItem("randomness"))
};
+ if (isNaN(this.state.settings.randomness))
+ // Default: random asymmetric
+ this.state.settings.randomness = 2;
const supportedLangs = ["en", "es", "fr"];
const navLanguage = navigator.language.substr(0,2);
this.state.lang =
"participant(s):": "participant(s):",
"Random?": "Random?",
"Randomness": "Randomness",
+ "Randomness against computer": "Randomness against computer",
Refuse: "Refuse",
Register: "Register",
"Registration complete! Please check your emails now": "Registration complete! Please check your emails now",
"participant(s):": "participante(s):",
"Random?": "Aleatorio?",
"Randomness": "Grado de azar",
+ "Randomness against computer": "Grado de azar contra la computadora",
Refuse: "Rechazar",
Register: "Registrarse",
"Registration complete! Please check your emails now": "¡Registro completo! Revise sus correos electrónicos ahora",
"participant(s):": "participant(s) :",
"Random?": "Aléatoire?",
"Randomness": "Degré d'aléa",
+ "Randomness against computer": "Degré d'aléa contre l'ordinateur",
Refuse: "Refuser",
Register: "S'enregistrer",
"Registration complete! Please check your emails now": "Enregistrement terminé ! Allez voir vos emails maintenant",
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
return "rnbqkbnr/pppppppp/3A4/8/8/3a4/PPPPPPPP/RNBQKBNR w 0 1111 -";
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
// Deterministic:
return "rnbqkbnrm/pppppppp/8/8/8/8/PPPPPPPP/MNBKQBNR w 0";
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
return "8/8/pppppppp/rnbqkbnr/8/8/PPPPPPPP/RNBQKBNR w 0 1111111111111111";
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0) {
return "rnbqkmcbnr/pppppppppp/10/10/10/10/10/10/PPPPPPPPPP/RNBQKMCBNR " +
"w 0 1111 - 00000000000000";
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
return "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w 0 -";
import { ChessRules, PiPo, Move } from "@/base_rules";
export const VariantRules = class RifleRules extends ChessRules {
- static get HasEnpassant() {
- // Due to the capturing mode, en passant is disabled
- return false;
- }
-
getBasicMove([sx, sy], [ex, ey], tr) {
let mv = new Move({
appear: [],
return mv;
}
+
+ getPotentialPawnMoves([x, y]) {
+ const color = this.turn;
+ let moves = [];
+ const [sizeX, sizeY] = [V.size.x, V.size.y];
+ const shiftX = color == "w" ? -1 : 1;
+ const startRank = color == "w" ? sizeX - 2 : 1;
+ const lastRank = color == "w" ? 0 : sizeX - 1;
+
+ const finalPieces =
+ x + shiftX == lastRank
+ ? [V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN]
+ : [V.PAWN];
+ if (this.board[x + shiftX][y] == V.EMPTY) {
+ for (let piece of finalPieces) {
+ moves.push(
+ this.getBasicMove([x, y], [x + shiftX, y], {
+ c: color,
+ p: piece
+ })
+ );
+ }
+ if (
+ x == startRank &&
+ this.board[x + 2 * shiftX][y] == V.EMPTY
+ ) {
+ moves.push(this.getBasicMove([x, y], [x + 2 * shiftX, y]));
+ }
+ }
+ // Captures
+ for (let shiftY of [-1, 1]) {
+ if (
+ y + shiftY >= 0 &&
+ y + shiftY < sizeY &&
+ this.board[x + shiftX][y + shiftY] != V.EMPTY &&
+ this.canTake([x, y], [x + shiftX, y + shiftY])
+ ) {
+ for (let piece of finalPieces) {
+ moves.push(
+ this.getBasicMove([x, y], [x + shiftX, y + shiftY], {
+ c: color,
+ p: piece
+ })
+ );
+ }
+ }
+ }
+
+ // En passant
+ const Lep = this.epSquares.length;
+ const epSquare = this.epSquares[Lep - 1]; //always at least one element
+ if (
+ !!epSquare &&
+ epSquare.x == x + shiftX &&
+ Math.abs(epSquare.y - y) == 1
+ ) {
+ let enpassantMove = new Move({
+ appear: [],
+ vanish: [],
+ start: {x:x, y:y},
+ end: {x:x+shiftX, y:epSquare.y}
+ });
+ enpassantMove.vanish.push({
+ x: x,
+ y: epSquare.y,
+ p: "p",
+ c: this.getColor(x, epSquare.y)
+ });
+ moves.push(enpassantMove);
+ }
+
+ return moves;
+ }
};
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
return "11/11/11/11/11/11/11/11/11/QRBNP1pnbrq/KRBNP1pnbrk w 0";
}
static GenRandInitFen(randomness) {
- if (!randomness) randomness = 2;
if (randomness == 0)
return "RNBQKBNR/PPPPPPPP/8/8/8/8/pppppppp/rnbqkbnr w 0";
},
gotoAnalyze: function() {
this.$router.push(
- "/analyse/" + this.gameInfo.vname + "/?fen=" + V.GenRandInitFen()
+ "/analyse/" + this.gameInfo.vname + "/?fen=" + V.GenRandInitFen(2)
);
}
}