From 381672f217b051c71f2853d01ac1d5b0c9dc3788 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Sat, 1 May 2021 19:13:22 +0200 Subject: [PATCH] Turn Grasshopper into a built-in variant --- README.md | 2 +- src/variant.cpp | 11 +++++++++++ src/variants.ini | 6 ------ tests/perft.sh | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2b1d5b7..14c9394 100644 --- 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) diff --git a/src/variant.cpp b/src/variant.cpp index 7866c79..4442c33 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -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()); diff --git a/src/variants.ini b/src/variants.ini index 7827066..968a1ba 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -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 diff --git a/tests/perft.sh b/tests/perft.sh index d4c9474..5262a62 100755 --- a/tests/perft.sh +++ b/tests/perft.sh @@ -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 -- 1.7.0.4