Add Doublearmy, commoner replaces middle king, no rules description yet (TODO)
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 24 Mar 2020 03:51:50 +0000 (04:51 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 24 Mar 2020 03:51:50 +0000 (04:51 +0100)
TODO
client/public/images/pieces/Doublearmy/bc.svg [new file with mode: 0644]
client/public/images/pieces/Doublearmy/wc.svg [new file with mode: 0644]
client/src/translations/en.js
client/src/translations/es.js
client/src/translations/fr.js
client/src/translations/rules/Doublearmy/en.pug [new file with mode: 0644]
client/src/translations/rules/Doublearmy/es.pug [new file with mode: 0644]
client/src/translations/rules/Doublearmy/fr.pug [new file with mode: 0644]
client/src/variants/Doublearmy.js [new file with mode: 0644]
server/db/populate.sql

diff --git a/TODO b/TODO
index 8d3eabc..7d46a80 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,4 @@
 # New variants
-Doublearmy: 2 kings remaining get mated.
-
 Landing pieces from empty board:
 https://www.chessvariants.com/diffsetup.dir/unachess.html
 Parachute v1 & 2
diff --git a/client/public/images/pieces/Doublearmy/bc.svg b/client/public/images/pieces/Doublearmy/bc.svg
new file mode 100644 (file)
index 0000000..0995449
--- /dev/null
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="45"
+   height="45"
+   viewBox="0 0 11.90625 11.90625"
+   version="1.1"
+   id="svg4393"
+   sodipodi:docname="CommonerB_Transparent.svg"
+   inkscape:version="0.92.1 r15371">
+  <defs
+     id="defs4387" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="3"
+     inkscape:cx="30.240069"
+     inkscape:cy="21.353804"
+     inkscape:document-units="mm"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1600"
+     inkscape:window-height="837"
+     inkscape:window-x="-8"
+     inkscape:window-y="-8"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata4390">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-285.09373)">
+    <g
+       id="g4572"
+       transform="matrix(0.28921369,0,0,0.28921369,-0.54713251,283.72613)">
+      <circle
+         id="circle4537"
+         r="2.5"
+         cy="13.5"
+         cx="22.5"
+         style="fill:#000000;stroke:#000000;stroke-width:1.5;stroke-linejoin:round" />
+      <circle
+         id="circle4539"
+         r="1.5"
+         cy="13.5"
+         cx="22.5"
+         style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linejoin:round" />
+      <g
+         id="g4543"
+         style="fill:#000000;stroke:#000000;stroke-width:1.5;stroke-linejoin:round">
+        <!-- test -->
+        <path
+           id="path4541"
+           d="m 11.5,37 c 5.5,3.5 15.5,3.5 21,0 v -7 c 0,0 9,-4.5 6,-11 -5.5,-7 -26.5,-7 -32,0 -3,6.5 5,10.5 5,10.5 z"
+           inkscape:connector-curvature="0" />
+      </g>
+      <g
+         id="g4553"
+         style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round">
+        <!-- test -->
+        <path
+           id="path4545"
+           d="m 32,29.5 c 0,0 8.5,-4 6,-9.65 C 32.65,13 12.35,13 7,19.85 c -2.5,5.65 4.85,9 4.85,9"
+           inkscape:connector-curvature="0" />
+        <!-- talp -->
+        <path
+           id="path4547"
+           d="M 11.5,30 C 17,27 27,27 32.5,30"
+           inkscape:connector-curvature="0" />
+        <path
+           id="path4549"
+           d="m 11.5,33.5 c 5.5,-3 15.5,-3 21,0"
+           inkscape:connector-curvature="0" />
+        <path
+           id="path4551"
+           d="M 11.5,37 C 17,34 27,34 32.5,37"
+           inkscape:connector-curvature="0" />
+      </g>
+    </g>
+  </g>
+</svg>
diff --git a/client/public/images/pieces/Doublearmy/wc.svg b/client/public/images/pieces/Doublearmy/wc.svg
new file mode 100644 (file)
index 0000000..12f2b27
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="45"
+   height="45"
+   viewBox="0 0 11.90625 11.90625"
+   version="1.1"
+   id="svg4393"
+   inkscape:version="0.92.1 r15371"
+   sodipodi:docname="Commoner_Transparent.svg">
+  <defs
+     id="defs4387" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1"
+     inkscape:cx="5.1998528"
+     inkscape:cy="24.301903"
+     inkscape:document-units="mm"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1600"
+     inkscape:window-height="837"
+     inkscape:window-x="-8"
+     inkscape:window-y="-8"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata4390">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-285.09373)">
+    <g
+       id="g4499"
+       transform="matrix(0.28598519,0,0,0.28598519,-0.47456997,283.80785)">
+      <g
+         id="g4399"
+         style="fill:#ffffff;stroke:#000000;stroke-width:1.5;stroke-linejoin:round">
+        <!-- bojt -->
+        <circle
+           id="circle4395"
+           r="2.5"
+           cy="13.5"
+           cx="22.5" />
+        <!-- test -->
+        <path
+           id="path4397"
+           d="m 11.5,37 c 5.5,3.5 15.5,3.5 21,0 v -7 c 0,0 9,-4.5 6,-11 -5.5,-7 -26.5,-7 -32,0 -3,6.5 5,10.5 5,10.5 z"
+           inkscape:connector-curvature="0" />
+      </g>
+      <g
+         id="g4407"
+         style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:round">
+        <!-- talp -->
+        <path
+           id="path4401"
+           d="M 11.5,30 C 17,27 27,27 32.5,30"
+           inkscape:connector-curvature="0" />
+        <path
+           id="path4403"
+           d="m 11.5,33.5 c 5.5,-3 15.5,-3 21,0"
+           inkscape:connector-curvature="0" />
+        <path
+           id="path4405"
+           d="M 11.5,37 C 17,34 27,34 32.5,37"
+           inkscape:connector-curvature="0" />
+      </g>
+    </g>
+  </g>
+</svg>
index 815edf6..513922a 100644 (file)
@@ -152,6 +152,7 @@ export const translations = {
   "Your message": "Your message",
 
   // Variants boxes:
+  "64 pieces on the board": "64 pieces on the board",
   "Ancient rules": "Ancient rules",
   "Attract opposite king": "Attract opposite king",
   "Balanced sliders & leapers": "Balanced sliders & leapers",
index f008e53..fb13e28 100644 (file)
@@ -152,6 +152,7 @@ export const translations = {
   "Your message": "Tu mensaje",
 
   // Variants boxes:
+  "64 pieces on the board": "64 piezas en el tablero",
   "Ancient rules": "Viejas reglas",
   "Attract opposite king": "Atraer al rey contrario",
   "Balanced sliders & leapers": "Modos de desplazamiento equilibrados",
index 1d4dbd5..8524dcb 100644 (file)
@@ -152,6 +152,7 @@ export const translations = {
   "Your message": "Votre message",
 
   // Variants boxes:
+  "64 pieces on the board": "64 pièces sur l'échiquier",
   "Ancient rules": "Règles anciennes",
   "Attract opposite king": "Attirer le roi adverse",
   "Balanced sliders & leapers": "Modes de déplacement équilibrés",
diff --git a/client/src/translations/rules/Doublearmy/en.pug b/client/src/translations/rules/Doublearmy/en.pug
new file mode 100644 (file)
index 0000000..5e0f62d
--- /dev/null
@@ -0,0 +1,2 @@
+p.boxed
+  | TODO.
diff --git a/client/src/translations/rules/Doublearmy/es.pug b/client/src/translations/rules/Doublearmy/es.pug
new file mode 100644 (file)
index 0000000..5e0f62d
--- /dev/null
@@ -0,0 +1,2 @@
+p.boxed
+  | TODO.
diff --git a/client/src/translations/rules/Doublearmy/fr.pug b/client/src/translations/rules/Doublearmy/fr.pug
new file mode 100644 (file)
index 0000000..5e0f62d
--- /dev/null
@@ -0,0 +1,2 @@
+p.boxed
+  | TODO.
diff --git a/client/src/variants/Doublearmy.js b/client/src/variants/Doublearmy.js
new file mode 100644 (file)
index 0000000..0fafe96
--- /dev/null
@@ -0,0 +1,81 @@
+import { ChessRules } from "@/base_rules";
+
+// Ideas with 2 kings:
+// Stage 1 {w, b} : 2 kings on board, value 5.
+// Stage 2: only one, get mated and all that, value 1000
+// ...But the middle king will get captured quickly...
+
+export class DoublearmyRules extends ChessRules {
+  static get COMMONER() {
+    return "c";
+  }
+
+  static get PIECES() {
+    return ChessRules.PIECES.concat([V.COMMONER]);
+  }
+
+  getPpath(b) {
+    return (b[1] == V.COMMONER ? "Doublearmy/" : "") + b;
+  }
+
+  static GenRandInitFen(randomness) {
+    const fen = ChessRules.GenRandInitFen(randomness);
+    const rows = fen.split(" ")[0].split("/");
+    return (
+      rows[0] + "/" +
+      rows[1] + "/" +
+      rows[0].replace('k', 'c') + "/" +
+      rows[1] + "/" +
+      rows[6] + "/" +
+      rows[7].replace('K', 'C') + "/" +
+      rows[6] + "/" +
+      rows[7] + fen.slice(-11)
+    );
+  }
+
+  getPotentialMovesFrom([x, y]) {
+    switch (this.getPiece(x, y)) {
+      case V.COMMONER:
+        return this.getPotentialCommonerMoves([x, y]);
+      default:
+        return super.getPotentialMovesFrom([x, y]);
+    }
+  }
+
+  getPotentialCommonerMoves(sq) {
+    return this.getSlideNJumpMoves(
+      sq,
+      V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
+      "oneStep"
+    );
+  }
+
+  isAttacked(sq, color) {
+    return (
+      super.isAttacked(sq, color) ||
+      this.isAttackedByCommoner(sq, color)
+    );
+  }
+
+  isAttackedByCommoner(sq, color) {
+    return this.isAttackedBySlideNJump(
+      sq,
+      color,
+      V.COMMONER,
+      V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
+      "oneStep"
+    );
+  }
+
+  static get VALUES() {
+    return Object.assign(
+      {},
+      ChessRules.VALUES,
+      { c: 5 }
+    );
+  }
+
+  static get SEARCH_DEPTH() {
+    return 2;
+  }
+};
index 72ded70..28d186c 100644 (file)
@@ -22,6 +22,7 @@ insert or ignore into Variants (name,description) values
   ('Crazyhouse', 'Captures reborn'),
   ('Cylinder', 'Neverending rows'),
   ('Dark', 'In the shadow'),
+  ('Doublearmy', '64 pieces on the board'),
   ('Eightpieces', 'Each piece is unique'),
   ('Enpassant', 'Capture en passant'),
   ('Extinction', 'Capture all of a kind'),