Support Armageddon Chess
authorFabian Fichter <ianfab@users.noreply.github.com>
Tue, 2 Jun 2020 18:49:54 +0000 (20:49 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Tue, 2 Jun 2020 19:36:09 +0000 (21:36 +0200)
https://en.wikipedia.org/wiki/Fast_chess#Armageddon

Closes #140.

src/parser.cpp
src/position.h
src/types.h
src/variant.cpp
src/variants.ini

index 8c6ccea..d89f25c 100644 (file)
@@ -78,8 +78,11 @@ namespace {
     template <> bool set(const std::string& value, MaterialCounting& target) {
         target =  value == "janggi"  ? JANGGI_MATERIAL
                 : value == "unweighted" ? UNWEIGHTED_MATERIAL
+                : value == "whitedrawodds" ? WHITE_DRAW_ODDS
+                : value == "blackdrawodds" ? BLACK_DRAW_ODDS
                 : NO_MATERIAL_COUNTING;
-        return value == "janggi" || value == "unweighted" || value == "none";
+        return   value == "janggi" || value == "unweighted"
+              || value == "whitedrawodds" || value == "blackdrawodds" || value == "none";
     }
 
     template <> bool set(const std::string& value, CountingRule& target) {
index 0415312..12df6c1 100644 (file)
@@ -1105,6 +1105,12 @@ inline Value Position::material_counting_result() const {
               : count(WHITE, ALL_PIECES) < count(BLACK, ALL_PIECES) ? -VALUE_MATE
                                                                     :  VALUE_DRAW;
       break;
+  case WHITE_DRAW_ODDS:
+      result = VALUE_MATE;
+      break;
+  case BLACK_DRAW_ODDS:
+      result = -VALUE_MATE;
+      break;
   default:
       assert(false);
       result = VALUE_DRAW;
index 29cc7f4..45ea71c 100644 (file)
@@ -275,7 +275,7 @@ enum CheckCount : int {
 };
 
 enum MaterialCounting {
-  NO_MATERIAL_COUNTING, JANGGI_MATERIAL, UNWEIGHTED_MATERIAL
+  NO_MATERIAL_COUNTING, JANGGI_MATERIAL, UNWEIGHTED_MATERIAL, WHITE_DRAW_ODDS, BLACK_DRAW_ODDS
 };
 
 enum CountingRule {
index 75e3399..0278dcf 100644 (file)
@@ -53,6 +53,13 @@ namespace {
         v->castling = false;
         return v;
     }
+    // Armageddon Chess
+    // https://en.wikipedia.org/wiki/Fast_chess#Armageddon
+    Variant* armageddon_variant() {
+        Variant* v = fairy_variant_base();
+        v->materialCounting = BLACK_DRAW_ODDS;
+        return v;
+    }
     Variant* fairy_variant() {
         Variant* v = chess_variant();
         v->add_piece(SILVER, 's');
@@ -927,6 +934,7 @@ void VariantMap::init() {
     add("normal", chess_variant());
     add("fischerandom", chess960_variant());
     add("nocastle", nocastle_variant());
+    add("armageddon", armageddon_variant());
     add("fairy", fairy_variant()); // fairy variant used for endgame code initialization
     add("makruk", makruk_variant());
     add("makpong", makpong_variant());
index 5fd0578..6a22b38 100644 (file)
@@ -93,7 +93,7 @@
 # [PieceType]: a piece type [letters defined for pieces, e.g., p]
 # [Bitboard]: list of squares [e.g., d4 e4 d5 e5]. * can be used as wildcard for files (e.g., *1 is the first rank)
 # [Value]: game result for the side to move [win, loss, draw]
-# [MaterialCounting]: material couting rules for adjudication [janggi, unweighted, none]
+# [MaterialCounting]: material couting rules for adjudication [janggi, unweighted, whitedrawodds, blackdrawodds, none]
 # [CountingRule]: makruk or ASEAN counting rules [makruk, asean, none]
 
 ### Rule definition options