Fix: wrong variable scope.
--- 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);
}