board.js
changeset 57 94e1b2d0bd31
parent 22 b041338d7e88
child 93 c2bf15c3b80b
--- a/board.js	Thu Sep 11 20:01:40 2014 +0300
+++ b/board.js	Mon Sep 15 02:49:02 2014 +0300
@@ -1,10 +1,13 @@
+"use strict";
+
+/** @fileOverview Board engines with optimised primitives. */
 
 ////////////////////////////////////////////////////////////////
-// Board as linear array.
+/** Create board on linear array.
+ * Extract data from 'brd' if present.
+ * @param brd  2d array
+ * @constructor */
 ////////////////////////////////////////////////////////////////
-
-/* Create board on linear array.
- * Extract data from 'brd' (which is 2d array) if present. */
 function BoardArr(brd) {
     this.brd = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
     if (brd) {
@@ -13,11 +16,11 @@
                 this.brd[4*i + j] = brd[i][j];
     }
 }
-/* Doesn't designed to be efficient. */
+/** Get [i][j] element. */
 BoardArr.prototype.get = function(i, j) {
     return this.brd[4*i + j];
 }
-/* Doesn't designed to be efficient. */
+/** Set [i][j] element. */
 BoardArr.prototype.set = function(i, j, val) {
     this.brd[4*i + j] = val;
 }
@@ -40,11 +43,11 @@
 
 
 ////////////////////////////////////////////////////////////////
-// Board as 2d array.
+/** Create board on 2d array.
+ * Extract data from 'brd' if present.
+ * @param brd  2d array
+ * @constructor */
 ////////////////////////////////////////////////////////////////
-
-/* Create board on 2d array.
- * Extract data from brd (which is 2d array) if present. */
 function BoardArr2d(brd) {
     this.brd = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];
     if (brd) {
@@ -53,9 +56,11 @@
                 this.brd[i][j] = brd[i][j];
     }
 }
+/** Get [i][j] element. */
 BoardArr2d.prototype.get = function(i, j) {
     return this.brd[i][j];
 }
+/** Set [i][j] element. */
 BoardArr2d.prototype.set = function(i, j, val) {
     this.brd[i][j] = val;
 }
@@ -724,11 +729,11 @@
 
 
 ////////////////////////////////////////////////////////////////
-// Board as properties.
+/** Create board as properties of object.
+ * Extract data from 'brd' if present.
+ * @param brd  2d array
+ * @constructor */
 ////////////////////////////////////////////////////////////////
-
-/* Create board as properties of object.
- * Extract data from 'brd' (which is 2d array) if present. */
 function BoardObj(brd) {
     if (brd)
         this.brd = { aa: brd[0][0], ab: brd[0][1], ac: brd[0][2], ad: brd[0][3],
@@ -742,11 +747,11 @@
                      da: 0, db: 0, dc: 0, dd: 0 };
 }
 BoardObj.arrMap = [["aa", "ab", "ac", "ad"], ["ba", "bb", "bc", "bd"], ["ca", "cb", "cc", "cd"], ["da", "db", "dc", "dd"]];
-/* Doesn't designed to be efficient. */
+/** Get [i][j] element. */
 BoardObj.prototype.get = function(i, j) {
     return this.brd[BoardObj.arrMap[i][j]];
 }
-/* Doesn't designed to be efficient. */
+/** Set [i][j] element. */
 BoardObj.prototype.set = function(i, j, val) {
     this.brd[BoardObj.arrMap[i][j]] = val;
 }