projects
/
vchess.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
28b32b4
)
Bug fixes
author
Benjamin Auder
<benjamin.auder@somewhere>
Tue, 10 Mar 2020 23:08:08 +0000
(
00:08
+0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Tue, 10 Mar 2020 23:08:08 +0000
(
00:08
+0100)
21 files changed:
client/src/base_rules.js
patch
|
blob
|
blame
|
history
client/src/components/MoveList.vue
patch
|
blob
|
blame
|
history
client/src/translations/en.js
patch
|
blob
|
blame
|
history
client/src/translations/es.js
patch
|
blob
|
blame
|
history
client/src/translations/fr.js
patch
|
blob
|
blame
|
history
client/src/variants/Alice.js
patch
|
blob
|
blame
|
history
client/src/variants/Allmate1.js
patch
|
blob
|
blame
|
history
client/src/variants/Allmate2.js
patch
|
blob
|
blame
|
history
client/src/variants/Antiking.js
patch
|
blob
|
blame
|
history
client/src/variants/Arena.js
patch
|
blob
|
blame
|
history
client/src/variants/Checkered.js
patch
|
blob
|
blame
|
history
client/src/variants/Circular.js
patch
|
blob
|
blame
|
history
client/src/variants/Crazyhouse.js
patch
|
blob
|
blame
|
history
client/src/variants/Cylinder.js
patch
|
blob
|
blame
|
history
client/src/variants/Enpassant.js
patch
|
blob
|
blame
|
history
client/src/variants/Grasshopper.js
patch
|
blob
|
blame
|
history
client/src/variants/Knightrelay.js
patch
|
blob
|
blame
|
history
client/src/variants/Magnetic.js
patch
|
blob
|
blame
|
history
client/src/variants/Upsidedown.js
patch
|
blob
|
blame
|
history
client/src/views/Game.vue
patch
|
blob
|
blame
|
history
client/src/views/Hall.vue
patch
|
blob
|
blame
|
history
diff --git
a/client/src/base_rules.js
b/client/src/base_rules.js
index
f0fe9e6
..
2bfdc99
100644
(file)
--- 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;
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;
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++) {
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]);
// 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]; }));
});
// 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) {
// 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++) {
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 =
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);
});
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)]];
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
eb47dc9
..
4428f29
100644
(file)
--- 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")
: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(
#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")
: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] }}
#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
35779ee
..
a3f660e
100644
(file)
--- 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!",
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",
"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):",
"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",
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
2095f92
..
3b5c7ab
100644
(file)
--- 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!",
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",
"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):",
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",
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
7030c5a
..
405320c
100644
(file)
--- 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 !",
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",
"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) :",
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",
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
5e9ff93
..
d787c42
100644
(file)
--- 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";
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
1149ea9
..
43062a3
100644
(file)
--- 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() {
}
static get SEARCH_DEPTH() {
- return
2
;
+ return
1
;
}
getNotation(move) {
}
getNotation(move) {
diff --git
a/client/src/variants/Allmate2.js
b/client/src/variants/Allmate2.js
index
fe5e98c
..
828e459
100644
(file)
--- 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() {
}
static get SEARCH_DEPTH() {
- return
2
;
+ return
1
;
}
getNotation(move) {
}
getNotation(move) {
diff --git
a/client/src/variants/Antiking.js
b/client/src/variants/Antiking.js
index
6771089
..
aa6b54c
100644
(file)
--- 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 -"
);
}
" w 0 1111 -"
);
}
+
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
};
};
diff --git
a/client/src/variants/Arena.js
b/client/src/variants/Arena.js
index
f3713e2
..
9ccd3cc
100644
(file)
--- a/
client/src/variants/Arena.js
+++ b/
client/src/variants/Arena.js
@@
-153,4
+153,8
@@
export const VariantRules = class ArenaRules extends ChessRules {
}
return "*";
}
}
return "*";
}
+
+ static get SEARCH_DEPTH() {
+ return 4;
+ }
};
};
diff --git
a/client/src/variants/Checkered.js
b/client/src/variants/Checkered.js
index
78b5ef0
..
1e42d99
100644
(file)
--- 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++) {
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 check
e
red pieces
if (this.board[i][j] != V.EMPTY && this.getColor(i, j) != oppCol) {
const moves = this.getPotentialMovesFrom([i, j]);
if (moves.length > 0) {
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);
}
super.undo(move);
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
getNotation(move) {
if (move.appear.length == 2) {
// Castle
getNotation(move) {
if (move.appear.length == 2) {
// Castle
diff --git
a/client/src/variants/Circular.js
b/client/src/variants/Circular.js
index
d0abe1c
..
df8d954
100644
(file)
--- 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
};
}
k: 1000
};
}
+
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
};
};
diff --git
a/client/src/variants/Crazyhouse.js
b/client/src/variants/Crazyhouse.js
index
0a237c7
..
03d7e41
100644
(file)
--- 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() {
}
static get SEARCH_DEPTH() {
- // High branching factor
return 2;
}
return 2;
}
diff --git
a/client/src/variants/Cylinder.js
b/client/src/variants/Cylinder.js
index
39a5185
..
a7639aa
100644
(file)
--- 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;
}
return false;
}
+ static get SEARCH_DEPTH() {
+ return 2;
+ }
+
static get VALUES() {
return {
p: 1,
static get VALUES() {
return {
p: 1,
diff --git
a/client/src/variants/Enpassant.js
b/client/src/variants/Enpassant.js
index
3f8f3b2
..
4b5ed33
100644
(file)
--- 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,
static get VALUES() {
return {
p: 1,
diff --git
a/client/src/variants/Grasshopper.js
b/client/src/variants/Grasshopper.js
index
a991035
..
416f632
100644
(file)
--- 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")
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
de1e89a
..
43aef74
100644
(file)
--- 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
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
fedd249
..
4549e84
100644
(file)
--- 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 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
2260b67
..
10bb83d
100644
(file)
--- 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
}
" 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
df5ef6f
..
703ba18
100644
(file)
--- 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,
drawSent: this.drawOffer == "sent",
rematchSent: this.rematchOffer == "sent",
score: this.game.score,
- score: this.game.scoreMsg,
+ score
Msg
: this.game.scoreMsg,
movesCount: L,
initime: this.game.initime[1 - myIdx] //relevant only if I played
};
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
14ea54f
..
1261cd0
100644
(file)
--- 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
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")
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"
input#selectPlayers(
type="text"
v-model="newchallenge.to"