push @json_moves, $json_pos;
}
+# Get stats for the root position, for the human index.
+my $start_pos = Position->start_pos;
+my ($json_start_pos, undef) = get_json_move($start_pos, 0, $chld_in, $chld_out);
+my $total_games = $json_start_pos->{'white'} + $json_start_pos->{'draw'} + $json_start_pos->{'black'};
+my $computer_games = $json_start_pos->{'computer'} * 1;
+
print $cgi->header(-type=>'application/json');
-print JSON::XS::encode_json({ moves => \@json_moves, opening => $opening, root_game => $root_game });
+print JSON::XS::encode_json({
+ moves => \@json_moves,
+ opening => $opening,
+ root_game => $root_game,
+ total_games => $total_games,
+ computer_games => $computer_games
+});
sub read_openings {
open my $fh, "../openings.txt"