# HG changeset patch # User Oleksandr Gavenko # Date 1411339488 -10800 # Node ID 6d5a9d8b00be5d2fc9e2e7c78bdce91fea60ad94 # Parent 5f4985c2a4d48221a908b85725d46f711d736b67 Renames. diff -r 5f4985c2a4d4 -r 6d5a9d8b00be ai.js --- a/ai.js Sun Sep 21 01:16:27 2014 +0300 +++ b/ai.js Mon Sep 22 01:44:48 2014 +0300 @@ -229,7 +229,7 @@ var dir = ai.dirs[i]; if (origBrd[dir](nextBrd)) { nextScore = nextBrd.score(); - var score = this.bestScore(nextBrd); + var score = this.evalFn(nextBrd); // console.log("dir: %o, prevScore: %o, nextScore: %o, maxScore: %o, score: %o", dir, prevScore, nextScore, maxScore, score); if (maxScore < score || (maxScore === score && prevScore < nextScore)) { prevScore = nextScore; @@ -240,7 +240,7 @@ } return bestDir; } -ai.DeepMaxScore.prototype.bestScore = function(brd, seenBrds) { +ai.DeepMaxScore.prototype.evalFn = function(brd, seenBrds) { if (seenBrds) { for (var i = 0; i < seenBrds.length; i++) if (brd.equals(seenBrds[i])) @@ -256,7 +256,7 @@ if (brd[ai.dirs[i]](nextBrd)) { var score = nextBrd.score(); if (score > currScore) - maxScore = Math.max(maxScore, this.bestScore(nextBrd, seenBrds)); + maxScore = Math.max(maxScore, this.evalFn(nextBrd, seenBrds)); } } return maxScore; @@ -321,7 +321,7 @@ var dir = ai.dirs[i]; if (origBrd[dir](nextBrd)) { nextScore = this.scoreCorner(nextBrd); - var score = this.bestScore(nextBrd); + var score = this.evalFn(nextBrd); // console.log("dir: %o, prevScore: %o, nextScore: %o, maxScore: %o, score: %o", dir, prevScore, nextScore, maxScore, score); if (maxScore < score || (maxScore === score && prevScore < nextScore)) { prevScore = nextScore; @@ -332,7 +332,7 @@ } return bestDir; } -ai.DeepMaxScoreCorner.prototype.bestScore = function(brd, seenBrds) { +ai.DeepMaxScoreCorner.prototype.evalFn = function(brd, seenBrds) { if (seenBrds) { for (var i = 0; i < seenBrds.length; i++) if (brd.equals(seenBrds[i])) @@ -348,7 +348,7 @@ if (brd[ai.dirs[i]](nextBrd)) { var score = this.scoreEdge(nextBrd); if (score > currScore) - maxScore = Math.max(maxScore, this.bestScore(nextBrd, seenBrds)); + maxScore = Math.max(maxScore, this.evalFn(nextBrd, seenBrds)); } } return maxScore; @@ -415,7 +415,7 @@ for (var i = 0; i < ai.dirs.length; i++) { var dir = ai.dirs[i]; if (origBrd[dir](nextBrd)) { - var weight = this.recWeight(nextBrd, 1); + var weight = this.evalFn(nextBrd, 1); var ok = (weight - maxWeight) > this.cfg.weightPriority; if ( ! ok && maxWeight <= weight) { nextScore = this.weight(nextBrd); @@ -431,7 +431,7 @@ this.cleanup(); return bestDir; } -ai.expectimax.prototype.recWeight = function(brd, depth) { +ai.expectimax.prototype.evalFn = function(brd, depth) { if (depth >= this.cfg.depth) return this.weight(brd); if (this.cache[depth]) { @@ -454,7 +454,7 @@ var n = 0, w = 0; for (var diri = 0; diri < ai.dirs.length; diri++) { if (randBoard[ai.dirs[diri]](nextBrd)) { - w += this.recWeight(nextBrd, depth+1); + w += this.evalFn(nextBrd, depth+1); n++; } } @@ -466,7 +466,7 @@ var n = 0, w = 0; for (var diri = 0; diri < ai.dirs.length; diri++) { if (randBoard[ai.dirs[diri]](nextBrd)) { - w += this.recWeight(nextBrd, depth+1); + w += this.evalFn(nextBrd, depth+1); n++; } }