# HG changeset patch # User Oleksandr Gavenko # Date 1411242924 -10800 # Node ID df4736e659f2eaad54f6975761cc8839a9ddbf0b # Parent eb4f89e2a00137f97ae36478a6e1b8cc1a346118 Rename AI. diff -r eb4f89e2a001 -r df4736e659f2 2048.html --- a/2048.html Sat Sep 20 09:44:08 2014 +0300 +++ b/2048.html Sat Sep 20 22:55:24 2014 +0300 @@ -213,9 +213,9 @@
-
+
-
next merge makes max value
+
one step ahead
score weight
@@ -715,10 +715,10 @@ cfg.whilePossible = aiDom.querySelectorAll("input[name='whilePossible']")[0].checked; return new ai.BlindCycle(ui.brdEngine, cfg); }, - "ai-one-step-deep": function(aiDom) { + "ai-one-step-ahead": function(aiDom) { var cfg = {}; ui.ai.parseCfg(aiDom, cfg); - return new ai.OneStepDeep(ui.brdEngine, cfg); + return new ai.OneStepAhead(ui.brdEngine, cfg); }, "ai-deep-max-score": function() { return new ai.DeepMaxScore(ui.brdEngine); diff -r eb4f89e2a001 -r df4736e659f2 ai.js --- a/ai.js Sat Sep 20 09:44:08 2014 +0300 +++ b/ai.js Sat Sep 20 22:55:24 2014 +0300 @@ -153,7 +153,7 @@ /** * Defines coefficient for linear resulted weight function. - * @name ai.OneStepDeep.cfg + * @name ai.OneStepAhead.cfg * @namespace * @property {number} scoreCoef multiplicator for score * @property {number} maxValCoef multiplicator for max value @@ -164,15 +164,15 @@ /** 1 step deep with * AI. * @param {Board} brdEngine board engine from board.js - * @param {ai.OneStepDeep.cfg} cfg configuration settings + * @param {ai.OneStepAhead.cfg} cfg configuration settings * @constructor */ -ai.OneStepDeep = function(brdEngine, cfg) { +ai.OneStepAhead = function(brdEngine, cfg) { this.brdEngine = brdEngine; - this.cfg = ai.copyObj(ai.OneStepDeep.bestCfg); + this.cfg = ai.copyObj(ai.OneStepAhead.bestCfg); ai.copyObj(cfg, this.cfg); } -ai.OneStepDeep.bestCfg = {scoreCoef: 1, maxValCoef: 0, cornerBonus: 0, edgeBonus: 0, freeBonus: 0}; -ai.OneStepDeep.prototype.weight = function(brd) { +ai.OneStepAhead.bestCfg = {scoreCoef: 1, maxValCoef: 0, cornerBonus: 0, edgeBonus: 0, freeBonus: 0}; +ai.OneStepAhead.prototype.weight = function(brd) { var weight = 0; if (this.cfg.scoreCoef > 0) weight += this.cfg.scoreCoef * brd.score(); @@ -187,7 +187,7 @@ weight += this.cfg.freeBonus * brd.free(); return weight; } -ai.OneStepDeep.prototype.analyse = function(brd) { +ai.OneStepAhead.prototype.analyse = function(brd) { var origBrd = new this.brdEngine(brd); var nextBrd = new this.brdEngine(); var maxWeight = -1; @@ -205,7 +205,7 @@ return bestDir; } /* Mark that next board will be unrelated to previous, so any stored precompution can be cleared. */ -ai.OneStepDeep.prototype.cleanup = function() { } +ai.OneStepAhead.prototype.cleanup = function() { }