Represent DragonKing and DragonHorse by D and H
[capablanca.git] / lasker-2.2.3 / src / algcheck.c
old mode 100755 (executable)
new mode 100644 (file)
index d043445..065a859
@@ -152,6 +152,8 @@ static int get_move_info(const char *str, int *piece, int *ff, int *fr, int *tf,
          lpiece = KNIGHT;
        else if (c == 'p')
          lpiece = PAWN;
+       else if (c == 'd')
+         lpiece = DRAGONKING;
        else
          goto nomatch;
        break;
@@ -219,7 +221,7 @@ static void add_promotion(struct game_state_t *gs, const char *mstr, struct move
        if (s == NULL) {
                return;
        }
-       
+
        if (piecetype(gs->board[mt->fromFile][mt->fromRank]) != PAWN) {
                return;
        }
@@ -339,6 +341,7 @@ int alg_parse_move(char *mstr, struct game_state_t * gs, struct move_t * mt)
       break;
     case HORSE:
       if(strstr(gs->variant, "great")) piece = PRIESTESS;
+      if(strstr(gs->variant, "shogi")) piece = DRAGONHORSE;
       break;
     case GOLD:
       if(strstr(gs->variant, "great")) piece = MASTODON;
@@ -566,10 +569,10 @@ char *alg_unparse(struct game_state_t * gs, struct move_t * mt)
     strcpy(mStr, "N");
     break;
   case DRAGONKING:
-    strcpy(mStr, "J");
+    strcpy(mStr, "D");
     break;
   case DRAGONHORSE:
-    strcpy(mStr, "I");
+    strcpy(mStr, "H");
     break;
   case LANCE:
     strcpy(mStr, "L");
@@ -656,8 +659,8 @@ char *alg_unparse(struct game_state_t * gs, struct move_t * mt)
   }\r
   sprintf(tmp, "%c%d", mt->toFile + 'a', mt->toRank + 1 - (gs->ranks > 9));\r
   strcat(mStr, tmp);\r
-\r
-  if ((piece == PAWN) && (mt->piecePromotionTo != NOPIECE)) {\r
+
+  if ((piece == PAWN || gs->promoType == 3) && (mt->piecePromotionTo != NOPIECE)) {\r
     strcat(mStr, "=");         /* = before promoting piece */\r
     switch (piecetype(mt->piecePromotionTo)) {\r
     case KNIGHT:\r
@@ -702,6 +705,15 @@ char *alg_unparse(struct game_state_t * gs, struct move_t * mt)
     case MASTODON:\r
       strcat(mStr, "G");\r
       break;\r
+    case GOLD: // [HGM] Shogi promotions: avoid use of '+'\r
+      strcat(mStr, "G");\r
+      break;\r
+    case DRAGONHORSE:\r
+      strcat(mStr, "H");\r
+      break;\r
+    case DRAGONKING:\r
+      strcat(mStr, "D");\r
+      break;\r
     default:\r
       break;\r
     }\r