From 5ee1c604d0b954b024626f72bd6813f379ee96c4 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 27 Dec 2018 19:06:08 +0100 Subject: [PATCH] Set Threads before the other options, so that setting up the hash is faster. --- remoteglot.pl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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"); + } +} -- 2.39.2