10 ECO::unpersist("../book/openings.txt");
13 my $fen = $cgi->param('fen');
14 my $pos = Position->from_fen($fen);
15 my $hex = unpack('H*', $pos->bitpacked_fen);
16 open my $fh, "-|", "../book/binlookup", "../book/open.mtbl", $hex
17 or die "../book/binlookup: $!";
24 my ($move, $white, $draw, $black, $opening_num, $white_avg_elo, $black_avg_elo) = split;
30 white_avg_elo => $white_avg_elo * 1,
31 black_avg_elo => $black_avg_elo * 1
33 $opening = $ECO::openings[$opening_num];
37 @moves = sort { num($b) <=> num($a) } @moves;
39 print $cgi->header(-type=>'application/json');
40 print JSON::XS::encode_json({ moves => \@moves, opening => $opening });
44 return $x->{'white'} + $x->{'draw'} + $x->{'black'};