changes by H.G. Muller; version 4.3.4
[xboard.git] / common.h
index fc2b999..be6d4e8 100644 (file)
--- a/common.h
+++ b/common.h
@@ -100,10 +100,27 @@ int pclose(FILE *);
 \r
 #define PROTOVER                2       /* engine protocol version */\r
 \r
-#define BOARD_SIZE              12                     /* [HGM] for in declarations */\r
-#define BOARD_WIDTH             (appData.NrFiles)      /* [HGM] made user adjustable */\r
-#define BOARD_HEIGHT            (appData.NrRanks)\r
-#define ONE                     ('1'-(BOARD_HEIGHT>9)) /* [HGM] foremost board rank */\r
+/* [HGM] Some notes about board sizes:\r
+   In games that allow piece drops, the holdings are considered part of the\r
+   board, in the leftmost and rightmost two files. This way they are\r
+   automatically part of the game-history states, and enjoy all display\r
+   functions (including drag-drop and click-click moves to the regular part\r
+   of the board). The drawback of this is that the internal numbering of\r
+   files starts at 2 for the a-file if holdings are displayed. To ensure\r
+   consistency, this shifted numbering system is used _everywhere_ in the\r
+   code, and conversion to the 'normal' system only takes place when the\r
+   file number is converted to or from ASCII (by redefining the character\r
+   constant 'a'). This works because Winboard only communicates with the\r
+   outside world in ASCII. In a similar way, the different rank numbering\r
+   systems (starting at rank 0 or 1) are implemented by redefining '1'.\r
+*/\r
+#define BOARD_SIZE              16            /* [HGM] for in declarations */\r
+#define BOARD_HEIGHT (gameInfo.boardHeight)   // [HGM] made user adjustable \r
+#define BOARD_WIDTH  (gameInfo.boardWidth + 2*gameInfo.holdingsWidth)   \r
+#define BOARD_LEFT   (gameInfo.holdingsWidth) // [HGM] play-board edges     \r
+#define BOARD_RGHT   (gameInfo.boardWidth + gameInfo.holdingsWidth)\r
+#define ONE          ('1'-(BOARD_HEIGHT>9))   // [HGM] foremost board rank  \r
+#define AAA          ('a'-BOARD_LEFT)         // [HGM] leftmost board file  \r
 #define DROP_RANK               -3\r
 #define MAX_MOVES              1000\r
 #define MSG_SIZ                        512\r
@@ -168,24 +185,32 @@ typedef enum {
   } GameMode;\r
 \r
 typedef enum {\r
-    WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, \r
+    WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen, \r
 #ifdef FAIRY\r
-    WhiteCardinal, WhiteMarshall, WhiteFairyPawn, WhiteFairyKnight,\r
-    WhiteFairyBishop, WhiteFairyRook, WhiteFairyCardinal, WhiteFairyMarshall,\r
-    WhiteFairyQueen, WhiteFairyKing,\r
+    /* [HGM] the order here is crucial for Crazyhouse & Shogi: */\r
+    /* only the first N pieces can go into the holdings, and   */\r
+    /* promotions in those variants shift P-W to E-M           */\r
+    WhiteFerz, WhiteWazir, WhiteAlfil, WhiteNightrider, WhiteCardinal,\r
+    WhiteMarshall, WhiteGrasshopper, WhiteCannon, WhiteMan, WhiteUnicorn,\r
 #endif\r
-    WhiteQueen, WhiteKing,\r
-    BlackPawn, BlackKnight, BlackBishop, BlackRook,\r
+    WhiteKing, BlackPawn, BlackKnight, BlackBishop, BlackRook, BlackQueen, \r
 #ifdef FAIRY\r
-    BlackCardinal, BlackMarshall, BlackFairyPawn, BlackFairyKnight,\r
-    BlackFairyBishop, BlackFairyRook, BlackFairyCardinal, BlackFairyMarshall,\r
-    BlackFairyQueen, BlackFairyKing,\r
+    BlackFerz, BlackWazir, BlackAlfil, BlackNightrider, BlackCardinal,\r
+    BlackMarshall, BlackGrasshopper, BlackCannon, BlackMan, BlackUnicorn,\r
 #endif\r
-    BlackQueen, BlackKing,\r
+    BlackKing,\r
     EmptySquare, \r
     ClearBoard, WhitePlay, BlackPlay /*for use on EditPosition menus*/\r
   } ChessSquare;\r
 \r
+/* [HGM] some macros that can be used as prefixes to convert piece types */\r
+#define WHITE_TO_BLACK (int)BlackPawn - (int)WhitePawn + (int)\r
+#define BLACK_TO_WHITE (int)WhitePawn - (int)BlackPawn + (int)\r
+#define PROMOTED       (int)WhiteAlfil - (int)WhitePawn + (int)\r
+#define DEMOTED        (int)WhitePawn - (int)WhiteAlfil + (int)\r
+#define SHOGI          (int)EmptySquare + (int)\r
+\r
+\r
 typedef ChessSquare Board[BOARD_SIZE][BOARD_SIZE];\r
 \r
 typedef enum {\r
@@ -243,52 +268,23 @@ typedef enum {
     VariantShatranj,     /* Unsupported (ICC wild 28) */\r
     Variant29,           /* Temporary name for possible future ICC wild 29 */\r
     Variant30,           /* Temporary name for possible future ICC wild 30 */\r
-#ifdef FAIRY\r
-    VariantShogi,        /* [HGM] To be supported in next version */\r
-    VariantXiangqi,\r
-    VariantCourier,\r
-    VariantGothic,\r
-    VariantCapablanca,\r
-    VariantFairy,        /* [HGM] allow more piece types */\r
-#else\r
     Variant31,           /* Temporary name for possible future ICC wild 31 */\r
     Variant32,           /* Temporary name for possible future ICC wild 32 */\r
-    Variant33,\r
+    Variant33,           /* Temporary name for possible future ICC wild 33 */\r
     Variant34,           /* Temporary name for possible future ICC wild 34 */\r
     Variant35,           /* Temporary name for possible future ICC wild 35 */\r
     Variant36,           /* Temporary name for possible future ICC wild 36 */\r
-#endif\r
+    VariantShogi,        /* [HGM] added variants */\r
+    VariantXiangqi,\r
+    VariantCourier,\r
+    VariantGothic,\r
+    VariantCapablanca,\r
+    VariantKnightmate,\r
+    VariantFairy,        \r
+    VariantShowgi,\r
     VariantUnknown       /* Catchall for other unknown variants */\r
 } VariantClass;\r
 \r
-#ifdef FAIRY\r
-#define VARIANT_NAMES { \\r
-  "normal", \\r
-  "normal", \\r
-  "wildcastle", \\r
-  "nocastle", \\r
-  "fischerandom", \\r
-  "bughouse", \\r
-  "crazyhouse", \\r
-  "losers", \\r
-  "suicide", \\r
-  "giveaway", \\r
-  "twokings", \\r
-  "kriegspiel", \\r
-  "atomic", \\r
-  "3check", \\r
-  "shatranj", \\r
-  "wild29", \\r
-  "wild30", \\r
-  "shogi", \\r
-  "xiangqi", \\r
-  "courier", \\r
-  "gothic", \\r
-  "capablanca", \\r
-  "fairy", \\r
-  "unknown" \\r
-}\r
-#else\r
 #define VARIANT_NAMES { \\r
   "normal", \\r
   "normal", \\r
@@ -313,9 +309,16 @@ typedef enum {
   "wild34", \\r
   "wild35", \\r
   "wild36", \\r
+  "shogi", \\r
+  "xiangqi", \\r
+  "courier", \\r
+  "gothic", \\r
+  "capablanca", \\r
+  "knightmate", \\r
+  "fairy", \\r
+  "showgi", \\r
   "unknown" \\r
 }\r
-#endif\r
 \r
 typedef struct {\r
 #if !defined(_amigados)\r
@@ -516,10 +519,16 @@ typedef struct {
     /* [HGM] Board size */\r
     int NrFiles;\r
     int NrRanks;\r
+    int holdingsSize;\r
     int matchPause;\r
+    Boolean alphaRank;\r
     Boolean testClaims;\r
+    Boolean checkMates;\r
+    Boolean materialDraws;\r
+    Boolean trivialDraws;\r
     int ruleMoves;\r
     int drawRepeats;\r
+    char * pieceToCharTable;\r
 \r
 #if ZIPPY\r
     char *zippyLines;\r
@@ -580,7 +589,16 @@ typedef struct {
     int blackRating;    /* -1 if unknown */\r
     VariantClass variant;\r
     char *outOfBook;    /* [AS] Move and score when engine went out of book */\r
+    int boardWidth;     /* [HGM] adjustable board size */\r
+    int boardHeight;\r
+/* [HGM] For Shogi and Crazyhouse: */\r
+    int holdingsSize;  /* number of different piece types in holdings       */\r
+    int holdingsWidth; /* number of files left and right of board, 0 or 2   */\r
 } GameInfo;\r
 \r
 \r
 #endif\r
+\r
+/* extern int holdingsWidth;  \r
+extern int holdingsHeight; \r
+/*extern int holdings[(int) EmptySquare];*/\r