tanks

Blow up enemy tanks using code
git clone https://git.woozle.org/neale/tanks.git

tanks / docs / _site
Neale Pickett  ·  2024-12-05

running.html

 1<!DOCTYPE html>
 2<html lang="en-US">
 3  <head>
 4    <meta charset='utf-8'>
 5    <meta name="viewport" content="width=device-width">
 6    <link rel="stylesheet" href="/assets/css/dirtbags.css?v=">
 7    <link rel="icon" type="image/png" href="/assets/images/icon.png">
 8
 9    <title> by </title>
10  </head>
11
12  <body>
13    <h1 id="title">Running Tanks</h1>
14
15<p>Unfortunately, it’s kind of a mess right now.
16I know there are a few forks of this code,
17and I would love it if someone proposed a merge to clearly illustrate how to run tanks.</p>
18
19<p>When I spin up a new tanks game,
20typically I run something like:</p>
21
22<div class="highlighter-rouge"><pre class="highlight"><code>while sleep 60; do ./round.sh */; done
23</code></pre>
24</div>
25
26<p>This assumes all your tanks directories are in the same place as <code class="highlighter-rouge">round.sh</code>.</p>
27
28<h2 id="included-programs">Included programs</h2>
29
30<p>I tried to stick with the Unix philosophy of one program per task.  I
31also tried to avoid doing any string processing in C.  The result is a
32hodgepodge of C, Bourne shell, and awk, but at least each piece is
33fairly simple to audit.</p>
34
35<h3 id="roundsh-tank1-tank2-">round.sh tank1 tank2 …</h3>
36
37<p>Runs a single round, awards points with rank.awk, and creates a new
38summary.html with summary.awk.  This is the main interface that you want
39to run from cron or whatever.</p>
40
41<h3 id="forftanks-tank1-tank2-">forftanks tank1 tank2 …</h3>
42
43<p>A program to run a round of tanks and output a JSON description of the
44game.  This is what tanks.js uses to render a game graphically.
45The object printed contains:</p>
46
47<div class="highlighter-rouge"><pre class="highlight"><code>[[game-width, game-height],
48 [[tank1-color, 
49  [[sensor1range, sensor1angle, sensor1width, sensor1turret],
50   ...]],
51  ...],
52 [[
53  [tank1x, tank1y, tank1angle, tank1sensangle, 
54   tank1flags, tank1sensors],
55  ...],
56 ...]]
57</code></pre>
58</div>
59
60<p>If file descriptor 3 is open for writes, it also outputs the results of
61the round to fd3.</p>
62
63<h3 id="rankawk">rank.awk</h3>
64
65<p>Processes the fd3 output of forftanks to award points and output an
66HTML results table.</p>
67
68<h3 id="summaryawk-tank1-tank2">summary.awk tank1 tank2</h3>
69
70<p>Creates summary.html, linking to all rounds and showing overall
71standing.</p>
72
73<h3 id="designercgi">designer.cgi</h3>
74
75<p>Accepts form input and writes a tank.</p>
76
77
78
79    <nav>
80      <ul>
81        <li><a href="/">Home</a></li>
82        <li><a href="/running">Running</a></li>
83        <li><a href="/history">History</a></li>
84        <li><a href="/thanks">Thanks</a></li>
85        <li><a href="https://github.com/dirtbags/tanks" title="Tanks on Github">Source</a></li>
86      </ul>
87    </nav>
88  </body>
89</html>