Parse checkbox AI config automatically.
--- a/2048.html Sat Sep 20 23:41:36 2014 +0300
+++ b/2048.html Sat Sep 20 23:47:48 2014 +0300
@@ -703,6 +703,10 @@
}
cfg[optDoms[i].name] = val;
}
+ var optDoms = aiDom.querySelectorAll("div.option > input[type='checkbox']");
+ for (var i = 0; i < optDoms.length; i++) {
+ cfg[optDoms[i].name] = optDoms[i].checked;
+ }
return cfg;
}
ui.ai.cfgTitle = function(aiName) {
@@ -721,9 +725,7 @@
return new ai.BlindWeightRandom(ui.brdEngine, cfg);
},
"ai-blind-cycle": function(aiDom) {
- var cfg = {};
- cfg.clockwise = aiDom.querySelectorAll("input[name='clockwise']")[0].checked;
- cfg.whilePossible = aiDom.querySelectorAll("input[name='whilePossible']")[0].checked;
+ var cfg = ui.ai.parseCfg(aiDom);
return new ai.BlindCycle(ui.brdEngine, cfg);
},
"ai-one-step-ahead": function(aiDom) {