--- a/2048.html Sat Sep 20 23:19:01 2014 +0300
+++ b/2048.html Sat Sep 20 23:41:36 2014 +0300
@@ -305,8 +305,10 @@
}
ui.dom.table = function(tbl, cols, cfg) {
var tableDom = document.createElement('table');
- if (typeof cfg.tableClass === 'string')
- tableDom.classList.add(cfg.tableClass);
+ if (typeof cfg.tblClass === 'string')
+ tableDom.classList.add(cfg.tblClass);
+ if (typeof cfg.tblTitle === 'string')
+ tableDom.title = cfg.tblTitle;
var trDom = document.createElement('tr');
for (var i = 0; i < cols.length; i++) {
var thDom = document.createElement('td');
@@ -690,6 +692,7 @@
ui.ai = {};
ui.ai.current = null;
ui.ai.parseCfg = function(aiDom, cfg) {
+ cfg = cfg || {};
var optDoms = aiDom.querySelectorAll("div.option > input.positive[type='text']");
for (var i = 0; i < optDoms.length; i++) {
var val = parseFloat(optDoms[i].value);
@@ -700,6 +703,13 @@
}
cfg[optDoms[i].name] = val;
}
+ return cfg;
+ }
+ ui.ai.cfgTitle = function(aiName) {
+ var title = JSON.stringify(ui.ai.parseCfg(document.getElementById(aiName))).replace(":", ": ", "g").replace(",", "\n", "g");
+ title = title.substr(1);
+ title = title.substr(0, title.length-1);
+ return title;
}
ui.ai.algList = {
@@ -707,8 +717,7 @@
return new ai.BlindRandom(ui.brdEngine);
},
"ai-blind-weight-random": function(aiDom) {
- var cfg = {};
- ui.ai.parseCfg(aiDom, cfg);
+ var cfg = ui.ai.parseCfg(aiDom);
return new ai.BlindWeightRandom(ui.brdEngine, cfg);
},
"ai-blind-cycle": function(aiDom) {
@@ -718,8 +727,7 @@
return new ai.BlindCycle(ui.brdEngine, cfg);
},
"ai-one-step-ahead": function(aiDom) {
- var cfg = {};
- ui.ai.parseCfg(aiDom, cfg);
+ var cfg = ui.ai.parseCfg(aiDom);
return new ai.OneStepAhead(ui.brdEngine, cfg);
},
"ai-deep-max-score": function() {
@@ -729,8 +737,7 @@
return new ai.DeepMaxScoreCorner(ui.brdEngine);
},
"ai-expectimax": function(aiDom) {
- var cfg = {};
- ui.ai.parseCfg(aiDom, cfg);
+ var cfg = ui.ai.parseCfg(aiDom);
return new ai.expectimax(ui.brdEngine, cfg);
},
// "": function() {
@@ -893,7 +900,7 @@
tblCols.push('mean speed');
tblCols.push('max speed');
}
- var tableDom = ui.dom.table(tbl, tblCols, { tableClass: 'report-by-maxval' });
+ var tableDom = ui.dom.table(tbl, tblCols, { tblClass: 'report-by-maxval', tblTitle: ui.ai.cfgTitle(ui.ai.currentName) });
reportDom.appendChild(tableDom);
reportsDom.insertBefore(reportDom, reportsDom.firstChild);
}