getComputerMove() {
const maxeval = V.INFINITY;
const color = this.turn;
- // Some variants may show a bigger moves list to the human (Switching),
- // thus the argument "computer" below (which is generally ignored)
let moves1 = this.getAllValidMoves();
if (moves1.length == 0)
// TODO: this situation should not happen
return null;
- // Rank moves using a min-max at depth 2
+ // Rank moves using a min-max at depth 2 (if search_depth >= 2!)
for (let i = 0; i < moves1.length; i++) {
+ if (V.SEARCH_DEPTH == 1) {
+ moves1[i].eval = this.evalPosition();
+ continue;
+ }
// Initial self evaluation is very low: "I'm checkmated"
moves1[i].eval = (color == "w" ? -1 : 1) * maxeval;
this.play(moves1[i]);
});
// console.log(moves1.map(m => { return [this.getNotation(m), m.eval]; }));
- let candidates = [0]; //indices of candidates moves
- for (let j = 1; j < moves1.length && moves1[j].eval == moves1[0].eval; j++)
- candidates.push(j);
- let currentBest = moves1[candidates[randInt(candidates.length)]];
-
// Skip depth 3+ if we found a checkmate (or if we are checkmated in 1...)
if (V.SEARCH_DEPTH >= 3 && Math.abs(moves1[0].eval) < V.THRESHOLD_MATE) {
- // From here, depth >= 3: may take a while, so we control time
- const timeStart = Date.now();
for (let i = 0; i < moves1.length; i++) {
- if (Date.now() - timeStart >= 5000)
- //more than 5 seconds
- return currentBest; //depth 2 at least
this.play(moves1[i]);
// 0.1 * oldEval : heuristic to avoid some bad moves (not all...)
moves1[i].eval =
moves1.sort((a, b) => {
return (color == "w" ? 1 : -1) * (b.eval - a.eval);
});
- } else return currentBest;
-// console.log(moves1.map(m => { return [this.getNotation(m), m.eval]; }));
+ }
- candidates = [0];
+ let candidates = [0];
for (let j = 1; j < moves1.length && moves1[j].eval == moves1[0].eval; j++)
candidates.push(j);
return moves1[candidates[randInt(candidates.length)]];
:aria-label="st.tr['Resize board']"
)
img.inline(src="/images/icons/resize.svg")
+ button.tooltip(
+ v-if="canAnalyze"
+ @click="$emit('analyze')"
+ :aria-label="st.tr['Analyse']"
+ )
+ img.inline(src="/images/icons/analyse.svg")
#downloadDiv(v-if="canDownload")
a#download(href="#")
button.tooltip(
:aria-label="st.tr['Download'] + ' PGN'"
)
img.inline(src="/images/icons/download.svg")
- button.tooltip(
- v-if="canAnalyze"
- @click="$emit('analyze')"
- :aria-label="st.tr['Analyse']"
- )
- img.inline(src="/images/icons/analyse.svg")
#scoreInfo(v-if="score!='*'")
span.score {{ score }}
span.score-msg {{ st.tr[message] }}
Login: "Login",
Logout: "Logout",
"Logout successful!": "Logout successful!",
- "Memorize?": "Memorize?",
+ "Memorize": "Memorize",
"Mispelled variant name": "Mispelled variant name",
"Missing email": "Missing email",
"Missing FEN": "Missing FEN",
"Offer draw?": "Offer draw?",
"Opponent action": "Opponent action",
"Participant(s):": "Participant(s):",
- "Play with?": "Play with?",
+ "Play with": "Play with",
Players: "Players",
"Please log in to accept corr challenges": "Please log in to accept corr challenges",
"Please log in to play correspondance games": "Please log in to play correspondance games",
Login: "Login",
Logout: "Logout",
"Logout successful!": "¡Desconexión exitosa!",
- "Memorize?": "¿Memorizar?",
+ "Memorize": "Memorizar",
"Mispelled variant name": "Variante mal escrita",
"Missing email": "Email falta",
"Missing FEN": "FEN falta",
Observe: "Observar",
"Opponent action": "Acción del adversario",
"Participant(s):": "Participante(s):",
- "Play with?": "¿Jugar con?",
+ "Play with": "Jugar con",
Players: "Jugadores",
"Please log in to accept corr challenges": "Inicia sesión para aceptar los desafíos por correspondencia",
"Please log in to play correspondance games": "Inicia sesión para jugar partidas por correspondancia",
Login: "Login",
Logout: "Logout",
"Logout successful!": "Déconnection réussie !",
- "Memorize?": "Mémoriser ?",
+ "Memorize": "Mémoriser",
"Mispelled variant name": "Variante mal orthographiée",
"Missing email": "Email manquant",
"Missing FEN": "FEN manquante",
Observe: "Observer",
"Opponent action": "Action de l'adversaire",
"Participant(s):": "Participant(s) :",
- "Play with?": "Jouer avec ?",
+ "Play with": "Jouer avec",
Players: "Joueurs",
"Please log in to accept corr challenges": "Identifiez vous pour accepter des défis par correspondance",
"Please log in to play correspondance games": "Identifiez vous pour jouer des parties par correspondance",
);
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
getNotation(move) {
if (move.appear.length == 2 && move.appear[0].p == V.KING) {
if (move.end.y < move.start.y) return "0-0-0";
}
static get SEARCH_DEPTH() {
- return 2;
+ return 1;
}
getNotation(move) {
}
static get SEARCH_DEPTH() {
- return 2;
+ return 1;
}
getNotation(move) {
" w 0 1111 -"
);
}
+
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
};
}
return "*";
}
+
+ static get SEARCH_DEPTH() {
+ return 4;
+ }
};
const oppCol = V.GetOppCol(this.turn);
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
- // NOTE: just testing == color isn't enough because of checkred pieces
+ // NOTE: just testing == color isn't enough because of checkered pieces
if (this.board[i][j] != V.EMPTY && this.getColor(i, j) != oppCol) {
const moves = this.getPotentialMovesFrom([i, j]);
if (moves.length > 0) {
super.undo(move);
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
getNotation(move) {
if (move.appear.length == 2) {
// Castle
k: 1000
};
}
+
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
};
}
static get SEARCH_DEPTH() {
- // High branching factor
return 2;
}
return false;
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
static get VALUES() {
return {
p: 1,
);
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
static get VALUES() {
return {
p: 1,
);
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
static GenRandInitFen(randomness) {
return ChessRules.GenRandInitFen(randomness)
.replace("w 0 1111 -", "w 0 1111")
};
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
getNotation(move) {
if (move.appear.length == 2 && move.appear[0].p == V.KING)
// Castle
static get THRESHOLD_MATE() {
return 500; //checkmates evals may be slightly below 1000
}
+
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
};
" w 0"
); //no castle, no en-passant
}
+
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
};
drawSent: this.drawOffer == "sent",
rematchSent: this.rematchOffer == "sent",
score: this.game.score,
- score: this.game.scoreMsg,
+ scoreMsg: this.game.scoreMsg,
movesCount: L,
initime: this.game.initime[1 - myIdx] //relevant only if I played
};
option(value="1") {{ st.tr["Symmetric random"] }}
option(value="2") {{ st.tr["Asymmetric random"] }}
fieldset
- label(for="memorizeChall") {{ st.tr["Memorize?"] }}
+ label(for="memorizeChall") {{ st.tr["Memorize"] }}
input#memorizeChall(
type="checkbox"
v-model="newchallenge.memorize"
)
fieldset(v-if="st.user.id > 0")
- label(for="selectPlayers") {{ st.tr["Play with?"] }}
+ label(for="selectPlayers") {{ st.tr["Play with"] }}
+ select#selectPlayersInList(v-model="newchallenge.to")
+ option(value="")
+ option(
+ v-for="p in Object.values(people)"
+ :value="p.name"
+ )
+ | {{ p.name }}
input#selectPlayers(
type="text"
v-model="newchallenge.to"