Turn Grasshopper into a built-in variant
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 1 May 2021 17:13:22 +0000 (19:13 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 1 May 2021 17:13:22 +0000 (19:13 +0200)
README.md
src/variant.cpp
src/variants.ini
tests/perft.sh

index 2b1d5b7..14c9394 100644 (file)
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ The games currently supported besides chess are listed below. Fairy-Stockfish ca
 - [Los Alamos](https://en.wikipedia.org/wiki/Los_Alamos_chess), [Gardner's Minichess](https://en.wikipedia.org/wiki/Minichess#5%C3%975_chess)
 - [Atomic](https://en.wikipedia.org/wiki/Atomic_chess)
 - [Horde](https://en.wikipedia.org/wiki/Dunsany%27s_Chess#Horde_Chess), [Maharajah and the Sepoys](https://en.wikipedia.org/wiki/Maharajah_and_the_Sepoys)
-- [Knightmate](https://www.chessvariants.com/diffobjective.dir/knightmate.html), [Nightrider](https://en.wikipedia.org/wiki/Nightrider_(chess))
+- [Knightmate](https://www.chessvariants.com/diffobjective.dir/knightmate.html), [Nightrider](https://en.wikipedia.org/wiki/Nightrider_(chess)), [Grasshopper](https://en.wikipedia.org/wiki/Grasshopper_chess)
 
 ### Shogi variants
 - [Minishogi](https://en.wikipedia.org/wiki/Minishogi), [EuroShogi](https://en.wikipedia.org/wiki/EuroShogi), [Judkins shogi](https://en.wikipedia.org/wiki/Judkins_shogi)
index 7866c79..4442c33 100644 (file)
@@ -202,6 +202,16 @@ namespace {
         v->promotionPieceTypes = {QUEEN, ROOK, BISHOP, CUSTOM_PIECES};
         return v;
     }
+    // Grasshopper chess
+    // https://en.wikipedia.org/wiki/Grasshopper_chess
+    Variant* grasshopper_variant() {
+        Variant* v = chess_variant_base();
+        v->add_piece(CUSTOM_PIECES, 'g', "gQ");
+        v->promotionPieceTypes.insert(CUSTOM_PIECES);
+        v->startFen = "rnbqkbnr/gggggggg/pppppppp/8/8/PPPPPPPP/GGGGGGGG/RNBQKBNR w KQkq - 0 1";
+        v->doubleStep = false;
+        return v;
+    }
     // Hoppel-Poppel
     // A variant from Germany where knights capture like bishops and vice versa
     // https://www.chessvariants.com/diffmove.dir/hoppel-poppel.html
@@ -1312,6 +1322,7 @@ void VariantMap::init() {
     add("chaturanga", chaturanga_variant()->conclude());
     add("amazon", amazon_variant()->conclude());
     add("nightrider", nightrider_variant()->conclude());
+    add("grasshopper", grasshopper_variant()->conclude());
     add("hoppelpoppel", hoppelpoppel_variant()->conclude());
     add("newzealand", newzealand_variant()->conclude());
     add("kingofthehill", kingofthehill_variant()->conclude());
index 7827066..968a1ba 100644 (file)
@@ -682,9 +682,3 @@ startFen = 3mm3/8/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1
 extinctionValue = loss
 extinctionPieceTypes = m
 extinctionPseudoRoyal = true
-
-[grasshopper:chess]
-customPiece1 = g:gQ
-startFen = rnbqkbnr/gggggggg/pppppppp/8/8/PPPPPPPP/GGGGGGGG/RNBQKBNR w KQkq - 0 1
-promotionPieceTypes = brqng
-doubleStep = false
index d4c9474..5262a62 100755 (executable)
@@ -53,6 +53,7 @@ if [[ $1 == "" || $1 == "variant" ]]; then
   expect perft.exp shatranj startpos 4 68122 > /dev/null
   expect perft.exp amazon startpos 4 318185 > /dev/null
   expect perft.exp nightrider startpos 4 419019 > /dev/null
+  expect perft.exp grasshopper startpos 4 635298 > /dev/null
   expect perft.exp hoppelpoppel startpos 4 202459 > /dev/null
   expect perft.exp newzealand startpos 4 200310 > /dev/null
   # alternative goals