--- a/2048.html Wed Sep 17 19:59:32 2014 +0300
+++ b/2048.html Wed Sep 17 20:14:55 2014 +0300
@@ -633,7 +633,7 @@
// Reports and statistic.
function statistic() {
- var stat = [];
+ var stats = [];
var cnt = parseInt(document.getElementById('stat-count-limit').value);
if (isNaN(cnt) || !isFinite(cnt) || cnt < 1)
cnt = 100;
@@ -643,11 +643,12 @@
else
tsLimit = 1000 * tsLimit;
var safeBdr = board.create();
- var tsFrom = new Date().getTime();
+ var tsLimitFrom = new Date().getTime();
for (var i = 0; i < cnt; i++) {
var turn = 0;
var brd = board.create();
board.putRandom(brd);
+ var tsFrom = new Date().getTime();
while (!board.gameOver(brd)) {
board.copy(brd, safeBdr);
var move = ui.ai.current.analyse(safeBdr);
@@ -664,11 +665,14 @@
turn++;
}
var tsTo = new Date().getTime();
- stat.push(board.score(brd));
- if (tsTo - tsFrom >= tsLimit)
+ var stat = board.score(brd);
+ stat.turn = turn;
+ stat.ts = tsTo - tsFrom;
+ stats.push(stat);
+ if (tsTo - tsLimitFrom >= tsLimit)
break;
}
- console.log(stat);
+ console.log(stats);
}
var statisticBtn = document.getElementById('statistic');