Merge config with best settings.
--- 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) {