]> git.sesse.net Git - remoteglot/commitdiff
Set Threads before the other options, so that setting up the hash is faster.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 27 Dec 2018 18:06:08 +0000 (19:06 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 27 Dec 2018 18:06:08 +0000 (19:06 +0100)
remoteglot.pl

index c86eedee530e2a1e879e8b413aa2ceb524a1c551..7220412d14a03e022d7c50f9f8e6abf096a15e98 100755 (executable)
@@ -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");
+       }
+}