move_hash[moves[i].san] = moves[i];
}
+ // History and PV take priority over the display lines.
+ for (var i = 0; i < 2; ++i) {
+ var line = display_lines[i];
+ var first_move = line.pretty_pv[line.start_display_move_num];
+ if (move_hash[first_move]) {
+ return move_hash[first_move];
+ }
+ }
+
var best_move = null;
var best_move_score = null;
}
var first_move = line['pv_pretty'][0];
if (move_hash[first_move]) {
- if (best_move_score === null || line['score_sort_key'] > best_move_score) {
+ var score = parseInt(line['score_sort_key'], 10);
+ if (best_move_score === null || score > best_move_score) {
best_move = move_hash[first_move];
- best_move_score = line['score_sort_key'];
+ best_move_score = score;
}
}
}