]> git.sesse.net Git - remoteglot/commitdiff
Add more columns, and hide Elo variables if we have less than 10 samples.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 9 Dec 2014 23:28:54 +0000 (00:28 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 9 Dec 2014 23:28:54 +0000 (00:28 +0100)
book/binlookup.cpp
www/book.html
www/js/book.js
www/opening-stats.pl

index 363e8dc5e8dbe2c8b4e46bce3ebf8dec8085367d..5b5fd40f6101cfd29634506294dc03b8ffc7d719 100644 (file)
@@ -36,9 +36,10 @@ int main(int argc, char **argv)
        while (mtbl_iter_next(it, &key, &len_key, &val, &len_val)) {
                string move((char *)(key + prefix_len), len_key - prefix_len);
                const Count* c = (Count *)val;
-               printf("%s %d %d %d %d %f %f\n", move.c_str(),
+               printf("%s %d %d %d %d %f %f %d\n", move.c_str(),
                        c->white, c->draw, c->black, c->opening_num,
                        float(c->sum_white_elo) / c->num_elo,
-                       float(c->sum_black_elo) / c->num_elo);
+                       float(c->sum_black_elo) / c->num_elo,
+                       c->num_elo);
        }
 }
index 8dcc6e427a3f08bf6c65054c7370b57bc7fa6ee9..5f71296fc20a2335b799eef3663b24e3dcd76fd7 100644 (file)
         <th>Games</th>
         <th>%</th>
         <th>Win%</th>
-        <th>WElo</th>
-        <th>BElo</th>
+        <th>WWin</th>
+        <th>%WW</th>
+        <th>BWin</th>
+        <th>%BW</th>
+        <th>Draw</th>
+        <th>Draw%</th>
+        <th>AvWElo</th>
+        <th>AvBElo</th>
+        <th>EloVar</th>
         <th>AWin%</th>
         <!--<th class="winbars">
           <table><tr>
index bed05c1de71c8011c197842597c81fa73a27f125..0cc516f525db5944d36c19640e32d2878e597cff 100644 (file)
@@ -66,7 +66,7 @@ var show_lines = function(data, game) {
                move_td.appendChild(move_a);
                $(move_a).text(move['move']);
 
-               // #.
+               // N.
                var num = white + draw + black;
                add_td(tr, num);
 
@@ -78,16 +78,36 @@ var show_lines = function(data, game) {
                var win_ratio = (game.turn() == 'w') ? white_win_ratio : 1.0 - white_win_ratio;
                add_td(tr, ((100.0 * win_ratio).toFixed(1) + "%"));
 
-               // Elo.
-               add_td(tr, move['white_avg_elo'].toFixed(1));
-               add_td(tr, move['black_avg_elo'].toFixed(1));
-
-               // Win% corrected for Elo.
-               var win_elo = -400.0 * Math.log(1.0 / white_win_ratio - 1.0) / Math.LN10;
-               win_elo -= (move['white_avg_elo'] - move['black_avg_elo']);
-               white_win_ratio = 1.0 / (1.0 + Math.pow(10, win_elo / -400.0));
-               win_ratio = (game.turn() == 'w') ? white_win_ratio : 1.0 - white_win_ratio;
-               add_td(tr, ((100.0 * win_ratio).toFixed(1) + "%"));
+               // WWin and %WW.
+               add_td(tr, white);
+               add_td(tr, (100.0 * white / num).toFixed(1) + "%");
+
+               // BWin and %BW.
+               add_td(tr, black);
+               add_td(tr, (100.0 * black / num).toFixed(1) + "%");
+
+               // Draw and %Draw.
+               add_td(tr, draw);
+               add_td(tr, ((100.0 * draw / num).toFixed(1) + "%"));
+
+               if (move['num_elo'] >= 10) {
+                       // Elo.
+                       add_td(tr, move['white_avg_elo'].toFixed(1));
+                       add_td(tr, move['black_avg_elo'].toFixed(1));
+                       add_td(tr, (move['white_avg_elo'] - move['black_avg_elo']).toFixed(1));
+
+                       // Win% corrected for Elo.
+                       var win_elo = -400.0 * Math.log(1.0 / white_win_ratio - 1.0) / Math.LN10;
+                       win_elo -= (move['white_avg_elo'] - move['black_avg_elo']);
+                       white_win_ratio = 1.0 / (1.0 + Math.pow(10, win_elo / -400.0));
+                       win_ratio = (game.turn() == 'w') ? white_win_ratio : 1.0 - white_win_ratio;
+                       add_td(tr, ((100.0 * win_ratio).toFixed(1) + "%"));
+               } else {
+                       add_td(tr, "");
+                       add_td(tr, "");
+                       add_td(tr, "");
+                       add_td(tr, "");
+               }
 
                if (false) {
                        // Win bars (W/D/B).
index 3b2b2ff78c8f66b34a00336430e3482eec4eda0e..47bae771d4b3eb8b37ce46e9f242ff50e8765c40 100755 (executable)
@@ -21,14 +21,15 @@ my $opening;
 my @moves = ();
 while (<$fh>) {
        chomp;
-       my ($move, $white, $draw, $black, $opening_num, $white_avg_elo, $black_avg_elo) = split;
+       my ($move, $white, $draw, $black, $opening_num, $white_avg_elo, $black_avg_elo, $num_elo) = split;
        push @moves, {
                move => $move,
                white => $white * 1,
                draw => $draw * 1,
                black => $black * 1,
                white_avg_elo => $white_avg_elo * 1,
-               black_avg_elo => $black_avg_elo * 1
+               black_avg_elo => $black_avg_elo * 1,
+               num_elo => $num_elo * 1
        };
        $opening = $ECO::openings[$opening_num];
 }