Fix: wrong variable scope.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 24 Sep 2014 23:21:30 +0300
changeset 136 4a143572b9d2
parent 135 935a500cea3b
child 137 be8ee2240a17
Fix: wrong variable scope.
ai.js
--- a/ai.js	Wed Sep 24 22:55:49 2014 +0300
+++ b/ai.js	Wed Sep 24 23:21:30 2014 +0300
@@ -390,13 +390,13 @@
                         wMax2 = Math.max(wMax2, this.evalFn(nextBrd, depth+1));
                 }
                 var wMax4 = 0;
-                if (this.cfg.balance < 1) {
+                var balance = this.cfg.balance;
+                if (balance < 1) {
                     randBoard.set(i, j, 2);
                     for (var diri = 0; diri < ai.dirs.length; diri++) {
                         if (randBoard[ai.dirs[diri]](nextBrd))
                             wMax4 = Math.max(wMax4, this.evalFn(nextBrd, depth+1));
                     }
-                    var balance = this.cfg.balance;
                 }
                 wMin = Math.min(wMin, balance * wMax2 + (1 - balance) * wMax4);
             }