diff -r e4e21d2fcbe7 -r ee53cd2cb69a 2048.html
--- 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 @@
+
@@ -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);