]> git.sesse.net Git - remoteglot/commitdiff
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 fc812976ef7b6cf79cedf9ac1a66515bedef7dc7..c4518fc1c8837fa61285ed6de36e901c8a4ff550 100755 (executable)
@@ -258,10 +258,19 @@ sub parse_infos {
 
        my $info = $engine->{'info'};
 
 
        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') {
        while (scalar @x > 0) {
                if ($x[0] =~ 'multipv') {
+                       # Dealt with above
+                       shift @x;
                        shift @x;
                        shift @x;
-                       $mpv = shift @x;
                        next;
                }
                if ($x[0] =~ /^(currmove|currmovenumber|cpuload)$/) {
                        next;
                }
                if ($x[0] =~ /^(currmove|currmovenumber|cpuload)$/) {