Spacewar!

Clear Scores

This is a virtual DEC PDP-1 (emulated in HTML5/JavaScript) running the original code of "Spacewar!", the earliest known digital video game. If available, use gamepads or joysticks for authentic gameplay — the game was originally played using custom “control boxes”.

Spacewar! was conceived in 1961 by Martin Graetz, Stephen Russell, and Wayne Wiitanen. It was first realized on the PDP-1 in 1962 by Stephen Russell, Peter Samson, Dan Edwards, and Martin Graetz, together with Alan Kotok, Steve Piner, and Robert A Saunders.
Spacewar! is in the public domain, but this credit paragraph must accompany all distributed versions of the program.

This emulation is by Norbert Landsteiner, www.masswerk.at, 2012–2022.
It is based on emulation code by Barry Silverman, Brian Silverman, and Vadim Gerasimov. The emulation code has been rewritten and extended to support additional instructions and auxilary hardware. Special attention has been paid on accurate timing and on a recreatiion of the appearance and the unique experience of the original CRT display. Further, an informative splash-screen, which is not part of the original game, was added, and there are multiple versions of the original code ready to play. See below for details.
(The page has been slightly overhauled to celebrate Spacewar!'s 60th anniversary in 2022.)
For some other interactive programs running on this emulator, see www.masswerk.at/minskytron.

******************

*     M E M O    *

******************

 

 

ONCE AGAIN:

PLAYING "SPACEWAR!" DURING REGULAR OPERATIONS IS POSITIVELY PROHIBITED!

AS YOU ALL PRETTY WELL KNOW, REGULAR OPERATION HOURS ARE FROM 0 AM TO 12 PM ("24/7")!

 

 

INSTRUCTIONS FOR PLAYING "SPACEWAR!":

—————————————————————————————————————

 

   PLAYER 1:

 

      A ... TURN LEFT

      D ... TURN RIGHT

      S ... THRUST

      W ... FIRE

 

      Q ... HYPERSPACE

 

   PLAYER 2:

 

      J ... TURN LEFT      OR 4 (NUMBER-PAD)

      L ... TURN RIGHT     OR 6

      K ... THRUST         OR 5

      I ... FIRE           OR 8

 

      U ... HYPERSPACE     OR 7

 

 

OR USE CONTROL BOXES ("GAMEPADS"), THRUST IS DOWN, HYPERSPACE IS UP.

HIT TAB ON KEYBOARD TO SWAP ASSIGNMENTS OF CONTROL BOXES TO SHIPS.

 

 

SIGNED

 

   HEAD OF THE COMPUTER DEPARTMENT

Gamepads / Joysticks:

Spacewar control boxSpacewar! was original played using so-called "control boxes", the first game controllers for any digital video game. (In case these were not available, the game could be started from a special address to be operated by switches on the control console of the PDP-1.) These control boxes had a lever for left and right turn, another lever for thrust and hyperspace, and a button to fire the photon torpedoes. (Compare the illustration on the right.) — For the best experience, it is recommended to play the game using gamepads attached to your computer.

The emulator will show a message on the splash-screen, if it detects support for gamepads by your browser. For a close to original experience use the analog sticks: the left one turns (left / right) the right one is used for thrust (down) and hyperspace (up).
Digital sticks and D-pads are supported as well. Any major button should work as fire. Left shoulder buttons are hyperspace, right shoulder is fire. Hit the tab-key on the keyboard to swap the assignment of gamepads and ships.

Click here for an illustration of the gamepad mappings.
(To override these mappings and to use your own key mappings, go the options menu and toggle the item "USB Gamepads".)

Touch Controls:
Special controls featuring arcade-style buttons are displayed for touch-enabled devices (use landscape orientation; drag the controls by their ship icons to move them to a convenient screen location).

options menu iconGame Options:
Various options like emulation speed and "sense switch" options for the individual programs are available in the options menu at the top right of the page.

Notes & Descriptions

Spacewar! is a computer game for two human players. Each player controls one of the two spaceships, the “Needle” and the “Wedge”, in an epic battle in outer space. A central star exerts gravity on the ships, as closely modeled by the game by a simulation of Newtonian physics. Photon torpedoes of limited supply (not affected by gravity themselves for the limited resources of the PDP-1) may be fired in order to destroy the opponent. A game ends when any of the ships explodes in pixel dust or when both of the vessels manage to run out of torpedoes.
Hyperspace offers a means of last resort to any player in trouble, but of an unreliable sort: The "Mark I hyperfield generators" are likely to explode on re-entry, with an increasing probability with each successive jump. (A ship will explode with certainty on the eighth attempt, if you were ever to get that far.)

The scene is drawn against the backdrop of a realistically depicted moving starfield, Peter Samson’s Expensive Planetarium, which renders a 45° segement of the "stars of the heavens" (stars of the first four magnitudes between 22½° North and 22½° South as listed in the American Ephemeris and Nautical Almanac) in a gradually shifting motion.

The game features a scoring facility including managed matchplay with tie-resolving (up to 31 games, to be set up on the switches of the operator’s console). The machine would halt at the end of a game or a match and display the score on the control console in binary using the console lights for the accumulator (player 1) and the I/O register (player 2). Some of the later versions featured a graphical on-screen display for even increased delights.
(While matchplay is not supported by the emulation, the score is extracted and displayed in the bar below the emulated scope. For versions with a graphical on-screen score display, activate the “Scores” button at the bottom left of the display to have scores displayed after each game. Pressing “B” on the keyboard toggles this visual score board on/off, as well.)

A variety of settings can be accessed by the six “sense switches” at the operator's console:

In the emulation, these options can be set by the options menu options menu icon in the top right corner or can be toggled by pressing SHIFT and numbers 1 to 6 on the keyboard.

How to Play

Spacewar! - The CBS Opening

Players are adviced to not fight gravity (this is a rather fruitless attempt), but rather use it to their advantage. A well established maneuver to enter a stable orbit around the central star was known as the “CBS Opening” (named for the remarkable similarity to the network company’s logo): Turn your ship perpendicular to an imaginary axis towards the central star and fire your rocket thrusters for about 2 or 3 seconds. Orbits established, fire your torpedoes at your opponent. Gravity provides extra momentum and reach to your shots and even allows for some nifty slingshot maneuvers.

Program Versions

The emulation comes with several versions of the original game, which are loaded from virtual paper tapes. Select a program by the “versions menu” at the top left of the emulated display, or by simply clicking on a title in the description below.
(Title screens are not part of the original programs and are generated by the emulator.)

Versions available:

Bonus Content

A Hackable Game

All versions of Spacewar! (but the very earliest) start with a section commented “interesting and often changed constants” — probably the first cheats in electronic gaming history.
Steve Russell: “It was quite interesting to fiddle with the parameters, which of course I had to do to get it to be a really good game. By changing the parameters you could change it anywhere from essentially just random, where it was pure luck, to something where skill and experience counted above everything else. The normal choice is somewhere be­tween those two.” (quoted in “Spacewar – Fanatic Life and Symbolic Death Among the Computer Bums” by Stewart Brand.)

These “often changed constants” could be altered either by manipulating individual bits by the means of the operator’s console or, more likely, by the use of the online-debugger ddt. The emulator provides access to most of these “constants” by a special parameters dialog, accessible by the options menu options menu icon. (Please mind that these hacks have to be set anew, when a different version of Spacewar! has been loaded.)

An example for this is the “Winds of Space” hack (see above), another one is “Hydraulic Spacewar” described in Steven Levy’s “Hackers”: “By switching a few parameters you could turn the game into ‘hydraulic Spacewar,’ in which torpedoes flow out in ejaculatory streams instead of one by one.” This may be achieved by setting the value of paramter “rlt” (torpedo reload time) close to zero.

Note: While called “constants” in the comment, the entries in this setup table weren’t actually parameters, but entire instructions, which could be replaced by jumps to subroutines returning a suitable value (this was even encouraged by the comments). The program wouldn’t just look up these entries, it would actually execute the given instruction. Avoiding the perils of proper programming, the parameters dialog sticks with the original instructions and allows the adjustment of their operands in a somewhat user-friendly manner.

Similarly, spaceship outlines are defined in a hackable manner by strings of octal numbers, where each digit encodes a simple directive. There are codes for move-and-plot (down, left, right, down and left, down and right), store/restore the current position, and restarting the outline for the mirrored other side. (Reportedly, “ship hacks” were quite popular and this may well have been how the Star Treck inspired sprites, known from later ports of the program, came about.)

Playing Spacewar!, Dan Edwards and Peter Samson
Playing Spacewar! — Dan Edwards (l) and Peter Samson (r).

A Bit of History

Spacewar! originated as an entertaining demonstration for the real-time capabilities of the PDP-1. As word spread that Digital Equipment Corporation (DEC) would be donating one of their first models of their all-new Programmed Data Processor 1 to MIT, a group of grad students and MIT employees gathered to come up with an idea to show its capabilities at the next Science Open House. There was already an amazing graphics generator by Marvin Minsky, known as the “Minskytron, but this wasn’t really interactive and did capture interest for long. Clearly, it should be somewhat more involving than this. In midst of the Space Race and provided that the group (dubbed the Hingham Institute Study Group on Space Warfare, named after Steve Russell’s lodging) had a weak point for pulp science fiction, the idea of a ”spaceship trainer,” was somewhat convincing. However, what about a full-fledged space battle, like in the books by E. E. “Doc” Smith? Well, not a battle, but a duel?

So the idea of Spacewar! was born and “someone” was really to do something about it. In fall, the PDP-1 arrived (formally presented November 6, 1961) and the group around MIT’s Tech Model Railroad Club (TMRC) was eagerly waiting for the selected someone to act. However, Steve Russell, also known as “Slug”, wasn’t known for starting things early and was also not too keen on getting hands-on with the intricacies of complex numeric problems, like the transcendental functions of sine and cosine aproximation. This period of hesitation found an end by the help of Alan Kotok, who confronted Russell with a tape, he had obtained from DEC, using the famous quote, “All right, Russell, here’s a sine-cosine routine; now what's your excuse?” With the CRT display of the PDP-1 installed in the last days of December, the stars finally aligned, and by February 1962 a first playable version of the game was ready.

However, this was just the beginning. Facilitated by Dan Edward’s ingenious just-in-time compiler for drawing the spaceship outlines, gravity added another tactical dimension to the game, which also benefitted from an overall speed improvement. (However, there weren’t resources left to apply gravity to torpedoes, as well, thus the weightless “photon torpedos.”) Annoyed by an early random star background, Peter Samson added the realistic simulation of the “Expensive Planetarium”, and Martin Graetz contributed the original hyperspace routine, featuring a warping animation reminiscent of the Minskytron. A short article on the game appeared in the very first issue of “Decuscope – Information for Digital Equipment Computer Users” in April 1962, and, by the addition of a scoring and matchplay facility to regulate demand, the game was finally ready to be shown to the public on the occasion of the MIT Science Open House in May 1962.

For more on how the program came into being, see "The Origin of Spacewar" by J. M. Graetz (in: Creative Computing; Volume 7, Number 8; August 1981; also published in: The Computer Museum Report, Fall 1983; Malboro, MA, 1983).

Steve Russell, who had left MIT to follow Marvin Minsky to the West coast, returned in Septmeber to devise the improved version 3.1, which consolidated the various patches into a comprehensive program. In 1963, others, like Monty Preonas and “dfw” took over, adapting the program to the newly installed hardware multiply/divide option and experimenting with additional features. New input devices were tried, like the joystick (including its entire control panel) of a missile control acquired from USAF surplus supplies. At some point, there were controls for varying speed input. Monty Preonas experimented with multiple displays and subjective view points. A visual score board was added, and there had been probably a number of other variations, we don’t know of. The game was soon ported to other computers, especially new DEC machines, as they became available, and spread to wherever there was a computer installation with a visual display, becoming the computer game of the 1970s.

Technically, the game was written in PDP-1 assembler code, more specifically MIT’s own “Macro” assembler derived from the TX-O, and resided in the basic 4K 18-bit words core memory of the PDP-1. Dan Edward’s outline compiler, based on a previous interpreter for spaceship outline codes, may be the earliest example of a JIT-compiler. Steve Russell, who had previously written the very first incarnation of Lisp (together with Dan Edwards), used object oriented approaches in his code, making frequent use of pointers and lists.
Contrary to some rumors, there’s still space left in memory, there’s even a special mode to allow the program to be run together with the online-debugger “ddt”. Resources were not so much restricted by the amount of memory available or the general execution time, but by the requirements of the screen: with memory being enormously expensive and the display being of fairly high resolution, any screen content had to be redrawn by the program by re-issuing any plot commands in a steady loop. The bottleneck here was the display’s response time to any plotting commands, which limited the amount of what could be displayed flicker-free. (While an internal instruction completed in 5 microseconds, the display required 50 microseconds to respond with a completion pulse. This was caused by cooling circuits in the display, which prevented the electron beam from overshooting or “ringing”, while jumping at high speeds from one plot position to the next.) — The really expensive article was a dot on the display.

DEC PDP-1, Soroban console typewriter, Type 30 CRT display
DEC PDP-1, Soroban console typewriter, Type 30 CRT display.

The PDP-1 Computer

DEC was founded in 1957 by Ken Olsen and Harlan Anderson, who had previously worked on MIT˚s experimental computers, like Whirlwind, the Memory Test Computer (TMC), and Wes Clark’s TX-0 and TX-2 machines. While the new firm specialized in its first few years in electronic modules for computers and laboratory equipment, DEC revealed its first digital computer, the Programmed Data Processor 1 (PDP-1) at the Eastern Joint Computer Conference in December 1959. Designed by Ben Gurley, another former MIT employee, in just three-and-a-half months, the computer followed MIT’s tradition of interactive real-time computing and was probably the first commercial computer with a display available. Depending on its use, the PDP-1 may be characterized both as an early work station and as a small main frame computer.

A first pre-production prototype was delivered to Bolt, Beranek and Newman (BBN) in 1960, where it was used for prototyping time-sharing. (This machine also ran Spacewar!, but allegedly the game was eventually banned for the wear on its console switches. Conversely, the machine which arrived at MIT was used for protyping time-sharing, as well.) Another PDP-1 at BBN was used for writing and compiling the code of the Interface Message Processor (IMP), interfacing computers with ARPANET, and, as this machine came on-line itself, was also used to distribute software over the net (maybe annother first). The second pre-production prototype was delivered to Lawrence Livermore National Laboratory (LLNL), which eventually became the most extensively equipped PDP-1 installation. (This PDP-1 featured various experimental input devices for optical scanning and speech recognition, and even an early mouse, built in-house in the mid-1960s and refining Douglas Engelbart’s original design.) One of the first production machines was donated to MIT, where it was located in room 26265, next to the TX-0. Which is also the very machine that gave birth to Spacewar! (This was only the first of what eventually became a fleet of five PDP-1s known to have existed at MIT.)

In essence, the PDP-1 was a commercial version of MIT’s approach to computing. It came in a polished package, a single-cabinet main unit and a display in Space Age blue and hexagonal design elements. Unlike its experimental ancestors, it was reasonably priced, didn’t need much in terms of installation as it could be plugged into an ordinary wall socket, and could be turned on by the flip of a single switch. As Martin Graetz put it, it was the first toy computer. (However, you still had to be a potent institution to afford this toy: The reasonable list price for a PDP-1 was still US$ 120,000 and another US$ 14,300 for the display, which translated to 13 average family homes and a brand new car in 1960. But, compared to other computers, this was actually cheap.)

The PDP-1 was a fully transistorized solid-state computer with a word-size of 18-bit and one’s compliment arithmetic. The standard memory was 4K of 18-bit words, expandable to up to 12 memory modules of 4K each, which could be mounted as named banks. The cycle time for instructions internal to the CPU was 5 seconds, as was the access time to its core memory (providing 100,000 18-bit additions per second including memory access). The instruction set was quite comfortable, combining instructions and their operand in a single word. Besides its accumulator, there was another I/O register and extensive support for indirect addressing to facilitate programming, but no processor stack and no index registers and programs had to be self-modifying by necessity.

The PDP-1 came with extensive I/O circuitry of various sort, including custom taper pin panels, which came handy when it came to connecting the Spacewar! control boxes. An optional accessory to the display was a light pen, which again pointed back to the origin in MIT computers like Whirlwind and the TX-O. In its basic configuration, the PDP-1 came with 4K memory and a Soroban console typewriter (a IBM Model A electric typwriter modified by the Soroban Company using selenoids for remote operations) and a special DEC chair. Later models also shipped with the automatic hardware multiply/divide option preinstalled. (According to well-established rumors, PDP-1s came also with Spacewar! in the non-volatile core memory, ready for extensive testing, once the various components had been installed, which also helped spreading the game. However, there is no confirmed first-hand source for this.)

About 55 PDP-1s were made in total and the fully restored serial number 55 is a permanent exhibit at the Computer History Museum (CHM) in Mountain View/CA, where Spacewar! can be played on real hardware in the course of one of the scheduled demo tours. (There are a few other machines in storage, both at the CHM and at the Smithsonian.)

The Type 30 Visual CRT Display

DECUS icon

The most outstanding accessory to the PDP-1 was its CRT display. This utilized a CRT tube originally manufactured for scan radar, which wasn’t unusual for high resolution displays at the time. More unusual was its P7 phosphor with a dual layer of phosphor coating, one layer of bright blue phosphor with quick response and short sustain, and another yellowish-green layer of long decay, which was visible for several seconds. As a result, any moving objects drew iconic trails on the screen, which contributed to the aesthetics of Spacewar!, as did its concentric, Space Age modernist hexagonal housing. (The well regonizable shape of the Type 30 display also became the emblem of DECUS, the DEC Users Society, compare the image.)

The Type 30 CRT display was a point plotting display, also known as X/Y display or animated display. Unlike later raster displays, this was a random access display, which moved its illuminating cathode ray directely from point to point, as directed by the display instructions. While sharing this random access with vector displays, simple X/Y do not have any memory, meaning, any permanent representation on the screen had to be redrawn by the program at a stable interval. The technical resolution was 1024 × 1024 display location at 7 intensities (and another, invisible one, which could be registered by the light pen), where the various display intensities resulted in varying spot sizes and overlapping display locations. According to DEC, this resulted in a visual resolution of 512 × 512, which is also the resolution of this emulation (with sub-pixel rendering to account for intermediate locations and spot sizes.)

Spacewar! makes use of these characteristics in a rich variety of graphics stiles, from the cartoonish outlines of the spaceships (inspired by Buck Rogers cartoons and the contemporary Red Stone rocket), over the pulsing, rotating line of the gravitational star in the center, the abstract art of the “Minskytron effect”, to the painted effect of the explosion and the realism of the “Expensive Planetarium”. (The latter makes also use of the long sustain of the P7 phosphor, as the background stars are only drawn every second frame to render them more dimly and to separate them from the main scene.)

People watching Spacewar!
Watching Spacewar! (CHM catalog No. 102652458.)

Trivia

Special Thanks

Spacewar! – The Official Birth Announcement

In April 1962 the following tongue-in-cheek style text was published in the very first issue of “Decuscope – Information for Digital Equipment Computer Users” (Vol. 1 No. 1, April 1962, pp 2 and 4; a copy is provided as a PDF-document at bitsavers.org):

 
PDP-1 PLAYS AT SPACEWAR!

         by D.J. Edwards, MIT
              J.M. Graetz, MIT
 

If, when walking down the halls of MIT, you should happen to hear cries of "No! No! Turn! Fire! ARRRGGGHHH!!," do not be alarmed. Another western is not being filmed — MIT students and others are merely participating in a new sport, SPACEWAR!

Planned and programmed by Stephen R. Russell under the auspices of the Hingham Institute Study Group on Space Warfare, SPACEWAR is an exciting game for two players, many kibitzers, and a PDP-1.

The game starts with each player in control of a spaceship (displayed on PDP's scope face) equipped with propulsion rockets, rotation gyros, and space torpedoes. The use of switches to control apparent motion of displayed objects amply demonstrates the real-time capabilities of the PDP-1.

Also displayed on the scope is a central sun which excerts a gravitational influence on the spaceships. The entire battle is conducted against a slowly moving background of stars of the equatorial sky. The object of the game is to destroy the opponent's ship with torpedos. The computer follows the targets and participants have an opportunity to develop tactics which would be employed in any future warfare in space.

Your editor visited the MIT Campus in Room 26265 and can verify an excellent performance. She learned that the best "Aces" had only a 50% chance of survival. Enthusiasm nevertheless ran high and the battle continued while young Mr. Russell trued to explain his program.

"The most important feature of the program," he said, "is that one can simulate a reasonably complicated physical system and actually see what is going on."

Mr. Russell also said that symbolic and binary tapes were available. Please contact Mr. Russell for additional information.

(You may note that there is no notion of hyperspace yet in this text, the version in question being apparently Spacewar! 2B.)

Spacewar! as an Ambassador of the Programmed Data Processor-1 (PDP-1)

In 1963 (ca.) the Digital Equipment Corporation (DEC) related to "Spacewar"[sic] in a promotional brochure (“PDP-1 Computer and Spacewar”), which also provides some contemporary context, as follows:

SPACEWAR
The demonstration you are watching on the cathode ray tube is called Spacewar. At first look, Spacewar is a fascinating space-age game, in which two players maneuver rocket-armed spaceships in the near weightlessness of space until one is in position to fire the winning shot.

More important, Spacewar is typical of simulation techniques used in psychology laboratories to analyze the problems of man-machine relationships in complex or little-understood situations.

General-purpose computers and other digital equipment play a key role in many scientific studies. The PDP-1 computer used in Spacewar is performing calculations at speeds up to 100,000 per second as it interprets the operator's switch actions and sends positional information to the display at a rate of 20,000 points per second. To give some idea of the complexity of the computer's task, we might mention that in storing and plotting the relative positions and speeds of the spaceships, rockets, stars, and sun, PDP-1 is referring to Newton's laws of motion stored in its 4096-word core memory. Thus the operators must compensate for gravitational attraction when the spaceships come close to the sun.

[The following paragaraphs are not specially related to Spacewar!, but give a vivid picture of human-computer-interaction (HCI) as anticipated in the early 1960s, building on achievements like M.I.T.'s Whirlwind, the SAGE scope, the Charactron/MIV console, and Ivan Sutherland's Sketchpad on TX-2, which are all in PDP-1's pedigree. (C.f. this image and notes.)]

PDP-1 and its newer, lower priced companion PDP-4 can be installed in ordinary office space, require no special power, air conditioning, or floor reinforcement. They go to work almost immediately, since minimum customer training is required. Ample controls and indicators provide easy and convenient operation and control.

The Precision CRT Display Type 30 demonstrated here is one of the family of computer-operated displays designed by Digital Equipment Corporation to extend greatly the usefulness of the computers. With the unique Light Pen Type 32, a completely untrained operator can communicate with the computer. For example, the Light Pen aimed at the scope face could signal the computer to modify an engineering drawing displayed at the scope. The modified drawing would be displayed instantaneously.

People watching Spacewar!
Plot of Spacewar!’s field of gravity.

Research

Related Games and Emulations

Further Reading

Finally…

You may buy me a coffee here: Buy me a coffee