diff -r 2c389325d13b -r 8ba9dc89be87 2048.html --- a/2048.html Thu Sep 11 19:57:44 2014 +0300 +++ b/2048.html Thu Sep 11 20:01:09 2014 +0300 @@ -77,7 +77,7 @@ border: 1px solid tan; border-radius: 4px; } - div.ai > div.option > input.int { + div.ai > div.option > input.positive { text-align: right; max-width: 4em; margin-rght: 2px; @@ -161,16 +161,16 @@
bling weight random
- left weight + left weight
- right weight + right weight
- up weight + up weight
- down weight + down weight
@@ -189,19 +189,19 @@
next merge makes max value
- score weight + score weight
- max value weight + max value weight
- max value at corner bonus + max value at corner bonus
- max value at edge bonus + max value at edge bonus
- free cell coefficient + free cell coefficient
@@ -545,27 +545,26 @@ ui.ai = {}; ui.ai.current = null; ui.ai.parseCfg = function(aiDom, cfg) { - var optDoms = aiDom.querySelectorAll("div.option > input.int[type='text']"); + var optDoms = aiDom.querySelectorAll("div.option > input.positive[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!'); + if (val === NaN || val < 0) { + ui.game.setMessage('' + optDoms[i].name + ' is not a positive number!'); + cfg[optDoms[i].name] = 1; continue; } cfg[optDoms[i].name] = val; } } + ui.ai.algList = { "ai-blind-random": function() { return new ai.blindRandom(ui.brdEngine); }, "ai-blind-weight-random": function(aiDom) { var cfg = {}; - cfg.left = aiDom.querySelectorAll("input[name='left']")[0].value; - cfg.right = aiDom.querySelectorAll("input[name='right']")[0].value; - cfg.up = aiDom.querySelectorAll("input[name='up']")[0].value; - cfg.down = aiDom.querySelectorAll("input[name='down']")[0].value; - return new ai.blindWeightRandom(ui.brdEngine); + ui.ai.parseCfg(aiDom, cfg); + return new ai.blindWeightRandom(ui.brdEngine, cfg); }, "ai-blind-cycle": function(aiDom) { var cfg = {}; @@ -576,7 +575,6 @@ "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() {