# HG changeset patch # User Oleksandr Gavenko # Date 1411684414 -10800 # Node ID d4f9433e30b954233031b604f31330f50ca44d8d # Parent a7b42ea88ac5a2cfe9f9f63d65607ee9d18df7b1 Use proper name for incoming argument. diff -r a7b42ea88ac5 -r d4f9433e30b9 ai.js --- a/ai.js Fri Sep 26 01:21:58 2014 +0300 +++ b/ai.js Fri Sep 26 01:33:34 2014 +0300 @@ -59,8 +59,9 @@ ai.BlindRandom = function(brdEngine) { this.brdEngine = brdEngine; } -ai.BlindRandom.prototype.analyse = function(brd) { - var origBrd = new this.brdEngine(brd); +/** Select best direction for next step. */ +ai.BlindRandom.prototype.analyse = function(brd2d) { + var origBrd = new this.brdEngine(brd2d); while (true) { var rnd = Math.floor(Math.random()*4); if (origBrd[ai.canDirs[rnd]]()) @@ -99,8 +100,9 @@ this.threshold3 = (this.cfg.left + this.cfg.down + this.cfg.right)/total; } ai.BlindWeightRandom.bestCfg = { left: 1, right: 16, up: 4, down: 8 }; -ai.BlindWeightRandom.prototype.analyse = function(brd) { - var origBrd = new this.brdEngine(brd); +/** Select best direction for next step. */ +ai.BlindWeightRandom.prototype.analyse = function(brd2d) { + var origBrd = new this.brdEngine(brd2d); while (true) { var rnd = Math.random(); if (rnd < this.threshold1) @@ -149,8 +151,9 @@ else return (dir + 1) % 4; } -ai.BlindCycle.prototype.analyse = function(brd) { - var origBrd = new this.brdEngine(brd); +/** Select best direction for next step. */ +ai.BlindCycle.prototype.analyse = function(brd2d) { + var origBrd = new this.brdEngine(brd2d); this.prevDir = this.prevDir || 0; if (!this.cfg.whilePossible) this.prevDir = this.nextDir(this.prevDir); @@ -209,8 +212,9 @@ weight += this.cfg.freeBonus * brd.free(); return weight; } -ai.OneStepAhead.prototype.analyse = function(brd) { - var origBrd = new this.brdEngine(brd); +/** Select best direction for next step. */ +ai.OneStepAhead.prototype.analyse = function(brd2d) { + var origBrd = new this.brdEngine(brd2d); var nextBrd = new this.brdEngine(); var maxWeight = -1; var bestDir; @@ -271,8 +275,9 @@ weight += this.cfg.freeBonus * brd.free(); return weight; } -ai.StaticDeepMerges.prototype.analyse = function(brd) { - var origBrd = new this.brdEngine(brd); +/** Select best direction for next step. */ +ai.StaticDeepMerges.prototype.analyse = function(brd2d) { + var origBrd = new this.brdEngine(brd2d); var nextBrd = new this.brdEngine(); var prevScore = -1, nextScore = -1; var maxWeight = -1; @@ -364,9 +369,10 @@ score += cfg.freeBonus * brd.free(); return score; } -ai.expectimax.prototype.analyse = function(brd) { +/** Select best direction for next step. */ +ai.expectimax.prototype.analyse = function(brd2d) { this.brdCache = new ai.brdCache(); - var origBrd = new this.brdEngine(brd); + var origBrd = new this.brdEngine(brd2d); var nextBrd = new this.brdEngine(); var maxW = -1; var bestDir;