X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fopening-stats.pl;h=a88b0a28b1ad3d28cdb7f9fbd43290711a94113e;hb=66abb549375189d50dc00c93071afa0cf19611b1;hp=0da6e0546f54e1b20382c0d39787cd9292c35df0;hpb=74f1261e4067cbc1b743b329ed2d419aee735cbf;p=remoteglot-book diff --git a/www/opening-stats.pl b/www/opening-stats.pl index 0da6e05..a88b0a2 100755 --- a/www/opening-stats.pl +++ b/www/opening-stats.pl @@ -48,6 +48,9 @@ eval { $root_game->{'eco'} = $pgn->eco; $root_game->{'moves'} = int(((scalar @{$pgn->moves}) + 1) / 2); }; +if ($@) { + print STDERR "Error while getting root move: $@\n"; +} # Explore one move out. my $white_left = $json_root_pos->{'white'}; @@ -128,6 +131,7 @@ sub read_root_pgn { or die "../pgnnames.txt: $!"; while (<$pgnnamesfh>) { chomp; + s/^comp://; push @pgnnames, $_; } close $pgnnamesfh; @@ -170,14 +174,14 @@ sub get_json_move { my ($white, $draw, $black, $computer, $opening_num, $white_sum_elo, $black_sum_elo, $num_elo, $timestamp, $pgn_file_number, $pgn_start_position, @moves) = split / /, $line; my $json_pos = { - white => $white, - draw => $draw, - black => $black, - computer => $computer, + white => int($white), + draw => int($draw), + black => int($black), + computer => int($computer), white_avg_elo => $num_elo == 0 ? undef : $white_sum_elo / $num_elo, black_avg_elo => $num_elo == 0 ? undef : $black_sum_elo / $num_elo, - num_elo => $num_elo, - opening_num => $opening_num, + num_elo => int($num_elo), + opening_num => $opening_num, # Keep as string. }; my $aux_data = { # Only relevant for the root. pos_hash => $pos_hash * 1,