+var calc_move_derived_data = function(move, total_num, data, is_white) {
+ var derived = {};
+ var white = move['white'];
+ var draw = move['draw'];
+ var black = move['black'];
+ var computer = move['computer'];
+
+ var num = white + draw + black;
+ derived['num'] = num;
+ derived['fraction'] = num / total_num;
+
+ // Adjust so that the human index is 50% overall.
+ var exp = Math.log(0.5) / Math.log(data['computer_games'] / data['total_games']);
+ derived['human_index'] = 1.0 - Math.pow(computer / num, exp);
+
+ // Win%.
+ var white_win_ratio = (white + 0.5 * draw) / num;
+ var win_ratio = is_white ? white_win_ratio : 1.0 - white_win_ratio;
+ derived['win_ratio'] = win_ratio;
+
+ if (move['num_elo'] >= 10) {
+ // 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 = is_white ? white_win_ratio : 1.0 - white_win_ratio;
+ derived['corrected_win_ratio'] = win_ratio;
+ }
+
+ return derived;
+};
+