# HG changeset patch # User Oleksandr Gavenko # Date 1411424275 -10800 # Node ID 7e93fb8136a3e51717c5c3cf2f811d4d2d079004 # Parent 5701802ff23252968583ec64a940ace083813fa2 Fix: ReferenceError: reference to undefined property this.cfg.weightPriority diff -r 5701802ff232 -r 7e93fb8136a3 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;