]> git.sesse.net Git - remoteglot-book/commitdiff
Small cleanup.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 29 May 2016 22:14:26 +0000 (00:14 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 29 May 2016 22:14:26 +0000 (00:14 +0200)
www/js/book.js

index 30a5677d95b2aca3efa64627c0080631a1e0cb98..2cbbcec6dc00fe1df7a2439c6d845c670373dddc 100644 (file)
@@ -121,7 +121,7 @@ var find_last_move_score = function() {
                        ";includetransp=0"
        }).done(function(data, textstatus, xhr) {
                var moves = data['moves'];
-               var root_move = sort_moves_by_common(moves, data);
+               var root_move = sort_move_by_frequency(moves, data);
                var your_move, your_index;
 
                for (var i = 0; i < moves.length; ++i) {
@@ -131,7 +131,6 @@ var find_last_move_score = function() {
                                your_index = i;
                        }
                }
-               moves.sort(function(a, b) { return b['num'] - a['num'] });
 
                if (your_move) {
                        $("#yourfraction").text(format_fraction(your_move['fraction']));
@@ -167,7 +166,7 @@ var find_computer_move = function() {
                var candidate_moves = [];
 
                var moves = data['moves'];
-               var root_move = sort_moves_by_common(moves, data);
+               var root_move = sort_move_by_frequency(moves, data);
 
                var practice_minimum_move_fraction;
                if (move_override > 20) {
@@ -201,7 +200,7 @@ var find_computer_move = function() {
 
 // Add deried data and then sort moves to get the most common ones (in-place).
 // Remove the root mode and return it. Currently usable for practice mode only!
-var sort_moves_by_common = function(moves, data)
+var sort_move_by_frequency = function(moves, data)
 {
        var total_num = find_total_games(moves);
        var root_move;