--- a/board.js Sun Sep 07 14:16:26 2014 +0300
+++ b/board.js Sun Sep 07 23:30:11 2014 +0300
@@ -59,6 +59,13 @@
BoardArr2d.prototype.set = function(i, j, val) {
this.brd[i][j] = val;
}
+BoardArr2d.prototype.equals = function(brd) {
+ for (var i = 0; i < 4; i++)
+ for (var j = 0; j < 4; j++)
+ if (this.brd[i][j] !== brd.brd[i][j])
+ return false;
+ return true;
+}
/* Return and optionally fill 2d board. */
BoardArr2d.prototype.exportTo = function(brd) {
brd = brd || [[],[],[],[]];
@@ -85,6 +92,15 @@
}
return score;
}
+BoardArr2d.prototype.max = function() {
+ var max = 0;
+ for (var i = 0; i < 4; i++) {
+ for (var j = 0; j < 4; j++) {
+ max = Math.max(max, this.brd[i][j]);
+ }
+ }
+ return max;
+}
BoardArr2d.prototype.canRight = function() {
for (var i = 0; i < 4; i++) {