Rename AI.
--- 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 @@
</div>
<div class="clearfix"></div>
</div>
- <div class="ai" id="ai-one-step-deep">
+ <div class="ai" id="ai-one-step-ahead">
<button class="ai">enable</button>
- <h5>next merge makes max value</h5>
+ <h5>one step ahead</h5>
<div class="option">
<input type="text" name="scoreCoef" class="positive" pattern="[0-9]*[.]?[0-9]*" value="1"/> score weight
</div>
@@ -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);
--- 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() { }