# HG changeset patch # User Oleksandr Gavenko # Date 1410454900 -10800 # Node ID 76d257640b7da06f057114690be6f7c86f821f9e # Parent 8ba9dc89be87198df2cbb5c0648a356f135a3e71 Merge config with best settings. diff -r 8ba9dc89be87 -r 76d257640b7d ai.js --- a/ai.js Thu Sep 11 20:01:09 2014 +0300 +++ b/ai.js Thu Sep 11 20:01:40 2014 +0300 @@ -48,22 +48,14 @@ ai.blindWeightRandom = function(brdEngine, cfg) { this.brdEngine = brdEngine; - this.cfg = this.cfg || {}; - var left = ai.blindWeightRandom.fixWeight(this.cfg.left); - var right = ai.blindWeightRandom.fixWeight(this.cfg.right); - var up = ai.blindWeightRandom.fixWeight(this.cfg.up); - var down = ai.blindWeightRandom.fixWeight(this.cfg.down); - var total = left + right + up + down; - this.threshold1 = left/total; - this.threshold2 = (left+down)/total; - this.threshold3 = (left+down+right)/total; + this.cfg = ai.copyObj(ai.blindWeightRandom.bestCfg); + ai.copyObj(cfg, this.cfg); + var total = this.cfg.left + this.cfg.right + this.cfg.up + this.cfg.down; + this.threshold1 = this.cfg.left/total; + this.threshold2 = (this.cfg.left + this.cfg.down)/total; + this.threshold3 = (this.cfg.left + this.cfg.down + this.cfg.right)/total; } -ai.blindWeightRandom.fixWeight = function(val) { - val = val && parseFloat(v) || 1; - if (val <= 0) - val = 1; - return val; -} +ai.blindWeightRandom.bestCfg = {left: 1, down: 10, right: 5, up: 1}; ai.blindWeightRandom.prototype.analyse = function(brd) { var origBrd = new this.brdEngine(brd); while (true) {