From: Benjamin Auder Date: Thu, 2 Apr 2020 01:09:18 +0000 (+0200) Subject: Fix Interweave, remove unused Dynamo images X-Git-Url: https://git.auder.net/variants/current/doc/css/assets/pieces/cb.svg?a=commitdiff_plain;h=7ddfec38b0804bf0bd0c5b5c6972d355902e9fb0;p=vchess.git Fix Interweave, remove unused Dynamo images --- diff --git a/client/public/images/pieces/Dynamo/empty.svg b/client/public/images/pieces/Dynamo/empty.svg deleted file mode 100644 index 08ec9068..00000000 --- a/client/public/images/pieces/Dynamo/empty.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/client/public/images/pieces/Dynamo/pstep.svg b/client/public/images/pieces/Dynamo/pstep.svg deleted file mode 100644 index 17b0440a..00000000 --- a/client/public/images/pieces/Dynamo/pstep.svg +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - -   - P - - diff --git a/client/public/images/pieces/Dynamo/raus.svg b/client/public/images/pieces/Dynamo/raus.svg deleted file mode 100644 index 1d831147..00000000 --- a/client/public/images/pieces/Dynamo/raus.svg +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - -   - R - - diff --git a/client/public/images/pieces/Dynamo/shift_1.svg b/client/public/images/pieces/Dynamo/shift_1.svg deleted file mode 100644 index 3bcd08bd..00000000 --- a/client/public/images/pieces/Dynamo/shift_1.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/Dynamo/shift_2.svg b/client/public/images/pieces/Dynamo/shift_2.svg deleted file mode 100644 index 4f7eeb51..00000000 --- a/client/public/images/pieces/Dynamo/shift_2.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/Dynamo/shift_3.svg b/client/public/images/pieces/Dynamo/shift_3.svg deleted file mode 100644 index 50b2d025..00000000 --- a/client/public/images/pieces/Dynamo/shift_3.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/Dynamo/shift_4.svg b/client/public/images/pieces/Dynamo/shift_4.svg deleted file mode 100644 index 96557131..00000000 --- a/client/public/images/pieces/Dynamo/shift_4.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/Dynamo/shift_5.svg b/client/public/images/pieces/Dynamo/shift_5.svg deleted file mode 100644 index b2237d73..00000000 --- a/client/public/images/pieces/Dynamo/shift_5.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/Dynamo/shift_6.svg b/client/public/images/pieces/Dynamo/shift_6.svg deleted file mode 100644 index 4897edc3..00000000 --- a/client/public/images/pieces/Dynamo/shift_6.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/Dynamo/shift_7.svg b/client/public/images/pieces/Dynamo/shift_7.svg deleted file mode 100644 index 59970898..00000000 --- a/client/public/images/pieces/Dynamo/shift_7.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/client/public/images/pieces/SOURCE b/client/public/images/pieces/SOURCE index 0417e945..dca099c7 100644 --- a/client/public/images/pieces/SOURCE +++ b/client/public/images/pieces/SOURCE @@ -5,8 +5,5 @@ Some fairy pieces found on the web and icon scout: https://iconscout.com/ PNG images for Eightpieces from https://greenchess.net/index.php and Jeff Kubach design. Images of the Hawk and Elephant were designed by "Couch Tomato #2218" on Discord, for the pychess-variants website (http://pychess-variants.herokuapp.com/) -He also designed all the Horde pieces in Orda. -For Dynamo: -https://commons.wikimedia.org/wiki/File:Font_P.svg -https://commons.wikimedia.org/wiki/File:Font_R.svg -https://svgsilh.com/image/3203304.html +He also designed all the Horde pieces in Orda, and sent me the wizard and +champion SVG files as well (modified from Wikipedia) diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index ddfe1e7e..dd15f133 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -409,6 +409,8 @@ export default { smove.unambiguous = V.GetUnambiguousNotation(smove); this.vr.play(smove); this.lastMove = smove; + // Is opponent (or me) in check? + this.incheck = this.vr.getCheckSquares(this.vr.turn); if (!this.inMultimove) { // Condition is "!navigate" but we mean "!this.autoplay" if (!navigate) { @@ -470,8 +472,6 @@ export default { if (!smove.fen) // NOTE: only FEN of last sub-move is required (=> setting it here) smove.fen = this.vr.getFen(); - // Is opponent in check? - this.incheck = this.vr.getCheckSquares(this.vr.turn); this.emitFenIfAnalyze(); this.inMultimove = false; this.score = computeScore(); diff --git a/client/src/variants/Checkless.js b/client/src/variants/Checkless.js index 88612143..b304a483 100644 --- a/client/src/variants/Checkless.js +++ b/client/src/variants/Checkless.js @@ -41,4 +41,8 @@ export class ChecklessRules extends ChessRules { return res; }); } + + static get SEARCH_DEPTH() { + return 2; + } }; diff --git a/client/src/variants/Dynamo.js b/client/src/variants/Dynamo.js index 9d47fd8f..f2a22c8f 100644 --- a/client/src/variants/Dynamo.js +++ b/client/src/variants/Dynamo.js @@ -1,7 +1,7 @@ import { ChessRules, Move, PiPo } from "@/base_rules"; export class DynamoRules extends ChessRules { - // TODO: later, allow to push out pawns on a and h files? + // TODO: later, allow to push out pawns on a and h files static get HasEnpassant() { return false; } @@ -17,7 +17,7 @@ export class DynamoRules extends ChessRules { // Local stack of "action moves" this.amoves = []; const amove = V.ParseFen(fen).amove; - if (cmove == "-") this.amoves.push(null); + if (amove == "-") this.amoves.push(null); else { const amoveParts = amove.split("/"); let amove = { @@ -59,21 +59,22 @@ export class DynamoRules extends ChessRules { return true; } - getAmove(move) { + // TODO: local stack of "last moves" to know move1 + getAmove(move1, move2) { + // TODO: merge (one is action one is move) if (move.appear.length == 2 && move.vanish.length == 2) return { appear: move.appear, vanish: move.vanish }; return null; } - // TODO: this.firstMove + rooks location in setOtherVariables - // only rooks location in FEN (firstMove is forgotten if quit game and come back) doClick(square) { // If subTurn == 2 && square is the final square of last move, // then return an empty move + const L = this.lastMoves.length; if ( this.subTurn == 2 && - square.x == this.firstMove.end.x && - square.y == this.firstMove.end.y + square.x == this.lastMoves[L-1].end.x && + square.y == this.lastMoves[L-1].end.y ) { return { appear: [], @@ -88,6 +89,10 @@ export class DynamoRules extends ChessRules { return false; } + // TODO: re-think these next 3 methods: + // Idea = have the info about lastMove in lastMoves[L-1], + // In particular if moving a piece or doing an action. + // "pa" : piece (as a square) doing this push/pull action getActionMoves([sx, sy], [ex, ey], pa) { const color = this.getColor(sx, sy); @@ -181,6 +186,8 @@ export class DynamoRules extends ChessRules { // (doing the action, moving or not) // TODO: for pushes, play the pushed piece first. // for pulls: play the piece doing the action first + // If castle, then no options available next (just re-click) + getPotentialMovesFrom([x, y]) { const color = this.turn; if (this.getColor(x, y) != color) @@ -209,15 +216,12 @@ export class DynamoRules extends ChessRules { return res; }) ); - } - - // TODO: track rooks locations, should be a field in FEN, in castleflags? - // --> only useful if castleFlags is still ON - getCastleMoves(sq) { - // TODO: if rook1 isn't at its place (with castleFlags ON), set it off - // same for rook2. - let moves = super.getCastleMoves(sq); - // TODO: restore castleFlags + // Check opposite moves here --> we have lastMoves[L-1], + // which is completed (merged) with current played move if subTurn == 2 +// return moves.filter(m => { +// const L = this.amoves.length; //at least 1: init from FEN +// return !this.oppositeMoves(this.amoves[L - 1], m); +// }); } // Does m2 un-do m1 ? (to disallow undoing actions) @@ -248,13 +252,13 @@ export class DynamoRules extends ChessRules { ); } + // TODO: + // Si on se met en échec au coup 1, peut-on le contrer au coup 2 ? (cf. take n make) filterValid(moves) { - if (moves.length == 0) return []; - const color = this.turn; - return moves.filter(m => { - const L = this.amoves.length; //at least 1: init from FEN - return !this.oppositeMoves(this.amoves[L - 1], m); - }); + if (this.subTurn == 1) + // Validity of subTurn 1 should be checked in getPotentialMoves... + return moves; + return super.filterMoves(moves); } isAttackedBySlideNJump([x, y], color, piece, steps, oneStep) { @@ -316,46 +320,35 @@ export class DynamoRules extends ChessRules { play(move) { move.flags = JSON.stringify(this.aggregateFlags()); V.PlayOnBoard(this.board, move); - if (this.subTurn == 1) { - // TODO: is there a second move possible? - // (if the first move is a normal one, there may be no actions available) - // --> If not, just change turn as ion the else {} section - this.subTurn = 2; - this.movesCount++; - } else { - // subTurn == 2 + if (this.subTurn == 2) { this.turn = V.GetOppCol(this.turn); - this.subTurn = 1; + this.movesCount++; } + this.subTurn = 3 - this.subTurn; this.postPlay(move); } updateCastleFlags(move, piece) { const c = V.GetOppCol(this.turn); const firstRank = (c == "w" ? V.size.x - 1 : 0); - // Update castling flags if rooks are moved (only) - if (piece == V.KING && move.appear.length > 0) - this.castleFlags[c] = [V.size.y, V.size.y]; - else if ( - move.start.x == firstRank && - this.castleFlags[c].includes(move.start.y) - ) { - const flagIdx = (move.start.y == this.castleFlags[c][0] ? 0 : 1); - this.castleFlags[c][flagIdx] = V.size.y; + // Update castling flags + if (piece == V.KING) this.castleFlags[c] = [V.size.y, V.size.y]; + for (let v of move.vanish) { + if (v.x == firstRank && this.castleFlags[c].includes(v.y)) { + const flagIdx = (v.y == this.castleFlags[c][0] ? 0 : 1); + this.castleFlags[c][flagIdx] = V.size.y; + } } } undo(move) { this.disaggregateFlags(JSON.parse(move.flags)); V.UndoOnBoard(this.board, move); - if (this.subTurn == 2) { - this.subTurn = 1; - this.movesCount--; - } else { - // subTurn == 1 (after a move played) + if (this.subTurn == 1) { this.turn = V.GetOppCol(this.turn); - this.subTurn = 2; + this.movesCount--; } + this.subTurn = 3 - this.subTurn; this.postUndo(move); } }; diff --git a/client/src/variants/Interweave.js b/client/src/variants/Interweave.js index c776889f..8e0c3cc6 100644 --- a/client/src/variants/Interweave.js +++ b/client/src/variants/Interweave.js @@ -195,56 +195,21 @@ export class InterweaveRules extends ChessRules { ); } - getPotentialMovesFrom([x, y], noPostprocess) { - const L = this.lastMoveEnd.length; - if ( - !!this.lastMoveEnd[L-1] && - ( - x != this.lastMoveEnd[L-1].x || - y != this.lastMoveEnd[L-1].y - ) - ) { - // A capture must continue: wrong square - return []; - } - let moves = []; + getPotentialMovesFrom([x, y]) { switch (this.getPiece(x, y)) { case V.PAWN: - moves = this.getPotentialPawnMoves([x, y]); - break; + return this.getPotentialPawnMoves([x, y]); case V.ROOK: - moves = this.getPotentialRookMoves([x, y]); - break; + return this.getPotentialRookMoves([x, y]); case V.KNIGHT: - moves = this.getPotentialKnightMoves([x, y]); - break; + return this.getPotentialKnightMoves([x, y]); case V.BISHOP: - moves = this.getPotentialBishopMoves([x, y]); - break; + return this.getPotentialBishopMoves([x, y]); case V.KING: - moves = this.getPotentialKingMoves([x, y]); - break; + return this.getPotentialKingMoves([x, y]); // No queens } - if (!noPostprocess) { - // Post-process: if capture, - // can another capture be achieved with the same piece? - moves.forEach(m => { - if (m.vanish.length >= 2 || m.appear.length == 0) { - this.play(m); - const moreCaptures = ( - V.KeepCaptures( - this.getPotentialMovesFrom([m.end.x, m.end.y], "noPostprocess") - ) - .length > 0 - ); - this.undo(m); - if (!moreCaptures) m.last = true; - } - else m.last = true; - }); - } - return moves; + return []; } // Special pawns movements @@ -590,11 +555,23 @@ export class InterweaveRules extends ChessRules { for (let i=1; i= 2 || move.appear.length == 0) { + const moreCaptures = ( + V.KeepCaptures( + this.getPotentialMovesFrom([move.end.x, move.end.y]) + ) + .length > 0 + ); + move.last = !moreCaptures; + } + else move.last = true; if (!!move.last) { // No capture, or no more capture available this.turn = V.GetOppCol(this.turn); this.movesCount++; this.lastMoveEnd.push(null); + move.last = true; //will be used in undo and computer play } else this.lastMoveEnd.push(move.end); } @@ -639,14 +616,14 @@ export class InterweaveRules extends ChessRules { while (moves.length > 0) { const mv = moves[randInt(moves.length)]; mvArray.push(mv); + this.play(mv); if (!mv.last) { - this.play(mv); moves = V.KeepCaptures( this.getPotentialMovesFrom([mv.end.x, mv.end.y])); } else break; } - for (let i = mvArray.length - 2; i >= 0; i--) this.undo(mvArray[i]); + for (let i = mvArray.length - 1; i >= 0; i--) this.undo(mvArray[i]); return (mvArray.length > 1 ? mvArray : mvArray[0]); }