From ee0ba01e4d3ca8af3ae46fe43f7267d944514f73 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Sun, 28 Nov 2021 14:30:52 +0100 Subject: [PATCH] Support time unit switch for UCCI Closes #406. --- src/uci.cpp | 9 +++++---- src/ucioption.cpp | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/uci.cpp b/src/uci.cpp index 6f3564d..d7f483c 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -138,6 +138,7 @@ namespace { limits.banmoves = banmoves; bool isUsi = Options["Protocol"] == "usi"; + int secResolution = Options["usemillisec"] ? 1 : 1000; while (is >> token) if (token == "searchmoves") // Needs to be the last command on the line @@ -157,10 +158,10 @@ namespace { else if (token == "infinite") limits.infinite = 1; else if (token == "ponder") ponderMode = true; // UCCI commands - else if (token == "time") is >> limits.time[pos.side_to_move()]; - else if (token == "opptime") is >> limits.time[~pos.side_to_move()]; - else if (token == "increment") is >> limits.inc[pos.side_to_move()]; - else if (token == "oppinc") is >> limits.inc[~pos.side_to_move()]; + else if (token == "time") is >> limits.time[pos.side_to_move()], limits.time[pos.side_to_move()] *= secResolution; + else if (token == "opptime") is >> limits.time[~pos.side_to_move()], limits.time[~pos.side_to_move()] *= secResolution; + else if (token == "increment") is >> limits.inc[pos.side_to_move()], limits.inc[pos.side_to_move()] *= secResolution; + else if (token == "oppincrement") is >> limits.inc[~pos.side_to_move()], limits.inc[~pos.side_to_move()] *= secResolution; // USI commands else if (token == "byoyomi") { diff --git a/src/ucioption.cpp b/src/ucioption.cpp index b1ceb8c..8666eac 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -207,6 +207,7 @@ void init(OptionsMap& o) { #endif o["TsumeMode"] << Option(false); o["VariantPath"] << Option("", on_variant_path); + o["usemillisec"] << Option(true); // time unit for UCCI } -- 1.7.0.4