Remove comparing with next board weight if expected value differ less then threshold.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 24 Sep 2014 14:57:53 +0300
changeset 125 fa1f44d3888d
parent 124 4a2551dd179d
child 126 e634761d0432
Remove comparing with next board weight if expected value differ less then threshold.
ai.js
--- a/ai.js	Wed Sep 24 14:51:22 2014 +0300
+++ b/ai.js	Wed Sep 24 14:57:53 2014 +0300
@@ -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, weightThreshold: 10};
+ai.expectimax.bestCfg = {balance: .9, depth: 3, scoreCoef: 1, maxValCoef: 0, cornerBonus: 0, edgeBonus: 0, freeBonus: 0};
 ai.expectimax.prototype.weight = function(brd) {
     var score = 0;
     var cfg = this.cfg;
@@ -345,22 +345,15 @@
 ai.expectimax.prototype.analyse = function(brd) {
     var origBrd = new this.brdEngine(brd);
     var nextBrd = new this.brdEngine();
-    var prevScore = -1, nextScore = -1;
-    var maxWeight = -1;
+    var maxW = -1;
     var bestDir;
     this.cleanup();
     for (var i = 0; i < ai.dirs.length; i++) {
         var dir = ai.dirs[i];
         if (origBrd[dir](nextBrd)) {
-            var weight = this.evalFn(nextBrd, 1);
-            var ok = (weight - maxWeight) > this.cfg.weightThreshold;
-            if ( ! ok && maxWeight <= weight) {
-                nextScore = this.weight(nextBrd);
-                ok = prevScore < nextScore;
-            }
-            if (ok) {
-                prevScore = nextScore;
-                maxWeight = weight;
+            var w = this.evalFn(nextBrd, 1);
+            if (w > maxW) {
+                maxW = w;
                 bestDir = dir;
             }
         }