From ad2494bd14f9a2fd068d713df0f8ac1fb3c3743f Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Wed, 15 Apr 2020 15:41:59 +0200 Subject: [PATCH] Randomize Shogi, update TODO --- TODO | 4 ++++ client/src/translations/about/en.pug | 1 + client/src/translations/about/es.pug | 1 + client/src/translations/about/fr.pug | 1 + client/src/variants/Shogi.js | 26 ++++++++++++++++++++++---- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index d37b936e..293d78a2 100644 --- 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. diff --git a/client/src/translations/about/en.pug b/client/src/translations/about/en.pug index 31992cd7..62c2af83 100644 --- a/client/src/translations/about/en.pug +++ b/client/src/translations/about/en.pug @@ -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 diff --git a/client/src/translations/about/es.pug b/client/src/translations/about/es.pug index 7f2f4dd2..aa0f08c4 100644 --- a/client/src/translations/about/es.pug +++ b/client/src/translations/about/es.pug @@ -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 diff --git a/client/src/translations/about/fr.pug b/client/src/translations/about/fr.pug index 76011991..d1a30a06 100644 --- a/client/src/translations/about/fr.pug +++ b/client/src/translations/about/fr.pug @@ -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 diff --git a/client/src/variants/Shogi.js b/client/src/variants/Shogi.js index f684a279..bbd3af5b 100644 --- a/client/src/variants/Shogi.js +++ b/client/src/variants/Shogi.js @@ -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" ); } -- 2.44.0