--- a/2048.html Thu Sep 11 18:12:24 2014 +0300
+++ b/2048.html Thu Sep 11 19:22:04 2014 +0300
@@ -185,9 +185,25 @@
</div>
<div class="clearfix"></div>
</div>
- <div class="ai" id="ai-next-max-value">
+ <div class="ai" id="ai-one-step-deep">
<button class="ai">enable</button>
<h5>next merge makes max value</h5>
+ <div class="option">
+ <input type="text" name="scoreCoef" class="int" pattern="[0-9]*" value="1"/> score weight
+ </div>
+ <div class="option">
+ <input type="text" name="maxValCoef" class="int" pattern="[0-9]*" value="0"/> max value weight
+ </div>
+ <div class="option">
+ <input type="text" name="cornerBonus" class="int" pattern="[0-9]*" value="100"/> max value at corner bonus
+ </div>
+ <div class="option">
+ <input type="text" name="edgeBonus" class="int" pattern="[0-9]*" value="0"/> max value at edge bonus
+ </div>
+ <div class="option">
+ <input type="text" name="freeBonus" class="int" pattern="[0-9]*" value="10"/> free cell coefficient
+ </div>
+ <div class="clearfix"></div>
</div>
<div class="ai" id="ai-deep-max-score">
<button class="ai">enable</button>
@@ -528,6 +544,17 @@
ui.ai = {};
ui.ai.current = null;
+ ui.ai.parseCfg = function(aiDom, cfg) {
+ var optDoms = aiDom.querySelectorAll("div.option > input.int[type='text']");
+ for (var i = 0; i < optDoms.length; i++) {
+ var val = parseFloat(optDoms[i].value);
+ if (val === NaN) {
+ ui.game.setMessage('' + optDoms[i].name + ' setting is not a number!');
+ continue;
+ }
+ cfg[optDoms[i].name] = val;
+ }
+ }
ui.ai.algList = {
"ai-blind-random": function() {
return new ai.blindRandom(ui.brdEngine);
@@ -546,11 +573,11 @@
cfg.whilePossible = aiDom.querySelectorAll("input[name='whilePossible']")[0].checked;
return new ai.blindCycle(ui.brdEngine, cfg);
},
- "ai-next-max-score": function() {
- return new ai.nextMaxScore(ui.brdEngine);
- },
- "ai-next-max-value": function() {
- return new ai.nextMaxValue(ui.brdEngine);
+ "ai-one-step-deep": function(aiDom) {
+ var cfg = {};
+ ui.ai.parseCfg(aiDom, cfg);
+ console.log(cfg);
+ return new ai.oneStepDeep(ui.brdEngine, cfg);
},
"ai-deep-max-score": function() {
return new ai.deepMaxScore(ui.brdEngine);