tanks/docs/_site/history.html

118 lines
4.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/assets/css/dirtbags.css?v=">
<link rel="icon" type="image/png" href="/assets/images/icon.png">
<script src="assets/js/tanks.js"></script>
<script src="assets/js/figures.js"></script>
<title> by </title>
</head>
<body>
<h1 id="title">History</h1>
<p>This is a port of the “Tanks” program written by Paul Ferrell
<a href="&#109;&#097;&#105;&#108;&#116;&#111;:&#112;&#102;&#108;&#097;&#114;&#114;&#064;&#099;&#108;&#097;&#110;&#115;&#112;&#117;&#109;&#046;&#110;&#101;&#116;">&#112;&#102;&#108;&#097;&#114;&#114;&#064;&#099;&#108;&#097;&#110;&#115;&#112;&#117;&#109;&#046;&#110;&#101;&#116;</a> in 2009-2010. Paul created the entire game based
off a brief description I provided him of
<a href="http://tpoindex.github.io/crobots">Crobots</a>
and a vague desire to
“make something fun for high school kids to learn some programming.” We
ran Pauls Tanks as part of a 100-attendee computer security contest in
February of 2010 and by all accounts it was a huge success. It even
made the nightly news.</p>
<p>Pauls version was written in Python and provided a custom language
called “Bullet”, which looked like this:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>&gt;addsensor(50, 0, 5, 1); # 0
&gt;addsensor(100, 90, 150, 1); # 1
&gt;addsensor(100, 270, 150, 1); # 2
&gt;addsensor(100, 0, 359, 0); # 3
# Default movement if nothing is detected
: move(70, 70) . turretccw();
random(2, 3): move(40, 70) . turretccw();
random(1, 3): move(70, 40) . turretccw();
# We found something!!
sense(3): move(0, 0);
sense(1): turretcw();
sense(2): turretccw();
sense(0): fire();
</code></pre>
</div>
<table class="figure">
<caption>"Chashtank" cleans up.</caption>
<tr>
<td>
<canvas id="shortround"></canvas>
<script type="application/javascript">
start("shortround", shortround);
</script>
</td>
</tr>
</table>
<p>Nick Moffitt played with this original version and convinced me (Neale)
that something like Forth would be a better language. I added some code
to accept a scaled-down version of PostScript. The IRC channel we
frequent collectively agreed to give this new language the derisive name
“Forf”, which should ideally be followed by punching someone after it is
spoken aloud. I wrote a Python implementation of Forf, which was slow,
and then Adam Glasgall wrote a C implementation, which was quick.</p>
<p>I decided to take Tanks to Def Con in July 2010, and just for bragging
rights, to have it run on an Asus WL-500gU. This is a $50 device with a
240 MHz MIPS CPU, 16MB RAM, and a 4MB flash disk, along with an
802.11b/g radio, 4-port 10/100 switch, and an additional 10/100 “uplink”
port; its sold as a home wireless router. I had originally intended to
run it off a lantern battery just for fun, but eventually thought better
of it: doing so would be wasteful for no good reason.</p>
<p>Aaron McPhall <a href="&#109;&#097;&#105;&#108;&#116;&#111;:&#097;&#109;&#099;&#112;&#104;&#097;&#108;&#108;&#064;&#109;&#099;&#112;&#104;&#097;&#108;&#108;&#046;&#111;&#114;&#103;">&#097;&#109;&#099;&#112;&#104;&#097;&#108;&#108;&#064;&#109;&#099;&#112;&#104;&#097;&#108;&#108;&#046;&#111;&#114;&#103;</a>, my summer intern at the time, got
OpenWRT and Python onto the box and benchmarked it at about 60 seconds
for a 16-tank game, after he had profiled the code and optimized a lot
of the math. That wasnt bad, it meant we could run a reasonably-sized
game at one turn per minute, which we knew from past experience was
about the right rate. But it required a USB thumb drive to hold Python,
and when we used the Python Forf implementation, the run-time shot up to
several minutes. I began this C port while Adam Glasgall, another fool
on the previously-mentioned IRC channel, started work on a C version of
a Forf interpreter.</p>
<p>This C version with Forf runs about 6 times faster than the Python
version with Bullet, on the WL-500gU. A 1GHz Intel Atom runs a 16-tank
game in about 0.2 seconds.</p>
<h2 id="whats-so-great-about-forf">Whats so great about Forf?</h2>
<p>Nothings great about Forf. Its a crummy language that only does
integer math. For this application its a good choice, for the
following reasons:</p>
<ul>
<li>No library dependencies, not even malloc</li>
<li>Runs in fixed size memory</li>
<li>Not Turing-complete, I think (impossible to make endless loops)</li>
<li>Lends itself to genetic algorithms</li>
</ul>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/running">Running</a></li>
<li><a href="/history">History</a></li>
<li><a href="/thanks">Thanks</a></li>
<li><a href="https://github.com/dirtbags/tanks" title="Tanks on Github">Source</a></li>
</ul>
</nav>
</body>
</html>