X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=opening-stats.pl;h=def0f8f67fb40626b1928f0e6ff189ee25366974;hb=74f1261e4067cbc1b743b329ed2d419aee735cbf;hp=24fdc99c1e31459d46c468df1f4f9469ba96af56;hpb=f95dfda2d14615a9816ba1abb32bd240a470e228;p=remoteglot-book diff --git a/opening-stats.pl b/opening-stats.pl index 24fdc99..def0f8f 100755 --- a/opening-stats.pl +++ b/opening-stats.pl @@ -9,26 +9,28 @@ use IPC::Open2; my $cgi = CGI->new; my $fen = $ARGV[0]; +my $filter_prev_pos_hash = $ARGV[1] // 0; my ($chld_out, $chld_in); my $pid = IPC::Open2::open2($chld_out, $chld_in, "./binlookup", "./open.mtbl", "40"); # Root position. my $pos = Position->from_fen($fen); -my $hex = unpack('H*', $pos->bitpacked_fen); -print $chld_in $hex, "\n"; +my $bpfen_hex = unpack('H*', $pos->bitpacked_fen); +my $prev_pos_hash_hex = unpack('H*', pack('S', $filter_prev_pos_hash)); +print $chld_in $bpfen_hex, "\n", $prev_pos_hash_hex, "\n"; chomp (my $line = <$chld_out>); # Root position hash. print $line, "\n"; -chomp (my $line = <$chld_out>); # Actual stats. +chomp ($line = <$chld_out>); # Actual stats. print $line, "\n"; -my ($white, $draw, $black, $opening_num, $white_avg_elo, $black_avg_elo, $num_elo, $timestamp, $pgn_file_number, $pgn_start_position, @moves) = split / /, $line; +my ($white, $draw, $black, $computer, $opening_num, $white_avg_elo, $black_avg_elo, $num_elo, $timestamp, $pgn_file_number, $pgn_start_position, @moves) = split / /, $line; # Explore one move out. for my $move (@moves) { my ($np, $uci_move) = $pos->make_pretty_move($move); my $hex = unpack('H*', $np->bitpacked_fen); - print $chld_in $hex, "\n"; + print $chld_in $hex, "\n\n"; my $line = <$chld_out>; # Ignore position hash. $line = <$chld_out>; print "$move $line";