Missile Command

Missile Command was a classic 1980 arcade game in which the player defends his ABM bases from ICBMs raining down from the sky.

We can implement a simple version of missile command in NetLogo:

Implementation

Here's a framework for Missile Command

MissileCommand.nlogo

Every turtle has three attributes:

turtles-own [abm? target-xcor target-ycor]

If abm? is set to true, then the turtle acts like an ABM (anti-ballistic missile), rapidly moving upwards toward its target. Otherwise the turtle acts like an ICBM (inter-continental ballistic missile), slowly falling downward toward its target. When a turtle is near its target, it explodes, killing all turtles and blackening all patches within range.

Pressing the setup button calls the init-model procedure.

Pressing the run button repeatedly calls the update-model procedure.

Notice that we frequently execute the command:

if mouse-down? [launch-abm mouse-xcor mouse-ycor]

If this command is executed while the mouse button happens to be down, then a new ABM is launched with the mouse coordinates as its target.

Warning: The player must hold the mouse button down for half a second to guarantee an ABM will be launched.