X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=5e1e94aa99cdf28cfbe1909b5f84a5d2817ef689;hp=1b06f05f88c2f29ff65c24ba011817afbd65acec;hb=ddc3383ef834627f59f3dd810e78040f6de2105b;hpb=7c106ea7120a60e4e71a59bb679fa9ce09fc241a diff --git a/remoteglot.pl b/remoteglot.pl index 1b06f05..5e1e94a 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -121,7 +121,7 @@ my $ev1 = AnyEvent->io( } ); if (defined($remoteglotconf::target)) { - if ($remoteglotconf::target =~ /^http:/) { + if ($remoteglotconf::target =~ /^https?:/) { fetch_pgn($remoteglotconf::target); } else { $t->cmd("observe $remoteglotconf::target"); @@ -526,7 +526,7 @@ sub prettyprint_pv_no_cache { sub prettyprint_pv { my ($pos, @pvs) = @_; - my $cachekey = join('', @pvs); + my $cachekey = $pos->{'fen'} . join('', @pvs); if (exists($pos->{'prettyprint_cache'}{$cachekey})) { return @{$pos->{'prettyprint_cache'}{$cachekey}}; } else { @@ -536,6 +536,8 @@ sub prettyprint_pv { } } +my %tbprobe_cache = (); + sub complete_using_tbprobe { my ($pos, $info, $mpv) = @_; @@ -553,10 +555,10 @@ sub complete_using_tbprobe { # Run through the PV until we are at a 6-man position. # TODO: We could in theory only have 5-man data. my @pv = @{$info->{'pv' . $mpv}}; - my $key = join('', @pv); + my $key = $pos->fen() . " " . join('', @pv); my @moves = (); - if (exists($pos->{'tbprobe_cache'}{$key})) { - @moves = @{$pos->{'tbprobe_cache'}{$key}}; + if (exists($tbprobe_cache{$key})) { + @moves = @{$tbprobe_cache{$key}}; } else { if ($mpv ne '') { # Force doing at least one move of the PV. @@ -587,7 +589,7 @@ sub complete_using_tbprobe { push @moves, $uci_move; } - $pos->{'tbprobe_cache'}{$key} = \@moves; + $tbprobe_cache{$key} = \@moves; } $info->{'pv' . $mpv} = \@moves; @@ -1088,7 +1090,7 @@ sub score_digest { if ($score == 0 && $info->{'tablebase'}) { return ['d', undef]; } else { - return ['cp', $score]; + return ['cp', int($score)]; } } }