board.js
changeset 161 ddc36c6cc097
parent 154 c6d9b84d9391
child 162 f2c55c5744ab
equal deleted inserted replaced
160:93c44d730198 161:ddc36c6cc097
   913         this.brd = { aa: 0, ab: 0, ac: 0, ad: 0,
   913         this.brd = { aa: 0, ab: 0, ac: 0, ad: 0,
   914                      ba: 0, bb: 0, bc: 0, bd: 0,
   914                      ba: 0, bb: 0, bc: 0, bd: 0,
   915                      ca: 0, cb: 0, cc: 0, cd: 0,
   915                      ca: 0, cb: 0, cc: 0, cd: 0,
   916                      da: 0, db: 0, dc: 0, dd: 0 };
   916                      da: 0, db: 0, dc: 0, dd: 0 };
   917 }
   917 }
   918 BoardObj.arrMap = [["aa", "ab", "ac", "ad"], ["ba", "bb", "bc", "bd"], ["ca", "cb", "cc", "cd"], ["da", "db", "dc", "dd"]];
   918 BoardObj.dim2Map = [["aa", "ab", "ac", "ad"], ["ba", "bb", "bc", "bd"], ["ca", "cb", "cc", "cd"], ["da", "db", "dc", "dd"]];
   919 /** Get [i][j] element. */
   919 /** Get [i][j] element. */
   920 BoardObj.prototype.get = function(i, j) {
   920 BoardObj.prototype.get = function(i, j) {
   921     return this.brd[BoardObj.arrMap[i][j]];
   921     return this.brd[BoardObj.dim2Map[i][j]];
   922 }
   922 }
   923 /** Set [i][j] element. */
   923 /** Set [i][j] element. */
   924 BoardObj.prototype.set = function(i, j, val) {
   924 BoardObj.prototype.set = function(i, j, val) {
   925     this.brd[BoardObj.arrMap[i][j]] = val;
   925     this.brd[BoardObj.dim2Map[i][j]] = val;
   926 }
   926 }
   927 /* Return and optionally fill 2d board.
   927 /* Return and optionally fill 2d board.
   928  * Doesn't designed to be efficient. */
   928  * Doesn't designed to be efficient. */
   929 BoardObj.prototype.exportTo = function(brd) {
   929 BoardObj.prototype.exportTo = function(brd) {
   930     brd = brd || [[],[],[],[]];
   930     brd = brd || [[],[],[],[]];