Renames.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Sep 2014 01:44:48 +0300
changeset 109 6d5a9d8b00be
parent 108 5f4985c2a4d4
child 110 e3a91b336976
Renames.
ai.js
--- a/ai.js	Sun Sep 21 01:16:27 2014 +0300
+++ b/ai.js	Mon Sep 22 01:44:48 2014 +0300
@@ -229,7 +229,7 @@
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
             nextScore = nextBrd.score();
-            var score = this.bestScore(nextBrd);
+            var score = this.evalFn(nextBrd);
             // console.log("dir: %o, prevScore: %o, nextScore: %o, maxScore: %o, score: %o", dir, prevScore, nextScore, maxScore, score);
             if (maxScore < score || (maxScore === score && prevScore < nextScore)) {
                 prevScore = nextScore;
@@ -240,7 +240,7 @@
     }
     return bestDir;
 }
-ai.DeepMaxScore.prototype.bestScore = function(brd, seenBrds) {
+ai.DeepMaxScore.prototype.evalFn = function(brd, seenBrds) {
     if (seenBrds) {
         for (var i = 0; i < seenBrds.length; i++)
             if (brd.equals(seenBrds[i]))
@@ -256,7 +256,7 @@
         if (brd[ai.dirs[i]](nextBrd)) {
             var score = nextBrd.score();
             if (score > currScore)
-                maxScore = Math.max(maxScore, this.bestScore(nextBrd, seenBrds));
+                maxScore = Math.max(maxScore, this.evalFn(nextBrd, seenBrds));
         }
     }
     return maxScore;
@@ -321,7 +321,7 @@
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
             nextScore = this.scoreCorner(nextBrd);
-            var score = this.bestScore(nextBrd);
+            var score = this.evalFn(nextBrd);
             // console.log("dir: %o, prevScore: %o, nextScore: %o, maxScore: %o, score: %o", dir, prevScore, nextScore, maxScore, score);
             if (maxScore < score || (maxScore === score && prevScore < nextScore)) {
                 prevScore = nextScore;
@@ -332,7 +332,7 @@
     }
     return bestDir;
 }
-ai.DeepMaxScoreCorner.prototype.bestScore = function(brd, seenBrds) {
+ai.DeepMaxScoreCorner.prototype.evalFn = function(brd, seenBrds) {
     if (seenBrds) {
         for (var i = 0; i < seenBrds.length; i++)
             if (brd.equals(seenBrds[i]))
@@ -348,7 +348,7 @@
         if (brd[ai.dirs[i]](nextBrd)) {
             var score = this.scoreEdge(nextBrd);
             if (score > currScore)
-                maxScore = Math.max(maxScore, this.bestScore(nextBrd, seenBrds));
+                maxScore = Math.max(maxScore, this.evalFn(nextBrd, seenBrds));
         }
     }
     return maxScore;
@@ -415,7 +415,7 @@
     for (var i = 0; i < ai.dirs.length; i++) {
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
-            var weight = this.recWeight(nextBrd, 1);
+            var weight = this.evalFn(nextBrd, 1);
             var ok = (weight - maxWeight) > this.cfg.weightPriority;
             if ( ! ok && maxWeight <= weight) {
                 nextScore = this.weight(nextBrd);
@@ -431,7 +431,7 @@
     this.cleanup();
     return bestDir;
 }
-ai.expectimax.prototype.recWeight = function(brd, depth) {
+ai.expectimax.prototype.evalFn = function(brd, depth) {
     if (depth >= this.cfg.depth)
         return this.weight(brd);
     if (this.cache[depth]) {
@@ -454,7 +454,7 @@
                 var n = 0, w = 0;
                 for (var diri = 0; diri < ai.dirs.length; diri++) {
                     if (randBoard[ai.dirs[diri]](nextBrd)) {
-                        w += this.recWeight(nextBrd, depth+1);
+                        w += this.evalFn(nextBrd, depth+1);
                         n++;
                     }
                 }
@@ -466,7 +466,7 @@
                     var n = 0, w = 0;
                     for (var diri = 0; diri < ai.dirs.length; diri++) {
                         if (randBoard[ai.dirs[diri]](nextBrd)) {
-                            w += this.recWeight(nextBrd, depth+1);
+                            w += this.evalFn(nextBrd, depth+1);
                             n++;
                         }
                     }