From ab2bc577ec2d70c2833e482af3bb27f4f94c3f99 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Wed, 12 Dec 2018 11:40:57 +0100 Subject: [PATCH] Drop Half chess: does not seem very interesting after all --- public/javascripts/variants/Half.js | 132 ---------------------------- variants.js | 1 - views/rules/Half.pug | 24 ----- 3 files changed, 157 deletions(-) delete mode 100644 public/javascripts/variants/Half.js delete mode 100644 views/rules/Half.pug diff --git a/public/javascripts/variants/Half.js b/public/javascripts/variants/Half.js deleted file mode 100644 index 6c6c7ebb..00000000 --- a/public/javascripts/variants/Half.js +++ /dev/null @@ -1,132 +0,0 @@ -// Standard rules on a 4x8 board with no pawns -class HalfRules extends ChessRules -{ - initVariables(fen) - { - this.kingPos = {'w':[-1,-1], 'b':[-1,-1]}; - const fenParts = fen.split(" "); - const position = fenParts[0].split("/"); - for (let i=0; i<position.length; i++) - { - let k = 0; - for (let j=0; j<position[i].length; j++) - { - switch (position[i].charAt(j)) - { - case 'k': - this.kingPos['b'] = [i,k]; - break; - case 'K': - this.kingPos['w'] = [i,k]; - break; - default: - let num = parseInt(position[i].charAt(j)); - if (!isNaN(num)) - k += (num-1); - } - k++; - } - } - // No pawns so no ep., but otherwise we must redefine play() - this.epSquares = []; - } - - setFlags(fen) - { - // No castling, hence no flags; but flags defined for compatibility - this.castleFlags = { "w":[false,false], "b":[false,false] }; - } - - static get size() { return [4,8]; } - - getPotentialKingMoves(sq) - { - const V = VariantRules; - // No castling - return this.getSlideNJumpMoves(sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep"); - } - - isAttacked(sq, colors) - { - return (this.isAttackedByRook(sq, colors) - || this.isAttackedByKnight(sq, colors) - || this.isAttackedByBishop(sq, colors) - || this.isAttackedByQueen(sq, colors) - || this.isAttackedByKing(sq, colors)); - } - - updateVariables(move) - { - // Just update king position - const piece = this.getPiece(move.start.x,move.start.y); - const c = this.getColor(move.start.x,move.start.y); - if (piece == VariantRules.KING) - { - this.kingPos[c][0] = move.appear[0].x; - this.kingPos[c][1] = move.appear[0].y; - } - } - - static GenRandInitFen() - { - let minorPieces = { "w": new Array(4), "b": new Array(4) }; - let majorPieces = { "w": new Array(4), "b": new Array(4) }; - for (let c of ["w","b"]) - { - // Minor pieces first (on 2nd rank) - let positions = _.range(4); - - // Get random squares for bishops - let randIndex = 2 * _.random(1); - let bishop1Pos = positions[randIndex]; - let randIndex_tmp = 2 * _.random(1) + 1; - let bishop2Pos = positions[randIndex_tmp]; - positions.splice(Math.max(randIndex,randIndex_tmp), 1); - positions.splice(Math.min(randIndex,randIndex_tmp), 1); - - // Get random squares for knights - randIndex = _.random(1); - let knight1Pos = positions[randIndex]; - positions.splice(randIndex, 1); - let knight2Pos = positions[0]; - - minorPieces[c][bishop1Pos] = 'b'; - minorPieces[c][bishop2Pos] = 'b'; - minorPieces[c][knight1Pos] = 'n'; - minorPieces[c][knight2Pos] = 'n'; - - // Major pieces then (on 1st rank) - positions = _.range(4); - - // Get random square for queen - randIndex = _.random(3); - let queenPos = positions[randIndex]; - positions.splice(randIndex, 1); - - // Random square for king (no castle) - randIndex = _.random(2); - let kingPos = positions[randIndex]; - positions.splice(randIndex, 1); - - // Rooks and king positions: - let rook1Pos = positions[0]; - let rook2Pos = positions[1]; - - majorPieces[c][rook1Pos] = 'r'; - majorPieces[c][rook2Pos] = 'r'; - majorPieces[c][kingPos] = 'k'; - majorPieces[c][queenPos] = 'q'; - } - let fen = ""; - for (let i=0; i<4; i++) - { - fen += majorPieces["b"][i] + minorPieces["b"][i] + "4" + - minorPieces["w"][i].toUpperCase() + majorPieces["w"][i].toUpperCase(); - if (i < 3) - fen += "/"; - } - fen += " 0000"; //TODO: flags?! - return fen; - } -} diff --git a/variants.js b/variants.js index 5623334e..2a20ffd9 100644 --- a/variants.js +++ b/variants.js @@ -13,5 +13,4 @@ module.exports = [ { "name": "Switching", "description": "Exchange pieces positions" }, { "name": "Extinction", "description": "Capture all of a kind" }, { "name": "Ultima", "description": "Non-standard captures" }, - { "name": "Half", "description": "Small board" }, ]; diff --git a/views/rules/Half.pug b/views/rules/Half.pug deleted file mode 100644 index 91b4a4e2..00000000 --- a/views/rules/Half.pug +++ /dev/null @@ -1,24 +0,0 @@ -p.boxed - | 4x8 board with no pawns. Orthodox rules. - -figure.diagram-container - .diagram - | fen:rn4NR/kb4BK/qb4BQ/rn4NR: - figcaption Initial position (non-random) - -h3 Specifications - -ul - li Chessboard: 4x8 (see diagram). - li Material: no pawns. - li Non-capturing moves: standard. - li Special moves: none. - li Captures: standard. - li End of game: standard. - -h3 Credits - -p - | This variant is shortly described on - a(href="https://www.chessvariants.com/small.dir/halfchess.html") chessvariants.com - | . -- 2.44.0