-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.js
111 lines (89 loc) · 3.13 KB
/
stats.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!--
// verbose mode
if (verbose) {verboseMode("load: stats.js");}
// functions used by the 'stats'-window.
// lukas
function showStats() {
if (go()!=true) {
showClean=true;
filterHeight = 2;
statsW = window.open("about:blank", "stats", "status=no, height=200, width=900, scrollbars=yes, resizable=yes");
updateMe=false;
statsW.document.open();
statsW.document.write(makeBody());
statsW.document.close();
}
}
function showRun() {
//if (go()==true) {statsW.run.tw.value = runtime;}
}
function go() {
return updateMe;
}
function updateStatsWin() {
if (go()==true && statsW.run.update.checked) {
showClean = statsW.run.clean.checked;
updateSave = statsW.run.update.checked;
statsW.document.open();
updateMe=updateSave;
statsW.document.write(makeBody());
statsW.document.close();
statsW.location = "#b";
}
}
function updateStatsWinClick() {
showClean = statsW.run.clean.checked;
updateSave = statsW.run.update.checked;
filterHeight = statsW.run.filter.value;
statsW.document.open();
updateMe=updateSave;
statsW.document.write(makeBody());
statsW.document.close();
statsW.location = "#b";
}
function makeBody() {
page = "<html><head><title>AISnake STATS</title></head><body leftMargin=0 topMargin=0 onUnload='window.opener.updateMe=false;'><table width=100% cellPadding=0 cellSpacing=0 border=0>";
page += "<tr bgcolor=black><td><font color=white>#</font></td><td><font color=white>g</font></td><td><font color=white>species</font></td><td><font color=white>parent</font></td><td><font color=white>creation type</font></td><td><font color=white>length at death</font></td><td><font color=white>type of death</font></td></tr>";
his = historyL;
if (showClean == true) {
for (n=0; his[n]!=null; n++) {
x = his[n];
if (parseInt(x[11]) >= parseInt(filterHeight) || x[11] == null) {
page += printLine(his[n]);
}
}
}
else { for (n=0; his[n]!=null; n++) { page += printLine(his[n]); }}
page += "</table><form name='run'>";
page += "show clean history <input type=checkbox";
if (showClean==true) {page += " checked ";}
page += " name=clean>";
page += "filter <input type=text value=";
page += filterHeight;
page += " name=filter>";
page += " || auto-update <input type=checkbox";
if (updateMe==true) {page += " checked ";}
page += " name=update onClick='window.opener.updateStatsWinClick();'>";
page += " || <a href='#' onClick='window.opener.updateStatsWinClick();'>update</a> || total snakes: "+ sC +"</form><a name='b'></body></html>";
return page;
}
function printLine(g) {
string = "";
string+= "<td>" + g[0] + "</td>";
string+= "<td>" + Darwin(g) + "</td>";
string+= "<td>" + g[9] + "</td>";
string+= "<td>" + g[10] + "</td>";
string+= "<td>" + g[11] + "</td>";
string+= "<td>" + g[12] + "</td>";
string += "</tr>";
c = "white";
if (g[11]==null) { c = "#ccffcc";}
if (g[12]=="hunger") { c = "#ffcccc";}
if (g[11]=="0") { c = "#aa0000";}
if (g[11]=="1") { c = "#aa0000";}
head = "<tr bgcolor='"+c+"'><td>" + n + "</td>";
return head + string;
}
// verbose mode
if (verbose) {verboseMode("done: stats.js");}
-->