Allow IA choose any direction in case when all move lead to game over.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 19 Oct 2014 01:16:11 +0300
changeset 156 e6a4bc888b72
parent 155 1f8df90bd338
child 157 f0e34d11f5cb
Allow IA choose any direction in case when all move lead to game over. Disable debug outpuut.
ai.js
--- a/ai.js	Sun Oct 19 01:13:42 2014 +0300
+++ b/ai.js	Sun Oct 19 01:16:11 2014 +0300
@@ -472,7 +472,7 @@
 ai.survive.prototype.analyse = function(brd2d) {
     var origBrd = new this.brdEngine(brd2d);
     var nextBrd = new this.brdEngine();
-    var bestW = -1;
+    var bestW = -2;
     var bestDir;
     var freeCnt = origBrd.freeCnt();
     if (freeCnt >= this.cfg.freeCells)
@@ -481,7 +481,6 @@
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
             var w = this.evalFn(nextBrd, 1);
-            console.log("dir: %s, w: %d", dir, w);
             if (w > bestW) {
                 bestW = w;
                 bestDir = dir;