Randomize Shogi, update TODO
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 15 Apr 2020 13:41:59 +0000 (15:41 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 15 Apr 2020 13:41:59 +0000 (15:41 +0200)
TODO
client/src/translations/about/en.pug
client/src/translations/about/es.pug
client/src/translations/about/fr.pug
client/src/variants/Shogi.js

diff --git a/TODO b/TODO
index d37b936..293d78a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,8 @@
 Chakart :)
 https://www.chessvariants.com/crossover.dir/koopachess.html
+--> Can a stunned piece capture? Maybe not.
+Donkey pose une banane soit en début de coup soit à la fin, en diagonale, et explosion orthogonale.
+Wario pareil mais pose orthogonale et explosion diagonale.
 
 Diamond Chess [Rynd] (J. A.
 Porterfield Rynd, 1886)  --> Berolina2 ?
@@ -49,6 +52,7 @@ Recycle1 et Recycle2 (--> celle-là)
 http://abrobecker.free.fr/chess/fairyblitz.htm#deplaceurdevivants
 Philippe Rouzaud, Phénix 151-152, mai 2006): Un camp peut, à la place d'un coup orthodoxe, capturer une de ses pièces et replacer la pièce capturée immédiatement sur l'échiquier. Un roi peut rester en échec durant cette action. Une pièce déplacée sur l'échiquier peut mater. Un pion ne peut pas être déplacé en première ou dernière rangée. Un roi peut déplacer et être déplacé, y compris pour se soustraire à un échec. Le roque ne peut se faire que de manière orthodoxe.
 Rouzaud-Banaddou: 1.Fxb2 (=f5) Dxc7 (=e6) 2.fxe6 dxe6 3.Txb1 (=b5) Dxe7 (=c7) 4.Txb2 (=a3) Dxf7 (=d6) 5.Txg1 (=g5) Dxg7 (=f6) 6.Txf1 (=f7)+ Rxf8 (=h4) 7.Fxb2 (=e8) Rxg7 (=c5) 8.Rxd1 (=f8)+ Rxh8 (=g7) 9.Dxg8+ Txg8 10.Txg8#
+--> Implémenté comme Dynamo, déplacement d'une pièce éventuellement avec self-capture, puis capture (sur case vide), forcée si premier coup illégal.
 
 http://abrobecker.free.fr/chess/fairyblitz.htm#madrasi
 Madrasi Chess, Abdul J. Karwathar, 1979): Deux pièces de même nature (excepté les rois) qui s'observent, se paralysent mutuellement en perdant tout pouvoir (déplacement, prise, donner échec ou mat) sauf celui de paralyser une autre pièce.
index 31992cd..62c2af8 100644 (file)
@@ -55,3 +55,4 @@ h3 Related links
   a(href="https://en.wikipedia.org/wiki/Fairy_chess_piece") Fairy chess pieces
   a(href="http://www.pion.ch/echecs/liste_variantes.php") pion.ch
   a(href="http://abrobecker.free.fr/chess/fairyblitz.htm") fairyblitz.htm
+  a(href="https://chessvariants.training/") chessvariants.training
index 7f2f4dd..aa0f08c 100644 (file)
@@ -55,3 +55,4 @@ h3 Enlaces relacionados
     | Piezas de ajedrez magicas
   a(href="http://www.pion.ch/echecs/liste_variantes.php") pion.ch
   a(href="http://abrobecker.free.fr/chess/fairyblitz.htm") fairyblitz.htm
+  a(href="https://chessvariants.training/") chessvariants.training
index 7601199..d1a30a0 100644 (file)
@@ -56,3 +56,4 @@ h3 Liens connexes
     | Pièces d'échecs féériques
   a(href="http://www.pion.ch/echecs/liste_variantes.php") pion.ch
   a(href="http://abrobecker.free.fr/chess/fairyblitz.htm") fairyblitz.htm
+  a(href="https://chessvariants.training/") chessvariants.training
index f684a27..bbd3af5 100644 (file)
@@ -1,5 +1,6 @@
 import { ChessRules, PiPo, Move } from "@/base_rules";
 import { ArrayFun } from "@/utils/array";
+import { shuffle } from "@/utils/alea";
 
 export class ShogiRules extends ChessRules {
   static get HasFlags() {
@@ -94,11 +95,28 @@ export class ShogiRules extends ChessRules {
     );
   }
 
-  static GenRandInitFen() {
-    // No randomization for now:
+  static GenRandInitFen(randomness) {
+    if (randomness == 0) {
+      return (
+        "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL " +
+        "w 0 00000000000000"
+      );
+    }
+    let pieces = { w: new Array(9), b: new Array(9) };
+    for (let c of ["w", "b"]) {
+      if (c == 'b' && randomness == 1) {
+        pieces['b'] = pieces['w'];
+        break;
+      }
+      let positions = shuffle(ArrayFun.range(9));
+      const composition = ['l', 'l', 'n', 'n', 's', 's', 'g', 'g', 'k'];
+      for (let i = 0; i < 9; i++) pieces[c][positions[i]] = composition[i];
+    }
     return (
-      "lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL " +
-      "w 0 00000000000000"
+      pieces["b"].join("") +
+      "/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/" +
+      pieces["w"].join("").toUpperCase() +
+      " w 0 00000000000000"
     );
   }