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:
b204a26
)
Adjust comments, add a few TODOs + remove DEBUG in play/undo
author
Benjamin Auder
<benjamin.auder@somewhere>
Tue, 4 Dec 2018 18:22:23 +0000
(19:22 +0100)
committer
Benjamin Auder
<benjamin.auder@somewhere>
Tue, 4 Dec 2018 18:22:23 +0000
(19:22 +0100)
20 files changed:
TODO
patch
|
blob
|
blame
|
history
package.json
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_Alt26.svg
[moved from
public/images/pieces/new/Chess_Alt26.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_Gdt45.svg
[moved from
public/images/pieces/new/Chess_Gdt45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_Gll45.svg
[moved from
public/images/pieces/new/Chess_Gll45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_Ult45.svg
[moved from
public/images/pieces/new/Chess_Ult45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_Zdl45.svg
[moved from
public/images/pieces/new/Chess_Zdl45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_Zll45.svg
[moved from
public/images/pieces/new/Chess_Zll45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_adt45.svg
[moved from
public/images/pieces/new/Chess_adt45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_alt45.svg
[moved from
public/images/pieces/new/Chess_alt45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/Chess_clt45.svg
[moved from
public/images/pieces/new/Chess_clt45.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/camel-animal-pet-desert-39f82768c72363eb.svg
[moved from
public/images/pieces/new/camel-animal-pet-desert-39f82768c72363eb.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/camel-animal-pet-desert-3f04e77f40eba40d.svg
[moved from
public/images/pieces/new/camel-animal-pet-desert-3f04e77f40eba40d.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/camel-animal-wildlife-34b2662eb81cfec3.svg
[moved from
public/images/pieces/new/camel-animal-wildlife-34b2662eb81cfec3.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/camel-animal-wildlife-3b15afb5e788b9ec.svg
[moved from
public/images/pieces/new/camel-animal-wildlife-3b15afb5e788b9ec.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/unicorn-myth-legend-halloween-fantasy-37ec614cb63bc127.svg
[moved from
public/images/pieces/new/unicorn-myth-legend-halloween-fantasy-37ec614cb63bc127.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/wildebeest-animal-wild-wildlife-face-326845431b848a31.svg
[moved from
public/images/pieces/new/wildebeest-animal-wild-wildlife-face-326845431b848a31.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/images/pieces/_originals/wildebeest-animal-wildlife-31b7b8fe2ffee150.svg
[moved from
public/images/pieces/new/wildebeest-animal-wildlife-31b7b8fe2ffee150.svg
with 100% similarity]
patch
|
blob
|
blame
|
history
public/javascripts/base_rules.js
patch
|
blob
|
blame
|
history
public/javascripts/components/game.js
patch
|
blob
|
blame
|
history
diff --git
a/TODO
b/TODO
index
7271a90
..
1aae2fb
100644
(file)
--- a/
TODO
+++ b/
TODO
@@
-3,5
+3,4
@@
For animation, moves should contains "moving" and "fading" maybe...
setInterval "CRON" task in sockets.js to check connected clients
(every 1hour maybe, or more)
Button to show all pieces that can move (next to expert mode; change icons)
setInterval "CRON" task in sockets.js to check connected clients
(every 1hour maybe, or more)
Button to show all pieces that can move (next to expert mode; change icons)
-Style (crazyhouse): ghost image of reserve pieces are initially translated
Some bots are very weak, others quite slow...
Some bots are very weak, others quite slow...
diff --git
a/package.json
b/package.json
index
ee95dd5
..
6209227
100644
(file)
--- a/
package.json
+++ b/
package.json
@@
-1,6
+1,6
@@
{
{
- "name": "vc",
- "version": "0.
0
.0",
+ "name": "vc
hess
",
+ "version": "0.
1
.0",
"private": true,
"scripts": {
"start": "gulp start"
"private": true,
"scripts": {
"start": "gulp start"
diff --git
a/public/images/pieces/new/Chess_Alt26.svg
b/public/images/pieces/_originals/Chess_Alt26.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_Alt26.svg
rename to
public/images/pieces/_originals/Chess_Alt26.svg
diff --git
a/public/images/pieces/new/Chess_Gdt45.svg
b/public/images/pieces/_originals/Chess_Gdt45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_Gdt45.svg
rename to
public/images/pieces/_originals/Chess_Gdt45.svg
diff --git
a/public/images/pieces/new/Chess_Gll45.svg
b/public/images/pieces/_originals/Chess_Gll45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_Gll45.svg
rename to
public/images/pieces/_originals/Chess_Gll45.svg
diff --git
a/public/images/pieces/new/Chess_Ult45.svg
b/public/images/pieces/_originals/Chess_Ult45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_Ult45.svg
rename to
public/images/pieces/_originals/Chess_Ult45.svg
diff --git
a/public/images/pieces/new/Chess_Zdl45.svg
b/public/images/pieces/_originals/Chess_Zdl45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_Zdl45.svg
rename to
public/images/pieces/_originals/Chess_Zdl45.svg
diff --git
a/public/images/pieces/new/Chess_Zll45.svg
b/public/images/pieces/_originals/Chess_Zll45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_Zll45.svg
rename to
public/images/pieces/_originals/Chess_Zll45.svg
diff --git
a/public/images/pieces/new/Chess_adt45.svg
b/public/images/pieces/_originals/Chess_adt45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_adt45.svg
rename to
public/images/pieces/_originals/Chess_adt45.svg
diff --git
a/public/images/pieces/new/Chess_alt45.svg
b/public/images/pieces/_originals/Chess_alt45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_alt45.svg
rename to
public/images/pieces/_originals/Chess_alt45.svg
diff --git
a/public/images/pieces/new/Chess_clt45.svg
b/public/images/pieces/_originals/Chess_clt45.svg
similarity index 100%
rename from
public/images/pieces/new/Chess_clt45.svg
rename to
public/images/pieces/_originals/Chess_clt45.svg
diff --git
a/public/images/pieces/new/camel-animal-pet-desert-39f82768c72363eb.svg
b/public/images/pieces/_originals/camel-animal-pet-desert-39f82768c72363eb.svg
similarity index 100%
rename from
public/images/pieces/new/camel-animal-pet-desert-39f82768c72363eb.svg
rename to
public/images/pieces/_originals/camel-animal-pet-desert-39f82768c72363eb.svg
diff --git
a/public/images/pieces/new/camel-animal-pet-desert-3f04e77f40eba40d.svg
b/public/images/pieces/_originals/camel-animal-pet-desert-3f04e77f40eba40d.svg
similarity index 100%
rename from
public/images/pieces/new/camel-animal-pet-desert-3f04e77f40eba40d.svg
rename to
public/images/pieces/_originals/camel-animal-pet-desert-3f04e77f40eba40d.svg
diff --git
a/public/images/pieces/new/camel-animal-wildlife-34b2662eb81cfec3.svg
b/public/images/pieces/_originals/camel-animal-wildlife-34b2662eb81cfec3.svg
similarity index 100%
rename from
public/images/pieces/new/camel-animal-wildlife-34b2662eb81cfec3.svg
rename to
public/images/pieces/_originals/camel-animal-wildlife-34b2662eb81cfec3.svg
diff --git
a/public/images/pieces/new/camel-animal-wildlife-3b15afb5e788b9ec.svg
b/public/images/pieces/_originals/camel-animal-wildlife-3b15afb5e788b9ec.svg
similarity index 100%
rename from
public/images/pieces/new/camel-animal-wildlife-3b15afb5e788b9ec.svg
rename to
public/images/pieces/_originals/camel-animal-wildlife-3b15afb5e788b9ec.svg
diff --git
a/public/images/pieces/new/unicorn-myth-legend-halloween-fantasy-37ec614cb63bc127.svg
b/public/images/pieces/_originals/unicorn-myth-legend-halloween-fantasy-37ec614cb63bc127.svg
similarity index 100%
rename from
public/images/pieces/new/unicorn-myth-legend-halloween-fantasy-37ec614cb63bc127.svg
rename to
public/images/pieces/_originals/unicorn-myth-legend-halloween-fantasy-37ec614cb63bc127.svg
diff --git
a/public/images/pieces/new/wildebeest-animal-wild-wildlife-face-326845431b848a31.svg
b/public/images/pieces/_originals/wildebeest-animal-wild-wildlife-face-326845431b848a31.svg
similarity index 100%
rename from
public/images/pieces/new/wildebeest-animal-wild-wildlife-face-326845431b848a31.svg
rename to
public/images/pieces/_originals/wildebeest-animal-wild-wildlife-face-326845431b848a31.svg
diff --git
a/public/images/pieces/new/wildebeest-animal-wildlife-31b7b8fe2ffee150.svg
b/public/images/pieces/_originals/wildebeest-animal-wildlife-31b7b8fe2ffee150.svg
similarity index 100%
rename from
public/images/pieces/new/wildebeest-animal-wildlife-31b7b8fe2ffee150.svg
rename to
public/images/pieces/_originals/wildebeest-animal-wildlife-31b7b8fe2ffee150.svg
diff --git
a/public/javascripts/base_rules.js
b/public/javascripts/base_rules.js
index
6bc3591
..
79b6a7a
100644
(file)
--- a/
public/javascripts/base_rules.js
+++ b/
public/javascripts/base_rules.js
@@
-124,7
+124,7
@@
class ChessRules
return board;
}
return board;
}
- //
Overridable: flags can change a lot
+ //
Extract (relevant) flags from fen
setFlags(fen)
{
// white a-castle, h-castle, black a-castle, h-castle
setFlags(fen)
{
// white a-castle, h-castle, black a-castle, h-castle
@@
-137,7
+137,6
@@
class ChessRules
///////////////////
// GETTERS, SETTERS
///////////////////
// GETTERS, SETTERS
- // Simple useful getters
static get size() { return [8,8]; }
// Two next functions return 'undefined' if called on empty square
getColor(i,j) { return this.board[i][j].charAt(0); }
static get size() { return [8,8]; }
// Two next functions return 'undefined' if called on empty square
getColor(i,j) { return this.board[i][j].charAt(0); }
@@
-199,7
+198,7
@@
class ChessRules
return undefined; //default
}
return undefined; //default
}
- //
c
an thing on square1 take thing on square2
+ //
C
an thing on square1 take thing on square2
canTake([x1,y1], [x2,y2])
{
return this.getColor(x1,y1) != this.getColor(x2,y2);
canTake([x1,y1], [x2,y2])
{
return this.getColor(x1,y1) != this.getColor(x2,y2);
@@
-291,7
+290,7
@@
class ChessRules
return moves;
}
return moves;
}
- // What are the pawn moves from square x,y
considering color "color"
?
+ // What are the pawn moves from square x,y ?
getPotentialPawnMoves([x,y])
{
const color = this.turn;
getPotentialPawnMoves([x,y])
{
const color = this.turn;
@@
-546,7
+545,7
@@
class ChessRules
return false;
}
return false;
}
- // Check if pieces of color 'colors' are attacking square x,y
+ // Check if pieces of color
in array
'colors' are attacking square x,y
isAttacked(sq, colors)
{
return (this.isAttackedByPawn(sq, colors)
isAttacked(sq, colors)
{
return (this.isAttackedByPawn(sq, colors)
@@
-557,7
+556,7
@@
class ChessRules
|| this.isAttackedByKing(sq, colors));
}
|| this.isAttackedByKing(sq, colors));
}
- // Is square x,y attacked by
pawns of color c
?
+ // Is square x,y attacked by
'colors' pawns
?
isAttackedByPawn([x,y], colors)
{
const [sizeX,sizeY] = VariantRules.size;
isAttackedByPawn([x,y], colors)
{
const [sizeX,sizeY] = VariantRules.size;
@@
-579,28
+578,28
@@
class ChessRules
return false;
}
return false;
}
- // Is square x,y attacked by
rooks of color c
?
+ // Is square x,y attacked by
'colors' rooks
?
isAttackedByRook(sq, colors)
{
return this.isAttackedBySlideNJump(sq, colors,
VariantRules.ROOK, VariantRules.steps[VariantRules.ROOK]);
}
isAttackedByRook(sq, colors)
{
return this.isAttackedBySlideNJump(sq, colors,
VariantRules.ROOK, VariantRules.steps[VariantRules.ROOK]);
}
- // Is square x,y attacked by
knights of color c
?
+ // Is square x,y attacked by
'colors' knights
?
isAttackedByKnight(sq, colors)
{
return this.isAttackedBySlideNJump(sq, colors,
VariantRules.KNIGHT, VariantRules.steps[VariantRules.KNIGHT], "oneStep");
}
isAttackedByKnight(sq, colors)
{
return this.isAttackedBySlideNJump(sq, colors,
VariantRules.KNIGHT, VariantRules.steps[VariantRules.KNIGHT], "oneStep");
}
- // Is square x,y attacked by
bishops of color c
?
+ // Is square x,y attacked by
'colors' bishops
?
isAttackedByBishop(sq, colors)
{
return this.isAttackedBySlideNJump(sq, colors,
VariantRules.BISHOP, VariantRules.steps[VariantRules.BISHOP]);
}
isAttackedByBishop(sq, colors)
{
return this.isAttackedBySlideNJump(sq, colors,
VariantRules.BISHOP, VariantRules.steps[VariantRules.BISHOP]);
}
- // Is square x,y attacked by
queens of color c
?
+ // Is square x,y attacked by
'colors' queens
?
isAttackedByQueen(sq, colors)
{
const V = VariantRules;
isAttackedByQueen(sq, colors)
{
const V = VariantRules;
@@
-608,7
+607,7
@@
class ChessRules
V.steps[V.ROOK].concat(V.steps[V.BISHOP]));
}
V.steps[V.ROOK].concat(V.steps[V.BISHOP]));
}
- // Is square x,y attacked by
king of color c
?
+ // Is square x,y attacked by
'colors' king(s)
?
isAttackedByKing(sq, colors)
{
const V = VariantRules;
isAttackedByKing(sq, colors)
{
const V = VariantRules;
@@
-617,7
+616,7
@@
class ChessRules
}
// Generic method for non-pawn pieces ("sliding or jumping"):
}
// Generic method for non-pawn pieces ("sliding or jumping"):
- // is x,y attacked by
piece !of color in colors
?
+ // is x,y attacked by
a piece of color in array 'colors'
?
isAttackedBySlideNJump([x,y], colors, piece, steps, oneStep)
{
const [sizeX,sizeY] = VariantRules.size;
isAttackedBySlideNJump([x,y], colors, piece, steps, oneStep)
{
const [sizeX,sizeY] = VariantRules.size;
@@
-640,7
+639,7
@@
class ChessRules
return false;
}
return false;
}
- // Is c
olor c under check after
move ?
+ // Is c
urrent player under check after his
move ?
underCheck(move)
{
const color = this.turn;
underCheck(move)
{
const color = this.turn;
@@
-650,7
+649,7
@@
class ChessRules
return res;
}
return res;
}
- // On which squares is
color c under check (after move)
?
+ // On which squares is
opponent under check after our move
?
getCheckSquares(move)
{
this.play(move);
getCheckSquares(move)
{
this.play(move);
@@
-711,6
+710,8
@@
class ChessRules
}
}
}
}
+ // After move is undo-ed, un-update variables (flags are reset)
+ // TODO: more symmetry, by storing flags increment in move...
unupdateVariables(move)
{
// (Potentially) Reset king position
unupdateVariables(move)
{
// (Potentially) Reset king position
@@
-721,12
+722,6
@@
class ChessRules
play(move, ingame)
{
play(move, ingame)
{
- // DEBUG:
-// if (!this.states) this.states = [];
-// if (!ingame) this.states.push(JSON.stringify(this.board));
-// if (!this.rstates) this.rstates = [];
-// if (!ingame) this.rstates.push(JSON.stringify(this.promoted)+"-"+JSON.stringify(this.reserve));
-
if (!!ingame)
move.notation = [this.getNotation(move), this.getLongNotation(move)];
if (!!ingame)
move.notation = [this.getNotation(move), this.getLongNotation(move)];
@@
-744,23
+739,16
@@
class ChessRules
this.moves.pop();
this.unupdateVariables(move);
this.parseFlags(JSON.parse(move.flags));
this.moves.pop();
this.unupdateVariables(move);
this.parseFlags(JSON.parse(move.flags));
-
- // DEBUG:
-// let state = this.states.pop();
-// let rstate = this.rstates.pop();
-// if (JSON.stringify(this.board) != state || JSON.stringify(this.promoted)+"-"+JSON.stringify(this.reserve) != rstate)
-// debugger;
}
//////////////
// END OF GAME
}
//////////////
// END OF GAME
+ // Basic check for 3 repetitions (in the last moves only)
checkRepetition()
{
checkRepetition()
{
- // Check for 3 repetitions
if (this.moves.length >= 8)
{
if (this.moves.length >= 8)
{
- // NOTE: crude detection, only moves repetition
const L = this.moves.length;
if (_.isEqual(this.moves[L-1], this.moves[L-5]) &&
_.isEqual(this.moves[L-2], this.moves[L-6]) &&
const L = this.moves.length;
if (_.isEqual(this.moves[L-1], this.moves[L-5]) &&
_.isEqual(this.moves[L-2], this.moves[L-6]) &&
@@
-773,6
+761,7
@@
class ChessRules
return false;
}
return false;
}
+ // Is game over ? And if yes, what is the score ?
checkGameOver()
{
if (this.checkRepetition())
checkGameOver()
{
if (this.checkRepetition())
@@
-900,6
+889,7
@@
class ChessRules
return moves1[_.sample(candidates, 1)];
}
return moves1[_.sample(candidates, 1)];
}
+ // TODO: some optimisations, understand why CH get mated in 2
alphabeta(depth, alpha, beta)
{
const maxeval = VariantRules.INFINITY;
alphabeta(depth, alpha, beta)
{
const maxeval = VariantRules.INFINITY;
@@
-965,7
+955,7
@@
class ChessRules
////////////
// FEN utils
////////////
// FEN utils
- //
Overridable..
+ //
Setup the initial random (assymetric) position
static GenRandInitFen()
{
let pieces = [new Array(8), new Array(8)];
static GenRandInitFen()
{
let pieces = [new Array(8), new Array(8)];
@@
-1025,6
+1015,7
@@
class ChessRules
return this.getBaseFen() + " " + this.getFlagsFen();
}
return this.getBaseFen() + " " + this.getFlagsFen();
}
+ // Position part of the FEN string
getBaseFen()
{
let fen = "";
getBaseFen()
{
let fen = "";
@@
-1058,7
+1049,7
@@
class ChessRules
return fen;
}
return fen;
}
- //
Overridable..
+ //
Flags part of the FEN string
getFlagsFen()
{
let fen = "";
getFlagsFen()
{
let fen = "";
diff --git
a/public/javascripts/components/game.js
b/public/javascripts/components/game.js
index
04185a7
..
72b5da9
100644
(file)
--- a/
public/javascripts/components/game.js
+++ b/
public/javascripts/components/game.js
@@
-432,7
+432,7
@@
Vue.component('my-game', {
"col-lg-6":true,
"col-lg-offset-3":true,
},
"col-lg-6":true,
"col-lg-offset-3":true,
},
- // NOTE: click = mousedown + mouseup
--> what about smartphone?!
+ // NOTE: click = mousedown + mouseup
on: {
mousedown: this.mousedown,
mousemove: this.mousemove,
on: {
mousedown: this.mousedown,
mousemove: this.mousemove,