]> git.sesse.net Git - remoteglot/commitdiff
Handle the "single MultiPV" information sent by Toga II better.
authorSteinar H. Gunderson <sesse@debian.org>
Sat, 30 Jun 2007 17:10:07 +0000 (19:10 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Sat, 30 Jun 2007 17:10:07 +0000 (19:10 +0200)
remoteglot.pl

index d457e9297eb3cb6c2135092db68cae7d2fd99eb5..24ce2e75106a10ce53c539cdc650b115efa7bb4e 100755 (executable)
@@ -472,7 +472,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 +501,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'};