Skip to content

Instantly share code, notes, and snippets.

@Bersam
Last active August 29, 2015 13:57
Show Gist options
  • Save Bersam/9533909 to your computer and use it in GitHub Desktop.
Save Bersam/9533909 to your computer and use it in GitHub Desktop.
function getGridString(grid){
var a = "";
for(var i=0; i<=3; i++){
for(var j=0; j<=3; j++){
if(grid[j][i]){
a += grid[j][i].value.toString();
} else {
a += "0";
}
}
}
return a;
}
var grid = getGridString(gameManager.grid.cells);
var up=0, down=0, right=0;
for(var i=1;i<=300;i++){
grid = getGridString(gameManager.grid.cells);
gameManager.move(0);
gameManager.move(3);
up++;
if(grid == getGridString(gameManager.grid.cells)){
gameManager.move(2);
down++;
if(grid == getGridString(gameManager.grid.cells)){
gameManager.move(1);
right++;
}
}
if(gameManager.over){
break;
}
}
var score = gameManager.score;
console.log("score:"+score);
console.log("up:"+up);
console.log("down:"+down);
console.log("right:"+right);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment