board.js
changeset 149 2839f8227a38
parent 148 93c122e0ea90
child 150 cab72d83a6e6
equal deleted inserted replaced
148:93c122e0ea90 149:2839f8227a38
    64         if (v > 1)
    64         if (v > 1)
    65             score += (v-1)*(1 << v);
    65             score += (v-1)*(1 << v);
    66     }
    66     }
    67     return score;
    67     return score;
    68 }
    68 }
    69 BoardArr.prototype.max = function() {
    69 BoardArr.prototype.maxVal = function() {
    70     var max = 0;
    70     var max = 0;
    71     for (var i = 0; i < 4; i++) {
    71     for (var i = 0; i < 4; i++) {
    72         for (var j = 0; j < 4; j++) {
    72         for (var j = 0; j < 4; j++) {
    73             max = Math.max(max, this.brd[i][j]);
    73             max = Math.max(max, this.brd[i][j]);
    74         }
    74         }
   173                 score += (v-1)*(1 << v);
   173                 score += (v-1)*(1 << v);
   174         }
   174         }
   175     }
   175     }
   176     return score;
   176     return score;
   177 }
   177 }
   178 BoardArr2d.prototype.max = function() {
   178 BoardArr2d.prototype.maxVal = function() {
   179     var max = 0;
   179     var max = 0;
   180     for (var i = 0; i < 4; i++) {
   180     for (var i = 0; i < 4; i++) {
   181         for (var j = 0; j < 4; j++) {
   181         for (var j = 0; j < 4; j++) {
   182             max = Math.max(max, this.brd[i][j]);
   182             max = Math.max(max, this.brd[i][j]);
   183         }
   183         }
   902     score += lookup[brd.db];
   902     score += lookup[brd.db];
   903     score += lookup[brd.dc];
   903     score += lookup[brd.dc];
   904     score += lookup[brd.dd];
   904     score += lookup[brd.dd];
   905     return score;
   905     return score;
   906 }
   906 }
   907 BoardObj.prototype.max = function() {
   907 BoardObj.prototype.maxVal = function() {
   908     var brd = this.brd;
   908     var brd = this.brd;
   909     var max = brd.aa;
   909     var max = brd.aa;
   910     max = Math.max(max, brd.ab);
   910     max = Math.max(max, brd.ab);
   911     max = Math.max(max, brd.ac);
   911     max = Math.max(max, brd.ac);
   912     max = Math.max(max, brd.ad);
   912     max = Math.max(max, brd.ad);