-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-tanks
executable file
·110 lines (96 loc) · 2.16 KB
/
run-tanks
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
#! /bin/sh
if [ "$#" -gt 0 ]; then
tanks="$@"
else
echo "Usage: $0 tank1 tank2 [...]"
echo "Writes ./next-round and ./summary.html"
exit 1
fi
TANKS_GAME=${TANKS_GAME:-forftanks}
NAV_HTML_INC=${NAV_HTML_INC:-./nav.html.inc} export NAV_HTML_INC
# Add wherever this lives to the search path
PATH=$PATH:$(dirname $0)
if [ -f next-round ]; then
next=$(cat next-round)
else
next=0
fi
expr $next + 1 > next-round
fn=$(printf "round-%04d.html" $next)
rfn=$(printf "results-%04d.txt" $next)
jfn=$(printf "round-%04d.json" $next)
cfn="current$$.html";
echo -n "Running round $next... "
$TANKS_GAME $tanks >>$jfn 3>$rfn
cat <<EOF >$fn
<!DOCTYPE html>
<html>
<head>
<title>Tanks Round $next</title>
<script type="application/javascript" src="tanks.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="application/javascript">
function go() {
start("battlefield",
// Start JSON data
EOF
cat $jfn >> $fn
cat <<EOF >>$fn
// end JSON data
);
}
window.onload = go;
</script>
</head>
<body>
<h1>Tanks Round $next</h1>
<div id="game_box"><canvas id="battlefield"></canvas></div>
<p><span id="fps">0</span> fps</p>
EOF
rank.awk $rfn >>$fn
cat $NAV_HTML_INC >>$fn
cat <<EOF >>$fn
</body>
</html>
EOF
cat <<EOF >$cfn
<!DOCTYPE html>
<html>
<head>
<title>Tanks Round $next</title>
<script type="application/javascript" src="tanks.js"></script>
<meta http-equiv="Refresh" content="60" />
<style type="text/css">
html {
background: #222;
}
#battlefield {
border: 1px solid green;
}
</style>
<script type="application/javascript">
function go() {
start("battlefield",
// Start JSON data
EOF
cat $jfn >> $cfn
cat <<EOF >>$cfn
// end JSON data
);
}
window.onload = go;
</script>
</head>
<body>
<div id="game_box"><canvas id="battlefield"></canvas></div>
EOF
cat <<EOF >>$cfn
</body>
</html>
EOF
mv "current$$.html" "current.html"
summary.awk $tanks > summary.html.$$
mv summary.html.$$ summary.html
./killmatrix.pl results-*.txt > killmatrix$$.js
mv killmatrix$$.js killmatrix.js
echo "done."