2048.html
changeset 69 cbdfc1072009
parent 68 f8d310e3aecf
child 70 01076b56feae
--- a/2048.html	Wed Sep 17 20:14:55 2014 +0300
+++ b/2048.html	Wed Sep 17 20:36:40 2014 +0300
@@ -672,7 +672,32 @@
         if (tsTo - tsLimitFrom >= tsLimit)
           break;
       }
-      console.log(stats);
+      var histo = {};
+      for (i = stats.length-1; i >= 0; i--) {
+        var stat = stats[i];
+        if ( ! histo[stat.max])
+          histo[stat.max] = { n: 0, minSpeed: Infinity, meanSpeed: 0, maxSpeed: 0, minTurn: Infinity, meanTurn: 0, maxTurn: 0, minScore: Infinity, meanScore: 0, maxScore: 0 };
+        var row = histo[stat.max];
+        row.n++;
+        var speed = (stat.turn * 1000.0) / stat.ts;
+        row.minSpeed = Math.min(row.minSpeed, speed);
+        row.meanSpeed += speed;
+        row.minSpeed = Math.max(row.minSpeed, speed);
+        row.minTurn = Math.min(row.minTurn, stat.turn);
+        row.meanTurn += stat.turn;
+        row.maxTurn = Math.max(row.minTurn, stat.turn);
+        row.minScore = Math.min(row.minScore, stat.score);
+        row.meanScore += stat.score;
+        row.maxScore = Math.max(row.minScore, stat.score);
+      }
+      for (var i in histo) {
+        var row = histo[i];
+        var n = row.n;
+        row.meanSpeed = row.meanSpeed / n;
+        row.meanTurn = row.meanTurn / n;
+        row.meanScore = row.meanScore / n;
+      }
+      console.log(histo);
     }
 
     var statisticBtn = document.getElementById('statistic');