Deal with multipv not being the first element on the info line (e.g. for Stockfish).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 17 Nov 2013 13:33:59 +0000 (14:33 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 17 Nov 2013 13:33:59 +0000 (14:33 +0100)
remoteglot.pl

index fc81297..c4518fc 100755 (executable)
@@ -258,10 +258,19 @@ sub parse_infos {
 
        my $info = $engine->{'info'};
 
+       # Search for "multipv" first of all, since e.g. Stockfish doesn't put it first.
+       for my $i (0..$#x - 1) {
+               if ($x[$i] =~ 'multipv') {
+                       $mpv = $x[$i + 1];
+                       next;
+               }
+       }
+
        while (scalar @x > 0) {
                if ($x[0] =~ 'multipv') {
+                       # Dealt with above
+                       shift @x;
                        shift @x;
-                       $mpv = shift @x;
                        next;
                }
                if ($x[0] =~ /^(currmove|currmovenumber|cpuload)$/) {