X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=www%2Fjs%2Fbook.js;h=0cc516f525db5944d36c19640e32d2878e597cff;hp=bed05c1de71c8011c197842597c81fa73a27f125;hb=4a29d0aca2c7a3941b2e0e9d8188707ec6d1e921;hpb=3a650d866c5e5792146f498cb6eaae7517ace1d3 diff --git a/www/js/book.js b/www/js/book.js index bed05c1..0cc516f 100644 --- a/www/js/book.js +++ b/www/js/book.js @@ -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).