More robust shogi move parsing
authorianfab <ianfab@users.noreply.github.com>
Wed, 22 Aug 2018 19:58:45 +0000 (21:58 +0200)
committerianfab <ianfab@users.noreply.github.com>
Wed, 22 Aug 2018 19:58:45 +0000 (21:58 +0200)
Allow optional equals sign at end of move string.

src/uci.cpp

index d17a467..ec8c044 100644 (file)
@@ -316,8 +316,15 @@ string UCI::move(const Position& pos, Move m) {
 
 Move UCI::to_move(const Position& pos, string& str) {
 
-  if (str.length() == 5) // Junior could send promotion piece in uppercase
-      str[4] = char(tolower(str[4]));
+  if (str.length() == 5)
+  {
+      if (str[4] == '=')
+          // shogi moves refraining from promotion might use equals sign
+          str.pop_back();
+      else
+          // Junior could send promotion piece in uppercase
+          str[4] = char(tolower(str[4]));
+  }
 
   for (const auto& m : MoveList<LEGAL>(pos))
       if (str == UCI::move(pos, m))