X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=56554a6d6b5589a65c13764a7d9ab0c5740bf624;hp=9742a5a09a8686e93270290961ac4fa3704a2dae;hb=e3d784bc499b0ffc1678cbadebb06ef415e12c61;hpb=9dbe80127346dce1003c423a118321a3eb1a0b59 diff --git a/remoteglot.pl b/remoteglot.pl index 9742a5a..56554a6 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -480,6 +480,8 @@ sub parse_infos { } } + my $prev_depth = $info->{'depth1'} // $info->{'depth'}; + while (scalar @x > 0) { if ($x[0] eq 'multipv') { # Dealt with above @@ -534,6 +536,14 @@ sub parse_infos { die "Unknown info '" . join(',', @x) . "'"; } + + my $now_depth = $info->{'depth1'} // $info->{'depth'}; + if (defined($prev_depth) && POSIX::floor($now_depth / 10) > POSIX::floor($prev_depth / 10)) { + my $d = POSIX::floor($now_depth / 10) * 10; # In case we skipped some. + my $cp = $info->{'score_cp1'} // $info->{'score_cp'}; + my $mate = $info->{'score_mate1'} // $info->{'score_mate'}; + push @{$info->{'lowdepth'}}, [ $d, $cp, $mate ]; + } } sub parse_ids { @@ -944,6 +954,13 @@ sub output_json { $json->{'tablebase'} = $info->{'tablebase'}; $json->{'pv'} = [ prettyprint_pv($pos_calculating, @{$info->{'pv'}}) ]; + $json->{'lowdepth'} = {}; + if (exists($info->{'lowdepth'})) { + for my $ld (@{$info->{'lowdepth'}}) { + $json->{'lowdepth'}{$ld->[0]} = score_digest_inner($ld->[1], $ld->[2], undef, 0, $pos_calculating); + } + } + my %refutation_lines = (); my @refutation_lines = (); if (defined($engine2)) { @@ -1172,29 +1189,43 @@ sub short_score { # (with side-to-play information) score_sort_key. sub score_digest { my ($info, $pos, $mpv) = @_; + return score_digest_inner( + $info->{'score_cp' . $mpv}, + $info->{'score_mate' . $mpv}, + $info->{'splicepos' . $mpv}, + $info->{'tablebase'}, + $pos); +} - if (defined($info->{'score_mate' . $mpv})) { - my $mate = $info->{'score_mate' . $mpv}; +sub score_digest_inner { + my ($score, $mate, $sp, $tablebase, $pos) = @_; + if (defined($mate)) { if ($pos->{'toplay'} eq 'B') { $mate = -$mate; } - if (exists($info->{'splicepos' . $mpv})) { - my $sp = $info->{'splicepos' . $mpv}; - if ($mate < 0) { - return ['tb', -$sp]; + if (defined($sp)) { + if ($mate > 0) { + return ['T', $sp]; } else { - return ['tb', $sp]; + return ['t', $sp]; } } else { - return ['m', $mate]; + if ($mate > 0) { + return ['M', $mate]; + } elsif ($mate < 0) { + return ['m', -$mate]; + } elsif ($pos->{'toplay'} eq 'B') { + return ['M', 0]; + } else { + return ['m', 0]; + } } } else { - if (exists($info->{'score_cp' . $mpv})) { - my $score = $info->{'score_cp' . $mpv}; + if (defined($score)) { if ($pos->{'toplay'} eq 'B') { $score = -$score; } - if ($score == 0 && $info->{'tablebase'}) { + if ($score == 0 && $tablebase) { return ['d', undef]; } else { return ['cp', int($score)]; @@ -1216,9 +1247,9 @@ sub long_score { if (exists($info->{'splicepos' . $mpv})) { my $sp = $info->{'splicepos' . $mpv}; if ($mate > 0) { - return sprintf "White wins in %u/%u", int(($sp + 1) * 0.5), $sp; + return sprintf "White wins in %u", int(($sp + 1) * 0.5); } else { - return sprintf "Black wins in %u/%u", int(($sp + 1) * 0.5), $sp; + return sprintf "Black wins in %u", int(($sp + 1) * 0.5); } } else { if ($mate > 0) {