# HG changeset patch # User Oleksandr Gavenko # Date 1411561511 -10800 # Node ID e634761d04327dcd00777dcbdbca2a216263b97f # Parent fa1f44d3888d1c01c23c56bde1ac4ca61b4d94de Increase depth limit. diff -r fa1f44d3888d -r e634761d0432 ai.js --- a/ai.js Wed Sep 24 14:57:53 2014 +0300 +++ b/ai.js Wed Sep 24 15:25:11 2014 +0300 @@ -318,10 +318,10 @@ this.cfg.balance = ai.expectimax.bestCfg.balance; if ( this.cfg.balance > 1) this.cfg.balance = 1; - if (!this.cfg.depth || this.cfg.depth < 0 || 8 <= this.cfg.depth) + if (!this.cfg.depth || this.cfg.depth < 0 || 9 <= 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}; +ai.expectimax.bestCfg = {balance: .9, depth: 5, scoreCoef: 1, maxValCoef: 0, cornerBonus: 0, edgeBonus: 0, freeBonus: 0}; ai.expectimax.prototype.weight = function(brd) { var score = 0; var cfg = this.cfg; @@ -348,6 +348,10 @@ var maxW = -1; var bestDir; this.cleanup(); + this.depthLimit = this.cfg.depth; + var free = origBrd.free(); + if (free >= 6) + this.depthLimit = Math.min(this.depthLimit, 6 - free/3); for (var i = 0; i < ai.dirs.length; i++) { var dir = ai.dirs[i]; if (origBrd[dir](nextBrd)) { @@ -362,7 +366,7 @@ return bestDir; } ai.expectimax.prototype.evalFn = function(brd, depth) { - if (depth >= this.cfg.depth) + if (depth >= this.depthLimit) return this.weight(brd); if (this.cache[depth]) { var cache = this.cache[depth];