From: Benjamin Auder Date: Tue, 10 Mar 2020 23:08:08 +0000 (+0100) Subject: Bug fixes X-Git-Url: https://git.auder.net/js/%7B%7B%20asset%28%27mixstore/css/assets/rpsls.css?a=commitdiff_plain;h=b83a675a3066c67cc7843ae27ad8aeffd15b0976;p=vchess.git Bug fixes --- diff --git a/client/src/base_rules.js b/client/src/base_rules.js index f0fe9e6a..2bfdc997 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -1128,16 +1128,18 @@ export const ChessRules = class ChessRules { 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]); @@ -1185,19 +1187,9 @@ export const ChessRules = class ChessRules { }); // 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 = @@ -1208,10 +1200,9 @@ export const ChessRules = class ChessRules { 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)]]; diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index eb47dc90..4428f298 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -27,6 +27,12 @@ div :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( @@ -34,12 +40,6 @@ div :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] }} diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 35779ee7..a3f660e7 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -59,7 +59,7 @@ export const translations = { 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", @@ -90,7 +90,7 @@ export const translations = { "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", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index 2095f923..3b5c7ab8 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -59,7 +59,7 @@ export const translations = { 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", @@ -90,7 +90,7 @@ export const translations = { 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", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index 7030c5a6..405320c3 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -59,7 +59,7 @@ export const translations = { 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", @@ -90,7 +90,7 @@ export const translations = { 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", diff --git a/client/src/variants/Alice.js b/client/src/variants/Alice.js index 5e9ff93d..d787c42e 100644 --- a/client/src/variants/Alice.js +++ b/client/src/variants/Alice.js @@ -296,6 +296,10 @@ export const VariantRules = class AliceRules extends ChessRules { ); } + 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"; diff --git a/client/src/variants/Allmate1.js b/client/src/variants/Allmate1.js index 1149ea91..43062a39 100644 --- a/client/src/variants/Allmate1.js +++ b/client/src/variants/Allmate1.js @@ -284,7 +284,7 @@ export const VariantRules = class Allmate1Rules extends ChessRules { } static get SEARCH_DEPTH() { - return 2; + return 1; } getNotation(move) { diff --git a/client/src/variants/Allmate2.js b/client/src/variants/Allmate2.js index fe5e98ce..828e459f 100644 --- a/client/src/variants/Allmate2.js +++ b/client/src/variants/Allmate2.js @@ -288,7 +288,7 @@ export const VariantRules = class Allmate2Rules extends ChessRules { } static get SEARCH_DEPTH() { - return 2; + return 1; } getNotation(move) { diff --git a/client/src/variants/Antiking.js b/client/src/variants/Antiking.js index 6771089f..aa6b54cc 100644 --- a/client/src/variants/Antiking.js +++ b/client/src/variants/Antiking.js @@ -222,4 +222,8 @@ export const VariantRules = class AntikingRules extends ChessRules { " w 0 1111 -" ); } + + static get SEARCH_DEPTH() { + return 2; + } }; diff --git a/client/src/variants/Arena.js b/client/src/variants/Arena.js index f3713e27..9ccd3cc4 100644 --- a/client/src/variants/Arena.js +++ b/client/src/variants/Arena.js @@ -153,4 +153,8 @@ export const VariantRules = class ArenaRules extends ChessRules { } return "*"; } + + static get SEARCH_DEPTH() { + return 4; + } }; diff --git a/client/src/variants/Checkered.js b/client/src/variants/Checkered.js index 78b5ef07..1e42d995 100644 --- a/client/src/variants/Checkered.js +++ b/client/src/variants/Checkered.js @@ -279,7 +279,7 @@ export const VariantRules = class CheckeredRules extends ChessRules { 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) { @@ -414,6 +414,10 @@ export const VariantRules = class CheckeredRules extends ChessRules { super.undo(move); } + static get SEARCH_DEPTH() { + return 2; + } + getNotation(move) { if (move.appear.length == 2) { // Castle diff --git a/client/src/variants/Circular.js b/client/src/variants/Circular.js index d0abe1cc..df8d9545 100644 --- a/client/src/variants/Circular.js +++ b/client/src/variants/Circular.js @@ -246,4 +246,8 @@ export const VariantRules = class CircularRules extends ChessRules { k: 1000 }; } + + static get SEARCH_DEPTH() { + return 2; + } }; diff --git a/client/src/variants/Crazyhouse.js b/client/src/variants/Crazyhouse.js index 0a237c7d..03d7e418 100644 --- a/client/src/variants/Crazyhouse.js +++ b/client/src/variants/Crazyhouse.js @@ -234,7 +234,6 @@ export const VariantRules = class CrazyhouseRules extends ChessRules { } static get SEARCH_DEPTH() { - // High branching factor return 2; } diff --git a/client/src/variants/Cylinder.js b/client/src/variants/Cylinder.js index 39a51851..a7639aa6 100644 --- a/client/src/variants/Cylinder.js +++ b/client/src/variants/Cylinder.js @@ -134,6 +134,10 @@ export const VariantRules = class CylinderRules extends ChessRules { return false; } + static get SEARCH_DEPTH() { + return 2; + } + static get VALUES() { return { p: 1, diff --git a/client/src/variants/Enpassant.js b/client/src/variants/Enpassant.js index 3f8f3b2e..4b5ed339 100644 --- a/client/src/variants/Enpassant.js +++ b/client/src/variants/Enpassant.js @@ -212,6 +212,10 @@ export const VariantRules = class EnpassantRules extends ChessRules { ); } + static get SEARCH_DEPTH() { + return 2; + } + static get VALUES() { return { p: 1, diff --git a/client/src/variants/Grasshopper.js b/client/src/variants/Grasshopper.js index a991035b..416f6325 100644 --- a/client/src/variants/Grasshopper.js +++ b/client/src/variants/Grasshopper.js @@ -133,6 +133,10 @@ export const VariantRules = class GrasshopperRules extends ChessRules { ); } + static get SEARCH_DEPTH() { + return 2; + } + static GenRandInitFen(randomness) { return ChessRules.GenRandInitFen(randomness) .replace("w 0 1111 -", "w 0 1111") diff --git a/client/src/variants/Knightrelay.js b/client/src/variants/Knightrelay.js index de1e89ab..43aef74d 100644 --- a/client/src/variants/Knightrelay.js +++ b/client/src/variants/Knightrelay.js @@ -88,6 +88,10 @@ export const VariantRules = class KnightrelayRules extends ChessRules { }; } + static get SEARCH_DEPTH() { + return 2; + } + getNotation(move) { if (move.appear.length == 2 && move.appear[0].p == V.KING) // Castle diff --git a/client/src/variants/Magnetic.js b/client/src/variants/Magnetic.js index fedd2492..4549e846 100644 --- a/client/src/variants/Magnetic.js +++ b/client/src/variants/Magnetic.js @@ -201,4 +201,8 @@ export const VariantRules = class MagneticRules extends ChessRules { static get THRESHOLD_MATE() { return 500; //checkmates evals may be slightly below 1000 } + + static get SEARCH_DEPTH() { + return 2; + } }; diff --git a/client/src/variants/Upsidedown.js b/client/src/variants/Upsidedown.js index 2260b673..10bb83dd 100644 --- a/client/src/variants/Upsidedown.js +++ b/client/src/variants/Upsidedown.js @@ -81,4 +81,8 @@ export const VariantRules = class UpsidedownRules extends ChessRules { " w 0" ); //no castle, no en-passant } + + static get SEARCH_DEPTH() { + return 2; + } }; diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index df5ef6f3..703ba184 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -757,7 +757,7 @@ export default { 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 }; diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 14ea54fa..1261cd09 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -66,13 +66,20 @@ main 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"