ai.js
changeset 148 93c122e0ea90
parent 147 d4f9433e30b9
child 149 2839f8227a38
--- a/ai.js	Fri Sep 26 01:33:34 2014 +0300
+++ b/ai.js	Fri Sep 26 01:40:08 2014 +0300
@@ -209,7 +209,7 @@
     if (this.cfg.edgeBonus > 0 && brd.atEdge(max))
         weight += this.cfg.edgeBonus;
     if (this.cfg.freeBonus > 0)
-        weight += this.cfg.freeBonus * brd.free();
+        weight += this.cfg.freeBonus * brd.freeCnt();
     return weight;
 }
 /** Select best direction for next step. */
@@ -272,7 +272,7 @@
     if (this.cfg.edgeBonus > 0 && brd.atEdge(max))
         weight += this.cfg.edgeBonus;
     if (this.cfg.freeBonus > 0)
-        weight += this.cfg.freeBonus * brd.free();
+        weight += this.cfg.freeBonus * brd.freeCnt();
     return weight;
 }
 /** Select best direction for next step. */
@@ -366,7 +366,7 @@
                 score += cfg.edgeBonus;
     }
     if (cfg.freeBonus > 0)
-        score += cfg.freeBonus * brd.free();
+        score += cfg.freeBonus * brd.freeCnt();
     return score;
 }
 /** Select best direction for next step. */
@@ -378,9 +378,9 @@
     var bestDir;
     this.cleanup();
     this.depthLimit = this.cfg.depth;
-    var free = origBrd.free();
-    if (free >= 6)
-        this.depthLimit = Math.min(this.depthLimit, 6 - free/3);
+    var freeCnt = origBrd.freeCnt();
+    if (freeCnt >= 6)
+        this.depthLimit = Math.min(this.depthLimit, 6 - freeCnt/3);
     for (var i = 0; i < ai.dirs.length; i++) {
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {