From 6f3012bcc5128d52ba23058dcff0cb7f759eaf1f Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 20 Dec 2014 18:27:01 +0100 Subject: [PATCH] Show an adjusted human index instead of the raw percentage of computer games. --- www/js/book.js | 7 +++++-- www/opening-stats.pl | 14 +++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/www/js/book.js b/www/js/book.js index cc948fd..c6290f1 100644 --- a/www/js/book.js +++ b/www/js/book.js @@ -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; diff --git a/www/opening-stats.pl b/www/opening-stats.pl index aea5db8..ad578a0 100755 --- a/www/opening-stats.pl +++ b/www/opening-stats.pl @@ -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" -- 2.39.2