merged
authorOleksandr Gavenko <gavenkoa@gmail.com>
Fri, 26 Sep 2014 09:53:50 +0300
changeset 150 cab72d83a6e6
parent 149 2839f8227a38 (current diff)
parent 145 bf3d47ecd0dd (diff)
child 151 bb5994be7eda
merged
board.js
--- a/board.js	Fri Sep 26 02:21:28 2014 +0300
+++ b/board.js	Fri Sep 26 09:53:50 2014 +0300
@@ -34,6 +34,20 @@
         && from[8] === to[8] && from[9] === to[9] && from[10] === to[10] && from[11] === to[11]
         && from[13] === to[13] && from[14] === to[14];
 }
+BoardArr.prototype.compress = function() {
+    var brd = this.brd;
+    var h1 = 0;
+    for (var j = 0; j < 4; j++)
+        h1 = (h1 << 4) | brd[0][j];
+    for (var j = 0; j < 4; j++)
+        h1 = (h1 << 4) | brd[1][j];
+    var h2 = 0;
+    for (var j = 0; j < 4; j++)
+        h2 = (h2 << 4) | brd[2][j];
+    for (var j = 0; j < 4; j++)
+        h2 = (h2 << 4) | brd[3][j];
+    return [h1, h2];
+}
 /* Return and optionally fill 2d board.
  * Doesn't designed to be efficient. */
 BoardArr.prototype.exportTo = function(brd) {