+var choose_move = function(idx) {
+ chosen_index = idx;
+ var chosen = candidate_moves[chosen_index];
+ $("#compmove").text(chosen['move']);
+ $("#compfraction").text((100.0 * chosen['fraction']).toFixed(1) + "%");
+ if (candidate_moves.length == 1) {
+ $("#comprank").text("only candidate move");
+ } else {
+ $("#comprank").text(format_ordinal(chosen_index + 1) + " out of " + candidate_moves.length + " candidate moves, j/k to switch");
+ }
+ make_move(chosen['move']);
+}
+
+var prev_variant = function() {
+ if (chosen_index !== null) {
+ --move_override;
+ choose_move((chosen_index + candidate_moves.length - 1) % candidate_moves.length);
+ }
+}
+
+var next_variant = function() {
+ if (chosen_index !== null) {
+ --move_override;
+ choose_move((chosen_index + 1) % candidate_moves.length);
+ }
+}
+