projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix squares colors on diagrams
[vchess.git]
/
client
/
src
/
variants
/
Synochess.js
diff --git
a/client/src/variants/Synochess.js
b/client/src/variants/Synochess.js
index
5291522
..
74eecac
100644
(file)
--- a/
client/src/variants/Synochess.js
+++ b/
client/src/variants/Synochess.js
@@
-2,6
+2,18
@@
import { ChessRules, Move, PiPo } from "@/base_rules";
export class SynochessRules extends ChessRules {
export class SynochessRules extends ChessRules {
+ static get Options() {
+ return {
+ check: [
+ {
+ label: "Random",
+ defaut: false,
+ variable: "random"
+ }
+ ]
+ };
+ }
+
static get LoseOnRepetition() {
return true;
}
static get LoseOnRepetition() {
return true;
}
@@
-28,8
+40,8
@@
export class SynochessRules extends ChessRules {
);
}
);
}
- static GenRandInitFen(
randomnes
s) {
- if (
randomness == 0
)
+ static GenRandInitFen(
option
s) {
+ if (
!options.random
)
return "rneakenr/8/1c4c1/1ss2ss1/8/8/PPPPPPPP/RNBQKBNR w 0 ah - 2";
// Mapping kingdom --> dynasty:
return "rneakenr/8/1c4c1/1ss2ss1/8/8/PPPPPPPP/RNBQKBNR w 0 ah - 2";
// Mapping kingdom --> dynasty:
@@
-42,7
+54,7
@@
export class SynochessRules extends ChessRules {
};
// Always symmetric (randomness = 1), because open files.
};
// Always symmetric (randomness = 1), because open files.
- const baseFen = ChessRules.GenRandInitFen(
1
);
+ const baseFen = ChessRules.GenRandInitFen(
{ randomness: 1 }
);
return (
baseFen.substr(0, 8).split("").map(p => piecesMap[p]).join("") +
"/8/1c4c1/1ss2ss1/" + baseFen.substr(22, 28) + " - 2"
return (
baseFen.substr(0, 8).split("").map(p => piecesMap[p]).join("") +
"/8/1c4c1/1ss2ss1/" + baseFen.substr(22, 28) + " - 2"
@@
-256,9
+268,6
@@
export class SynochessRules extends ChessRules {
// or if move.end.x == enemy king rank.
const color = this.getColor(sq[0], sq[1]);
const oppCol = V.GetOppCol(color);
// or if move.end.x == enemy king rank.
const color = this.getColor(sq[0], sq[1]);
const oppCol = V.GetOppCol(color);
- // check == -1 if (row, or col) unchecked, 1 if checked and occupied,
- // 0 if checked and clear
- let check = [-1, -1];
return moves.filter(m => {
if (
m.end.y != this.kingPos[oppCol][1] &&
return moves.filter(m => {
if (
m.end.y != this.kingPos[oppCol][1] &&
@@
-266,13
+275,15
@@
export class SynochessRules extends ChessRules {
) {
return true;
}
) {
return true;
}
+ // check == -1 if (row, or col) unchecked, 1 if checked and occupied,
+ // 0 if checked and clear
+ let check = [-1, -1];
// TODO: factor two next "if"...
if (m.end.x == this.kingPos[oppCol][0]) {
if (check[0] < 0) {
// Do the check:
check[0] = 0;
// TODO: factor two next "if"...
if (m.end.x == this.kingPos[oppCol][0]) {
if (check[0] < 0) {
// Do the check:
check[0] = 0;
- let [kingPos1, kingPos2] =
- [this.kingPos[color][1], this.kingPos[oppCol][1]];
+ let [kingPos1, kingPos2] = [m.end.y, this.kingPos[oppCol][1]];
if (kingPos1 > kingPos2) [kingPos1, kingPos2] = [kingPos2, kingPos1];
for (let i = kingPos1 + 1; i < kingPos2; i++) {
if (this.board[m.end.x][i] != V.EMPTY) {
if (kingPos1 > kingPos2) [kingPos1, kingPos2] = [kingPos2, kingPos1];
for (let i = kingPos1 + 1; i < kingPos2; i++) {
if (this.board[m.end.x][i] != V.EMPTY) {
@@
-289,8
+300,7
@@
export class SynochessRules extends ChessRules {
if (check[1] < 0) {
// Do the check:
check[1] = 0;
if (check[1] < 0) {
// Do the check:
check[1] = 0;
- let [kingPos1, kingPos2] =
- [this.kingPos[color][0], this.kingPos[oppCol][0]];
+ let [kingPos1, kingPos2] = [m.end.x, this.kingPos[oppCol][0]];
if (kingPos1 > kingPos2) [kingPos1, kingPos2] = [kingPos2, kingPos1];
for (let i = kingPos1 + 1; i < kingPos2; i++) {
if (this.board[i][m.end.y] != V.EMPTY) {
if (kingPos1 > kingPos2) [kingPos1, kingPos2] = [kingPos2, kingPos1];
for (let i = kingPos1 + 1; i < kingPos2; i++) {
if (this.board[i][m.end.y] != V.EMPTY) {
@@
-307,17
+317,14
@@
export class SynochessRules extends ChessRules {
getPotentialAdvisorMoves(sq) {
return super.getSlideNJumpMoves(
getPotentialAdvisorMoves(sq) {
return super.getSlideNJumpMoves(
- sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
"oneStep"
);
+ sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
1
);
}
getPotentialKingMoves([x, y]) {
if (this.getColor(x, y) == 'w') return super.getPotentialKingMoves([x, y]);
// Dynasty doesn't castle:
return super.getSlideNJumpMoves(
}
getPotentialKingMoves([x, y]) {
if (this.getColor(x, y) == 'w') return super.getPotentialKingMoves([x, y]);
// Dynasty doesn't castle:
return super.getSlideNJumpMoves(
- [x, y],
- V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
- "oneStep"
- );
+ [x, y], V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1);
}
getPotentialSoldierMoves([x, y]) {
}
getPotentialSoldierMoves([x, y]) {
@@
-328,11
+335,11
@@
export class SynochessRules extends ChessRules {
if (!lastRank) steps.push([shiftX, 0]);
if (y > 0) steps.push([0, -1]);
if (y < 9) steps.push([0, 1]);
if (!lastRank) steps.push([shiftX, 0]);
if (y > 0) steps.push([0, -1]);
if (y < 9) steps.push([0, 1]);
- return super.getSlideNJumpMoves([x, y], steps,
"oneStep"
);
+ return super.getSlideNJumpMoves([x, y], steps,
1
);
}
getPotentialElephantMoves([x, y]) {
}
getPotentialElephantMoves([x, y]) {
- return this.getSlideNJumpMoves([x, y], V.steps[V.ELEPHANT],
"oneStep"
);
+ return this.getSlideNJumpMoves([x, y], V.steps[V.ELEPHANT],
1
);
}
// NOTE: (mostly) duplicated from Shako (TODO?)
}
// NOTE: (mostly) duplicated from Shako (TODO?)
@@
-419,26
+426,19
@@
export class SynochessRules extends ChessRules {
}
isAttackedByAdvisor(sq, color) {
}
isAttackedByAdvisor(sq, color) {
- return (
- super.isAttackedBySlideNJump(
- sq, color, V.ADVISOR,
- V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"
- )
- );
+ return super.isAttackedBySlideNJump(
+ sq, color, V.ADVISOR, V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1);
}
isAttackedByElephant(sq, color) {
}
isAttackedByElephant(sq, color) {
- return (
- this.isAttackedBySlideNJump(
- sq, color, V.ELEPHANT, V.steps[V.ELEPHANT], "oneStep"
- )
- );
+ return this.isAttackedBySlideNJump(
+ sq, color, V.ELEPHANT, V.steps[V.ELEPHANT], 1);
}
isAttackedBySoldier([x, y], color) {
const shiftX = (color == 'w' ? 1 : -1); //shift from king
return super.isAttackedBySlideNJump(
}
isAttackedBySoldier([x, y], color) {
const shiftX = (color == 'w' ? 1 : -1); //shift from king
return super.isAttackedBySlideNJump(
- [x, y], color, V.SOLDIER, [[shiftX, 0], [0, 1], [0, -1]],
"oneStep"
);
+ [x, y], color, V.SOLDIER, [[shiftX, 0], [0, 1], [0, -1]],
1
);
}
getAllValidMoves() {
}
getAllValidMoves() {
@@
-527,7
+527,7
@@
export class SynochessRules extends ChessRules {
evalPosition() {
let evaluation = super.evalPosition();
evalPosition() {
let evaluation = super.evalPosition();
- if (this.turn == 'b')
+ if (this.turn == 'b'
&& !!this.reserve
)
// Add reserves:
evaluation += this.reserve['b'][V.SOLDIER] * V.VALUES[V.SOLDIER];
return evaluation;
// Add reserves:
evaluation += this.reserve['b'][V.SOLDIER] * V.VALUES[V.SOLDIER];
return evaluation;