From: Fabian Fichter Date: Sun, 2 Apr 2023 16:22:46 +0000 (+0200) Subject: Allow to set protocol at startup X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f68cd1c6ac9578ef8640c1d4327bb4113a625a73;p=fairystockfish.git Allow to set protocol at startup --- diff --git a/src/uci.cpp b/src/uci.cpp index 4f41b3f..9902afd 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -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) diff --git a/tests/protocol.sh b/tests/protocol.sh index d66d9a1..18c3a45 100755 --- a/tests/protocol.sh +++ b/tests/protocol.sh @@ -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