Skip to content

Commit 113c8b7

Browse files
authored
fix: flushing stdout after sending UCI responses (#345) (#350)
2 parents 4eb48a6 + c997ec7 commit 113c8b7

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

ben-bot/src/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <cstdlib>
1818
#include <exception>
1919
#include <format>
20-
#include <ios>
2120
#include <libchess/uci/Printing.hpp>
2221
#include <libchess/util/Console.hpp>
2322

@@ -27,10 +26,6 @@ int main(const int argc, const char** argv)
2726
try {
2827
chess::util::enable_utf8_console_output();
2928

30-
// we don't care about the ability to intermix C stdio with C++ iostreams
31-
// all of our IO is done through C++ iostreams
32-
std::ios_base::sync_with_stdio(false);
33-
3429
const auto args = ben_bot::Arguments::parse(argc, argv);
3530

3631
ben_bot::Engine engine;

libchess/src/uci/EngineBase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void EngineBase::handle_command(std::string_view command)
5353
wait();
5454

5555
println("readyok");
56+
std::cout.flush();
5657
return;
5758
}
5859

@@ -123,6 +124,8 @@ void EngineBase::respond_to_uci()
123124
println("{}", option->get_declaration_string());
124125

125126
println("uciok");
127+
128+
std::cout.flush();
126129
}
127130

128131
void EngineBase::handle_setpos(const string_view arguments)

libchess/src/uci/Printing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void best_move(
4848
"bestmove {}{}",
4949
to_uci(bestMove), ponder_move_string(ponderMove));
5050

51-
std::cout.flush(); // make sure the GUI doesn't think we've stalled
51+
std::cout.flush();
5252
}
5353

5454
namespace {

0 commit comments

Comments
 (0)