From: Benjamin Auder Date: Fri, 22 Jan 2021 03:45:15 +0000 (+0100) Subject: Some fixes. Screen variant computer play is still broken, seemingly X-Git-Url: https://git.auder.net/doc/html/app_dev.php/pieces/mini-custom.min.css?a=commitdiff_plain;h=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;p=vchess.git Some fixes. Screen variant computer play is still broken, seemingly --- diff --git a/client/public/images/pieces/Musketeer/bs.svg b/client/public/images/pieces/Musketeer/bs.svg index bba410cc..97dc32d8 100644 --- a/client/public/images/pieces/Musketeer/bs.svg +++ b/client/public/images/pieces/Musketeer/bs.svg @@ -42,11 +42,12 @@ showgrid="false" inkscape:zoom="0.43115234" inkscape:cx="1024" - inkscape:cy="1021.6806" + inkscape:cy="1019.3612" inkscape:window-x="0" inkscape:window-y="20" inkscape:window-maximized="0" - inkscape:current-layer="svg12" /> + inkscape:current-layer="svg12" + inkscape:document-rotation="0" /> + inkscape:current-layer="svg16" + inkscape:document-rotation="0" /> + inkscape:current-layer="svg18" + inkscape:document-rotation="0" /> + + + + + + diff --git a/client/public/images/pieces/Musketeer/wj.svg b/client/public/images/pieces/Musketeer/wj.svg index 97e92bbf..a4e13ee1 100644 --- a/client/public/images/pieces/Musketeer/wj.svg +++ b/client/public/images/pieces/Musketeer/wj.svg @@ -42,11 +42,12 @@ showgrid="false" inkscape:zoom="0.43115234" inkscape:cx="1024" - inkscape:cy="1021.6806" + inkscape:cy="1019.3612" inkscape:window-x="0" inkscape:window-y="20" inkscape:window-maximized="0" - inkscape:current-layer="svg18" /> + inkscape:current-layer="svg18" + inkscape:document-rotation="0" /> + + + + + + diff --git a/client/public/images/pieces/Musketeer/wm.svg b/client/public/images/pieces/Musketeer/wm.svg index 7f087be0..a153b120 100644 --- a/client/public/images/pieces/Musketeer/wm.svg +++ b/client/public/images/pieces/Musketeer/wm.svg @@ -36,17 +36,18 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" + inkscape:window-width="960" inkscape:window-height="1060" id="namedview8" showgrid="false" inkscape:zoom="0.43115234" inkscape:cx="1024" - inkscape:cy="1021.6806" + inkscape:cy="1019.3612" inkscape:window-x="0" inkscape:window-y="20" inkscape:window-maximized="0" - inkscape:current-layer="svg6" /> + inkscape:current-layer="svg6" + inkscape:document-rotation="0" /> + diff --git a/client/public/images/pieces/Musketeer/ws.svg b/client/public/images/pieces/Musketeer/ws.svg index a2b8cdc4..7facb419 100644 --- a/client/public/images/pieces/Musketeer/ws.svg +++ b/client/public/images/pieces/Musketeer/ws.svg @@ -36,17 +36,18 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" + inkscape:window-width="960" inkscape:window-height="1060" id="namedview36" showgrid="false" inkscape:zoom="0.43115234" inkscape:cx="1024" - inkscape:cy="1021.6806" + inkscape:cy="1019.3612" inkscape:window-x="0" inkscape:window-y="20" inkscape:window-maximized="0" - inkscape:current-layer="svg34" /> + inkscape:current-layer="svg34" + inkscape:document-rotation="0" /> + + + + + + + + + + + + + + diff --git a/client/public/images/pieces/Musketeer/wu.svg b/client/public/images/pieces/Musketeer/wu.svg index feef69ce..5cab5e37 100644 --- a/client/public/images/pieces/Musketeer/wu.svg +++ b/client/public/images/pieces/Musketeer/wu.svg @@ -36,17 +36,18 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" + inkscape:window-width="960" inkscape:window-height="1060" id="namedview20" showgrid="false" inkscape:zoom="0.43115234" inkscape:cx="1024" - inkscape:cy="1021.6806" + inkscape:cy="1019.3612" inkscape:window-x="0" inkscape:window-y="20" inkscape:window-maximized="0" - inkscape:current-layer="svg18" /> + inkscape:current-layer="svg18" + inkscape:document-rotation="0" /> + + + + + + diff --git a/client/public/images/pieces/Shogun/bM.svg b/client/public/images/pieces/Shogun/bm.svg similarity index 100% rename from client/public/images/pieces/Shogun/bM.svg rename to client/public/images/pieces/Shogun/bm.svg diff --git a/client/src/translations/rules/Progressive2/en.pug b/client/src/translations/rules/Progressive2/en.pug index 1590c187..bd56f338 100644 --- a/client/src/translations/rules/Progressive2/en.pug +++ b/client/src/translations/rules/Progressive2/en.pug @@ -3,6 +3,6 @@ p.boxed | then white plays three moves... p - Same as + | Same as a(href="/#/variants/Progressive1") Progressive1 | , but without initial double-step pawn move, and without castling. diff --git a/client/src/translations/rules/Progressive2/es.pug b/client/src/translations/rules/Progressive2/es.pug index a3f70e97..76139456 100644 --- a/client/src/translations/rules/Progressive2/es.pug +++ b/client/src/translations/rules/Progressive2/es.pug @@ -3,6 +3,6 @@ p.boxed | entonces las blancas juegan tres movimientos... p - | Como + | Como a(href="/#/variants/Progressive1") Progressive1 | , pero sin el doble movimiento inicial de peón, y sin enroque. diff --git a/client/src/translations/rules/Progressive2/fr.pug b/client/src/translations/rules/Progressive2/fr.pug index 6b8248fe..0aff27db 100644 --- a/client/src/translations/rules/Progressive2/fr.pug +++ b/client/src/translations/rules/Progressive2/fr.pug @@ -3,6 +3,6 @@ p.boxed | ensuite les blancs jouent trois coups... p - Comme + | Comme a(href="/#/variants/Progressive1") Progressive1 | , mais sans le double coup initial de pion, et sans roque. diff --git a/client/src/variants/Alapo.js b/client/src/variants/Alapo.js index 6864457e..f525555a 100644 --- a/client/src/variants/Alapo.js +++ b/client/src/variants/Alapo.js @@ -221,4 +221,15 @@ export class AlapoRules extends ChessRules { return super.getCurrentScore(); } + static get VALUES() { + return { + r: 5, + b: 3, + q: 9, + t: 3, + c: 2, + s: 5 + }; + } + }; diff --git a/client/src/variants/Atomic1.js b/client/src/variants/Atomic1.js index c44c2cac..a5198d69 100644 --- a/client/src/variants/Atomic1.js +++ b/client/src/variants/Atomic1.js @@ -5,6 +5,17 @@ export class Atomic1Rules extends ChessRules { getPotentialMovesFrom([x, y]) { let moves = super.getPotentialMovesFrom([x, y]); + if (this.getPiece(x, y) == V.PAWN) { + // Promotions by captures can be reduced to only one deterministic + // move (because of the explosion). + moves = moves.filter(m => { + return ( + m.vanish.length == 1 || + [V.PAWN, V.QUEEN].includes(m.appear[0].p) + ); + }); + } + // Handle explosions moves.forEach(m => { // NOTE: if vanish.length==2 and appear.length==2, this is castle diff --git a/client/src/variants/Crazyhouse.js b/client/src/variants/Crazyhouse.js index 7fa47b72..2a95dc85 100644 --- a/client/src/variants/Crazyhouse.js +++ b/client/src/variants/Crazyhouse.js @@ -80,9 +80,9 @@ export class CrazyhouseRules extends ChessRules { setOtherVariables(fen) { super.setOtherVariables(fen); + const fenParsed = V.ParseFen(fen); // Also init reserves (used by the interface to show landable pieces) - const reserve = - V.ParseFen(fen).reserve.split("").map(x => parseInt(x, 10)); + const reserve = fenParsed.reserve.split("").map(x => parseInt(x, 10)); this.reserve = { w: { [V.PAWN]: reserve[0], diff --git a/client/src/variants/Fanorona.js b/client/src/variants/Fanorona.js index 39911635..4593e6bb 100644 --- a/client/src/variants/Fanorona.js +++ b/client/src/variants/Fanorona.js @@ -80,13 +80,14 @@ export class FanoronaRules extends ChessRules { return "Fanorona/" + b; } - getPPpath(m) { + getPPpath(m, orientation) { // m.vanish.length >= 2, first capture gives direction const ref = (Math.abs(m.vanish[1].x - m.start.x) == 1 ? m.start : m.end); const step = [m.vanish[1].x - ref.x, m.vanish[1].y - ref.y]; + const multStep = (orientation == 'w' ? 1 : -1); const normalizedStep = [ - step[0] / Math.abs(step[0]), - step[1] / Math.abs(step[1]) + multStep * step[0] / Math.abs(step[0]), + multStep * step[1] / Math.abs(step[1]) ]; return ( "Fanorona/arrow_" + diff --git a/client/src/variants/Hypnotic.js b/client/src/variants/Hypnotic.js index 130b1279..a429c7c4 100644 --- a/client/src/variants/Hypnotic.js +++ b/client/src/variants/Hypnotic.js @@ -74,6 +74,21 @@ export class HypnoticRules extends ChessRules { return moves; } + getAllPotentialMoves() { + let potentialMoves = []; + for (let i = 0; i < V.size.x; i++) { + for (let j = 0; j < V.size.y; j++) { + if (this.board[i][j] != V.EMPTY) { + Array.prototype.push.apply( + potentialMoves, + this.getPotentialMovesFrom([i, j]) + ); + } + } + } + return potentialMoves; + } + getEnpassantCaptures([x, y], shiftX) { const Lep = this.epSquares.length; const epSquare = this.epSquares[Lep - 1]; //always at least one element diff --git a/client/src/variants/Madhouse.js b/client/src/variants/Madhouse.js index 72c41cd8..1ed248d0 100644 --- a/client/src/variants/Madhouse.js +++ b/client/src/variants/Madhouse.js @@ -3,10 +3,13 @@ import { randInt } from "@/utils/alea"; export class MadhouseRules extends ChessRules { - hoverHighlight([x, y]) { + hoverHighlight([x, y], side) { // Testing move validity results in an infinite update loop. // TODO: find a way to test validity anyway. - return (this.subTurn == 2 && this.board[x][y] == V.EMPTY); + return ( + (this.subTurn == 2 && this.board[x][y] == V.EMPTY) && + (!side || side == this.turn) + ); } setOtherVariables(fen) { @@ -15,6 +18,12 @@ export class MadhouseRules extends ChessRules { this.firstMove = []; } + canIplay(side, [x, y]) { + if (this.subTurn == 1) return super.canIplay(side, [x, y]); + // subturn == 2, drop a piece: + return side == this.turn && this.board[x][y] == V.EMPTY; + } + getPotentialMovesFrom([x, y]) { if (this.subTurn == 1) return super.getPotentialMovesFrom([x, y]); // subTurn == 2: a move is a click, not handled here diff --git a/client/src/variants/Makruk.js b/client/src/variants/Makruk.js index c7dd3430..55617025 100644 --- a/client/src/variants/Makruk.js +++ b/client/src/variants/Makruk.js @@ -16,6 +16,10 @@ export class MakrukRules extends ChessRules { return true; } + static get Notoodark() { + return true; + } + static get PawnSpecs() { return Object.assign( {}, diff --git a/client/src/variants/Minixiangqi.js b/client/src/variants/Minixiangqi.js index f467e2dc..fc1d164e 100644 --- a/client/src/variants/Minixiangqi.js +++ b/client/src/variants/Minixiangqi.js @@ -67,8 +67,10 @@ export class MinixiangqiRules extends XiangqiRules { let evaluation = 0; for (let i = 0; i < V.size.x; i++) { for (let j = 0; j < V.size.y; j++) { - if (this.board[i][j] != V.EMPTY) - evaluation += (c == 'w' ? 1 : -1) * V.VALUES[this.getPiece(i, j)]; + if (this.board[i][j] != V.EMPTY) { + const sign = this.getColor(i, j) == "w" ? 1 : -1; + evaluation += sign * V.VALUES[this.getPiece(i, j)]; + } } } return evaluation; diff --git a/client/src/variants/Pawnmassacre.js b/client/src/variants/Pawnmassacre.js index 12ce1d04..1fe61cbe 100644 --- a/client/src/variants/Pawnmassacre.js +++ b/client/src/variants/Pawnmassacre.js @@ -6,6 +6,10 @@ export class PawnmassacreRules extends ChessRules { return false; } + get showFirstTurn() { + return true; + } + static GenRandInitFen(randomness) { const bFen = ChessRules.GenRandInitFen(randomness) diff --git a/client/src/variants/Recycle.js b/client/src/variants/Recycle.js index eb84044e..4afae21c 100644 --- a/client/src/variants/Recycle.js +++ b/client/src/variants/Recycle.js @@ -86,6 +86,14 @@ export class RecycleRules extends ChessRules { return this.board[i][j].charAt(1); } + getPPpath(m) { + if (m.vanish.length == 2 && m.appear.length == 2) { + // Castle: show castle symbol + return "Coregal/castle"; + } + return super.getPPpath(m); + } + // Used by the interface: getReservePpath(index, color) { return color + V.RESERVE_PIECES[index]; diff --git a/client/src/variants/Screen.js b/client/src/variants/Screen.js index 41334da0..7ccb5a5d 100644 --- a/client/src/variants/Screen.js +++ b/client/src/variants/Screen.js @@ -61,7 +61,7 @@ export class ScreenRules extends ChessRules { for (let i=0; i<4; i++) { for (let j=0; j<8; j++) this.enlightened['b'][i][j] = true; } - for (let i=5; i<8; i++) { + for (let i=4; i<8; i++) { for (let j=0; j<8; j++) this.enlightened['w'][i][j] = true; } } diff --git a/client/src/variants/Selfabsorb.js b/client/src/variants/Selfabsorb.js index 0a8a7473..a5d30b58 100644 --- a/client/src/variants/Selfabsorb.js +++ b/client/src/variants/Selfabsorb.js @@ -70,4 +70,8 @@ export class SelfabsorbRules extends AbsorptionRules { return moves; } + static get SEARCH_DEPTH() { + return 2; + } + }; diff --git a/client/src/variants/Shogi.js b/client/src/variants/Shogi.js index 63c0d726..9104ed92 100644 --- a/client/src/variants/Shogi.js +++ b/client/src/variants/Shogi.js @@ -16,6 +16,10 @@ export class ShogiRules extends ChessRules { return true; } + get showFirstTurn() { + return true; + } + static get Notoodark() { return true; } diff --git a/client/src/variants/Synochess.js b/client/src/variants/Synochess.js index 52915220..f8e9386b 100644 --- a/client/src/variants/Synochess.js +++ b/client/src/variants/Synochess.js @@ -527,7 +527,7 @@ export class SynochessRules extends ChessRules { 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; diff --git a/client/src/variants/Wormhole1.js b/client/src/variants/Wormhole1.js index 8219d28b..11901119 100644 --- a/client/src/variants/Wormhole1.js +++ b/client/src/variants/Wormhole1.js @@ -90,7 +90,7 @@ export class Wormhole1Rules extends Wormhole2Rules { return ( baseFen.substr(0, 8).split('').map(p => piecesMap[p]).join('') + baseFen.substr(8, 27) + - baseFen.substr(35, 43).split('') + baseFen.substr(35, 8).toLowerCase().split('') .map(p => piecesMap[p]).join('').toUpperCase() + " w 0" );