Fix: ReferenceError: reference to undefined property this.cfg.weightPriority
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 23 Sep 2014 01:17:55 +0300
changeset 118 7e93fb8136a3
parent 117 5701802ff232
child 119 e5f1930f0f19
Fix: ReferenceError: reference to undefined property this.cfg.weightPriority
ai.js
--- a/ai.js	Tue Sep 23 01:09:28 2014 +0300
+++ b/ai.js	Tue Sep 23 01:17:55 2014 +0300
@@ -259,7 +259,7 @@
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
             var weight = this.evalFn(nextBrd);
-            var ok = (weight - maxWeight) > this.cfg.weightPriority;
+            var ok = (weight - maxWeight) > this.cfg.weightThreshold;
             if ( ! ok && maxWeight <= weight) {
                 nextScore = this.weight(nextBrd);
                 ok = prevScore < nextScore;
@@ -321,7 +321,7 @@
     if (!this.cfg.depth || this.cfg.depth < 0 || 8 <= this.cfg.depth)
         this.cfg.depth = ai.expectimax.bestCfg.depth;
 }
-ai.expectimax.bestCfg = {balance: .9, depth: 3, scoreCoef: 1, maxValCoef: 0, cornerBonus: 0, edgeBonus: 0, freeBonus: 0, weightPriority: 10};
+ai.expectimax.bestCfg = {balance: .9, depth: 3, scoreCoef: 1, maxValCoef: 0, cornerBonus: 0, edgeBonus: 0, freeBonus: 0, weightThreshold: 10};
 ai.expectimax.prototype.weight = function(brd) {
     var score = 0;
     if (this.cfg.scoreCoef > 0)
@@ -350,7 +350,7 @@
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
             var weight = this.evalFn(nextBrd, 1);
-            var ok = (weight - maxWeight) > this.cfg.weightPriority;
+            var ok = (weight - maxWeight) > this.cfg.weightThreshold;
             if ( ! ok && maxWeight <= weight) {
                 nextScore = this.weight(nextBrd);
                 ok = prevScore < nextScore;