]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Enable the tbprobe cache.
[remoteglot] / remoteglot.pl
index e021c664894e4fb0a077f82ec81d79abff6fc61b..1b06f05f88c2f29ff65c24ba011817afbd65acec 100755 (executable)
@@ -556,8 +556,15 @@ sub complete_using_tbprobe {
        my $key = join('', @pv);
        my @moves = ();
        if (exists($pos->{'tbprobe_cache'}{$key})) {
-               @moves = $pos->{'tbprobe_cache'}{$key};
+               @moves = @{$pos->{'tbprobe_cache'}{$key}};
        } else {
+               if ($mpv ne '') {
+                       # Force doing at least one move of the PV.
+                       my $move = shift @pv;
+                       push @moves, $move;
+                       $pos = $pos->make_move(parse_uci_move($move));
+               }
+
                while ($pos->num_pieces() > 6 && $#pv > -1) {
                        my $move = shift @pv;
                        push @moves, $move;
@@ -579,6 +586,8 @@ sub complete_using_tbprobe {
                        ($pos, $uci_move) = $pos->make_pretty_move($move);
                        push @moves, $uci_move;
                }
+
+               $pos->{'tbprobe_cache'}{$key} = \@moves;
        }
 
        $info->{'pv' . $mpv} = \@moves;