X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=dd913f6a6855b45263c043691a380da6514a2920;hp=4459015e7c8510de4bf79044480c5e4b88ad4214;hb=f19e1618521811dad0e260ff79645d7055b1b7b7;hpb=0966daf10b49c2d42bb5689a1d34a4e125144f48 diff --git a/remoteglot.pl b/remoteglot.pl index 4459015..dd913f6 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -105,6 +105,8 @@ EV::run; sub handle_uci { my ($engine, $line, $primary) = @_; + return if $line =~ /(upper|lower)bound/; + $line =~ s/ / /g; # Sometimes needed for Zappa Mexico print UCILOG localtime() . " $engine->{'tag'} <= $line\n"; if ($line =~ /^info/) { @@ -300,7 +302,7 @@ sub parse_infos { delete $info->{'score_cp' . $mpv}; delete $info->{'score_mate' . $mpv}; - while ($x[0] eq 'cp' || $x[0] eq 'mate' || $x[0] eq 'lowerbound' || $x[0] eq 'upperbound') { + while ($x[0] eq 'cp' || $x[0] eq 'mate') { if ($x[0] eq 'cp') { shift @x; $info->{'score_cp' . $mpv} = shift @x; @@ -633,11 +635,19 @@ sub score_sort_key { my ($info, $pos, $mpv, $invert) = @_; if (defined($info->{'score_mate' . $mpv})) { - if ($invert) { - return 99999 - $info->{'score_mate' . $mpv}; + my $mate = $info->{'score_mate' . $mpv}; + my $score; + if ($mate > 0) { + # Side to move mates + $mate = 99999 - $mate; } else { - return -(99999 - $info->{'score_mate' . $mpv}); + # Side to move is getting mated (note the double negative for $mate) + $mate = -99999 - $mate; + } + if ($invert) { + $score = -$score; } + return $score; } else { if (exists($info->{'score_cp' . $mpv})) { my $score = $info->{'score_cp' . $mpv};