From: Steinar H. Gunderson Date: Thu, 27 Dec 2018 18:06:08 +0000 (+0100) Subject: Set Threads before the other options, so that setting up the hash is faster. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=5ee1c604d0b954b024626f72bd6813f379ee96c4;hp=82620f45773509d6cb29f1df0f12bab1e3bbb63e Set Threads before the other options, so that setting up the hash is faster. --- diff --git a/remoteglot.pl b/remoteglot.pl index c86eede..7220412 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -76,19 +76,11 @@ my $last_move; my $last_text = ''; my ($pos_calculating, $pos_calculating_second_engine); -uciprint($engine, "setoption name UCI_AnalyseMode value true"); -uciprint($engine, "setoption name Analysis Contempt value Off"); -while (my ($key, $value) = each %remoteglotconf::engine_config) { - uciprint($engine, "setoption name $key value $value"); -} +setoptions($engine, \%remoteglotconf::engine_config); uciprint($engine, "ucinewgame"); if (defined($engine2)) { - uciprint($engine2, "setoption name UCI_AnalyseMode value true"); - uciprint($engine2, "setoption name Analysis Contempt value Off"); - while (my ($key, $value) = each %remoteglotconf::engine2_config) { - uciprint($engine2, "setoption name $key value $value"); - } + setoptions($engine2, \%remoteglotconf::engine2_config); uciprint($engine2, "setoption name MultiPV value 500"); uciprint($engine2, "ucinewgame"); } @@ -1475,3 +1467,16 @@ sub parse_uci_move { my $promo = substr($move, 4, 1); return ($from_row, $from_col, $to_row, $to_col, $promo); } + +sub setoptions { + my ($engine, $config) = @_; + uciprint($engine, "setoption name UCI_AnalyseMode value true"); + uciprint($engine, "setoption name Analysis Contempt value Off"); + if (exists($config->{'Threads'})) { # Threads first, because clearing hash can be multithreaded then. + uciprint($engine, "setoption name Threads value " . $config->{'Threads'}); + } + while (my ($key, $value) = each %$config) { + next if $key eq 'Threads'; + uciprint($engine, "setoption name $key value $value"); + } +}