X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=remoteglot.pl;h=69ba997470827c689068c9909425471c3438257d;hb=070a7919758dca209075c4d9d5ba10fb7f62db36;hp=d457e9297eb3cb6c2135092db68cae7d2fd99eb5;hpb=0a8aa7b78bf6011452eceb6a3aeef3bf7017ae83;p=remoteglot diff --git a/remoteglot.pl b/remoteglot.pl index d457e92..69ba997 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -16,15 +16,17 @@ use Time::HiRes; use strict; use warnings; -$SIG{ALRM} = sub { output_screen(); }; - -$| = 1; - +# Configuration my $server = "freechess.org"; my $target = "Sesse"; # my $engine = "/usr/games/toga2"; my $engine = "wine Rybkav2.3.2a.mp.w32.exe"; +# Program starts here +$SIG{ALRM} = sub { output_screen(); }; + +$| = 1; + open(FICSLOG, ">ficslog.txt") or die "ficslog.txt: $!"; print FICSLOG "Log starting.\n"; @@ -56,7 +58,7 @@ uciprint("setoption name UCI_AnalyseMode value true"); uciprint("setoption name NalimovPath value c:\\nalimov"); uciprint("setoption name NalimovUsage value Rarely"); uciprint("setoption name Hash value 1024"); -# uciprint("setoption name MultiPV value 3"); +uciprint("setoption name MultiPV value 3"); # uciprint("setoption name Contempt value 1000"); # uciprint("setoption name Outlook value Ultra Optimistic"); uciprint("ucinewgame"); @@ -99,6 +101,15 @@ while (1) { uciprint("stop"); uciprint("position fen $fen"); uciprint("go infinite"); + + # + # Output a command every move to note that we're + # still paying attention -- this is a good tradeoff, + # since if no move has happened in the last half + # hour, the analysis/relay has most likely stopped + # and we should stop hogging server resources. + # + $t->cmd("date"); } #print "FICS: [$line]\n"; $sleep = 0; @@ -472,7 +483,7 @@ sub output_screen { return unless (exists($ficsinfo{'board'})); - if (exists($uciinfo{'pv1'})) { + if (exists($uciinfo{'pv1'}) && exists($uciinfo{'pv2'})) { # multi-PV my $mpv = 1; while (exists($uciinfo{'pv' . $mpv})) { @@ -501,6 +512,19 @@ sub output_screen { ++$mpv; } } else { + # + # Some programs _always_ report MultiPV, even with only one PV. + # In this case, we simply use that data as if MultiPV was never + # specified. + # + if (exists($uciinfo{'pv1'})) { + for my $key qw(pv score_cp score_mate nodes nps depth seldepth tbhits) { + if (exists($uciinfo{$key . '1'}) && !exists($uciinfo{$key})) { + $uciinfo{$key} = $uciinfo{$key . '1'}; + } + } + } + # single-PV if (defined($uciinfo{'score_mate'})) { my $mate = $uciinfo{'score_mate'};