]> git.sesse.net Git - remoteglot-book/commitdiff
Show an adjusted human index instead of the raw percentage of computer games.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 20 Dec 2014 17:27:01 +0000 (18:27 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 20 Dec 2014 17:27:01 +0000 (18:27 +0100)
www/js/book.js
www/opening-stats.pl

index cc948fdc3b2152c50014b7eb8dcaee63e818d1b3..c6290f17cd13ff6dcaea29928a59834a8e995fe5 100644 (file)
@@ -93,7 +93,7 @@ var headings = [
        [ "Games", TYPE_INTEGER ],
        [ "%", TYPE_RATIO ],
        [ "CGames", TYPE_INTEGER ],
-       [ "Comp%", TYPE_RATIO ],
+       [ "Hum", TYPE_RATIO ],
        [ "Win%", TYPE_RATIO ],
        [ "WWin", TYPE_INTEGER ],
        [ "%WW", TYPE_RATIO ],
@@ -177,7 +177,10 @@ var show_lines = function(data, game) {
                line.push(num);  // N.
                line.push(num / total_num);  // %.
                line.push(computer);  // CGames.
-               line.push(computer / num);  // Comp%.
+
+               // Adjust so that the human index is 50% overall.
+               var exp = Math.log(0.5) / Math.log(data['computer_games'] / data['total_games']);
+               line.push(1.0 - Math.pow(computer / num, exp));  // Hum.
 
                // Win%.
                var white_win_ratio = (white + 0.5 * draw) / num;
index aea5db863bdd6139c5b47ad69d576418d911a1b4..ad578a0b7db95747cfcba67b80bc81ede6eca190 100755 (executable)
@@ -68,8 +68,20 @@ for my $move (@{$root_aux_data->{'moves'}}) {
        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"