Allow to set protocol at startup
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 2 Apr 2023 16:22:46 +0000 (18:22 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 2 Apr 2023 17:09:25 +0000 (19:09 +0200)
src/uci.cpp
tests/protocol.sh

index 4f41b3f..9902afd 100644 (file)
@@ -343,28 +343,31 @@ void UCI::loop(int argc, char* argv[]) {
       else if (token == "ponderhit")
           Threads.main()->ponder = false; // Switch to normal search
 
-      else if (token == "uci" || token == "usi" || token == "ucci" || token == "xboard")
+      else if (token == "uci" || token == "usi" || token == "ucci" || token == "xboard" || token == "ucicyclone")
       {
-          CurrentProtocol =  token == "uci"  ? UCI_GENERAL
+          CurrentProtocol =  token == "uci"  ? (CurrentProtocol == UCI_CYCLONE ? UCI_CYCLONE : UCI_GENERAL)
+                           : token == "ucicyclone" ? UCI_CYCLONE
                            : token == "usi"  ? USI
                            : token == "ucci" ? UCCI
                            : XBOARD;
           string defaultVariant = string(
 #ifdef LARGEBOARDS
                                            CurrentProtocol == USI  ? "shogi"
-                                         : CurrentProtocol == UCCI ? "xiangqi"
+                                         : CurrentProtocol == UCCI || CurrentProtocol == UCI_CYCLONE ? "xiangqi"
 #else
                                            CurrentProtocol == USI  ? "minishogi"
-                                         : CurrentProtocol == UCCI ? "minixiangqi"
+                                         : CurrentProtocol == UCCI || CurrentProtocol == UCI_CYCLONE ? "minixiangqi"
 #endif
                                                            : "chess");
           Options["UCI_Variant"].set_default(defaultVariant);
           std::istringstream ss("startpos");
           position(pos, ss, states);
-          if (is_uci_dialect(CurrentProtocol))
+          if (is_uci_dialect(CurrentProtocol) && token != "ucicyclone")
               sync_cout << "id name " << engine_info(true)
                           << "\n" << Options
                           << "\n" << token << "ok"  << sync_endl;
+          // Allow to enforce protocol at startup
+          argc = 1;
       }
 
       else if (CurrentProtocol == XBOARD)
index d66d9a1..18c3a45 100755 (executable)
@@ -49,6 +49,17 @@ cat << EOF > ucicyclone.exp
    expect eof
 EOF
 
+cat << EOF > ucicyclone2.exp
+   spawn ./stockfish ucicyclone
+   send "uci\\n"
+   expect "uciok"
+   send "position startpos\\n"
+   send "d\\n"
+   expect "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1"
+   send "quit\\n"
+   expect eof
+EOF
+
 cat << EOF > xboard.exp
    spawn ./stockfish load variants.ini
    send "xboard\\n"
@@ -64,7 +75,7 @@ cat << EOF > xboard.exp
    expect eof
 EOF
 
-for exp in uci.exp ucci.exp usi.exp ucicyclone.exp xboard.exp
+for exp in uci.exp ucci.exp usi.exp ucicyclone.exp ucicyclone2.exp xboard.exp
 do
   echo "Testing $exp"
   timeout 5 expect $exp > /dev/null