Spacewar!

This is a virtual DEC PDP-1 emulated in HTML5/JavaScript running the original code of "Spacewar!", the earliest known digital screen game.
If available, use gamepads or joysticks (currently Chrome and Firefox only, see instructions-memo below) 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 implementation by Norbert Landsteiner, www.masswerk.at, 2012–2015.
Based on emulation code by Barry Silverman, Brian Silverman, and Vadim Gerasimov. The emulation code was extended to support some additional instructions and auxilary hardware. Especially the shift/rotate instructions and the arithmetics were rewritten and now include an emulation of the automatic hardware multiply/divide option. Further, cycle counts were added for accurate timing and frame rates. Some importance was put in the recreation of the appearance of the original CRT display and the unique experience conveyed by it. Moreover, a splash-screen was added, and there are multiple versions of the original code ready to play. See below for details.
For some other interactive programs running on this emulator, see www.masswerk.at/minskytron.

The original PDP-1 emulation in HTML5/JavaScript running Spacewar! by Barry Silverman, Brian Silverman, and Vadim Gerasimov is to be found at: http://spacewar.oversigma.com/html5/.

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).
Use the special offline version to add "Spacewar!" to your home screen (so you may play even without an active network connection).

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

*     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

 

   PLAYER 2:

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

      L ... TURN RIGHT     OR 6

      K ... THRUST         OR 5

      I ... FIRE           OR 8

 

   PRESS 'LEFT' AND 'RIGHT' TOGETHER FOR CLOAK/HYPERSPACE.

 

 

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

HIT TAB ON KEYBOARD TO SWAP CONTROL BOXES AND SHIPS.

 

 

SIGNED

HEAD OF THE COMPUTER DEPARTMENT

Visit the "Sense Switches / Setup" dialog to select a national or non-standard keyboard layout.
Some keyboards may not read all keys at once, please resort to the alternate fire keys ("4" and "0") in this case.

Gamepads/Joysticks: The game will notify on the splash-screen, when support for gamepads is available with your browser. This is still quite experimental technology, support may depend on the make of the OS, the browser, and the specific pad. Switching a pad to "direct mode" may help. Some pads require to have a connection button pressed, when plugged in. For a close to original experience use one of the analog sticks for turn (left/right) and the other for thrust (down) and hyperspace (up). Digital sticks are supported as well. Any major button should work for fire. Left shoulder buttons are hyperspace, right shoulder is fire. Hit the tab-key of the keyboard to swap the assignment of pads and ships.

Notes & Descriptions

Program Versions & Sources

The emulation is running various versions of the original game, both from binaries copies of the original paper tapes and newly assembled from authentic code listings. The programs are loaded as virtual paper tapes (RIM-mode: Read In Memory) into the memory of the emulated DEC PDP-1.

Spaceships (stylized) according to the Hingham Institute Study Group on Space Warfare

Spacewar! 3.1, the final version of Spacewar! as left by the original programmers (Steve Russell and the other members of the Hingham Institute Study Group on Space Warfare), is presented here once in its original form and in a modified version showing scaled up graphics and effects for the benefit of small screen sizes. Further, there are both earlier and later versions, as Spacewar! 2b (the program described in "The Origin of Spacewar" by J. M. Graetz) and some examples of version 4 (adding minor features and compatibility to an upgraded hardware). Finally, there is a special version of Spacewar 3.1, demonstrating the "Winds of Space" effect.

(Please mind that the title screens are generated by the emulator and are not part of the original games.)

There are two display resolutions to select from:

Versions available (by the "versions menu" at the top left of the emulated display):

Some research has been invested in order to identify various versions and paper tapes, some of these versions are here playable for the first time in decades. The locations of the individual sources are linked in the descriptions above. Versions marked "[bin]" are loaded as-is from binary paper-tape images as they are found in the archives. Versions marked "[rim]" were newly assembled for this emulation from historic source listings. Modules marked "[mod]" are modified versions based on genuine listings.
You might want to play in classic setup with the "Sun" killing on contact by activating sense switch 5 (see the options menu options menu icon at the top right of the screen).

The Emulator

The code is executed in a DEC PDP-1 emulated in JavaScript (based on code by Barry Silverman, Brian Silverman, and Vadim Gerasimov, who did also a Java-implementation in 1997, which serves as a basis for any PDP-1 emulator around). The JS emulation code was partly rewritten and has been enhanced to support additional hard­ware like a paper-tape reader, the multiply/divide option of later PDP-1s, or the test-word, also a few additional instructions have been added to the em­u­lation and some of the code (like the shift/rotate-operations, the logic for arithmetics, switches, flags, or I/O operations) has been re-implemented. Realtime time-keeping was added for authentic emulation speed based on cycle counts. Aside the support of the PDP-1's sense switches to control some of the games' behavior, there's also a provision to extract and hack essential constants (setup parameters) of the games (see the tools menu accessible by the options menu options menu icon at the top right of the screen). (N.L. 2012-2015)

The DEC PDP-1 was introduced in 1959 as one of the first commercial machines using core memory and transitors only. It featured a clock rate of 0.2 MHz (100,000 additions per second) and operated at 18-bit words. The standard memory was 4 K of 18-bit words (expandable). The over all performance is roughly comparable to the one of an Apple II micro computer from the late 1970s (wider words and less CPU cycles per instruction make up for a slower clock rate).

Some importance has been put in reconstructing the visual impression of the original CRT display:

DECUS icon

Notes on the CRT-Emulation

The PDP-1 was one of the first computers to come with an (optional) CRT display. The DEC Type 30 Visual CRT Display featured a round tube in a distinctive, hexagonal housing in a concentric layout. The make of the tube was originally intended for radar scopes and employed a dual P7 coating with two layers of phosphor, a bright, light-blue one displaying freeshly activated blips, and a dimmer, greenish-yellowish one displaying the decaying blips in a fading afterglow. These characteris are also responsible for the iconic trails drawn by any moving object on the screen.

The Type 30 CRT was essentially a point plotting device (also known as XY display), meaning that there was no memory or repetitive scan, but plotting locations were addressed randomly by individual display commands. Refreshing the screen was entirely left to the program, which had to redraw any blips that were to stay on the screen. If not refreshed, the blips would fade away in the afterglow of the P7 phosphor. The scope provided a technical resolution of 1024 by 1024 plotting locations on an area of 9 3/8 inches square. The spot size of an activated location increased with its intensity (the display featured 8 distinctive brightnesses), the blips — we cannot speak of pixels here — thus slightly overlapped and mended on the screen, effecting in a visible resolution of approximately 512 by 512 display locations.

(Note: The Type 30 CRT was neither an oscilloscope nor a vector display. It lacked any memory, but it was a serious piece of hardware that came at a destinctive price tag. Point plotting CRTs with P7 phosphor are also known as "animated display" or "painted display" for their sponge-like display characteristics.)

These characteristics are quite important for the game, since its drawing mechanism heavily depends on the afterglow of the display, which provides the required stability for the screen image. Moreover, since the built-in brightnesses didn't scale that well, perceivable brightnesses are also modulated by distinctive refresh rates. (E.g, the background starfield is refreshed only every second frame in order to separate it from the foreground objects a little more.)

The emulation recreates the distinctive characteristics and their effects, like the dual layers of phosphor, the variable intensities and spot sizes, and the overall perceptible resolution. In low-resolution mode a special virutal subpixel mapping is employed to boost the display resolution, providing smooth movements and a similar degree of visible detail like the original device. Thanks to the faithful recreation of the display, the programs can be run and displayed at the original frame rate by the emulator. (There's also an option in the settings dialog to opt out of true frame-by-frame rendering for a more stable, flicker-free display.)

(While the low-resolution mode corresponds closely to the visual impression of the original display, users provided with a large screen or a high density ["retina"] display, may want to also check the full-scale version of the emulator.)

Spacewar!

The Game

Spacewar! features the epic battle of two spaceships, the Needle and the Wedge, each of them to be controlled by a human player. The two ships navigating in outer space are subject to the gravity excerted by a central star, closely simulating the laws 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 would explode in pixel dust or when both of the vessels would 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. (And a ship will certainly explode at the eighth attempt, if you would get ever that far.)

The ships are drawn against the background of a realistically depicted starfield, Peter Samson's Expensive Planetarium, which draws a 45° segement the "stars of the heavens" (the stars of the first four magnitudes between 22½° N and 22½° S 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 at the console lights (in binary, player 1 by the contents of the accumulator, player 2 by the lights of the I/O-register). Some of the later versions featured a graphical on-screen display for even increased delights.

A variety of settings could be accessed by the sense switches at the operator's console, like the kind of turning action (inertial rotation for angular momentum, simulating rocket-driven movement in space, or Bergenholm rotation, simulating the more convenient action of gyros), single shot or continuous fire operation, the presence of a central star and the extent of its gravity, controls for the background-starfield, and last but not least, if ships colliding with the central stars would explode or rather be warped to the "antipode" at the corners of the screen.

Initially intended as an entertaining demonstration object for the real-time capabilities of the DEC PDP-1, then newly donated to MIT, Spacewar! was to become the first of what we now know as digital video games. A group of MIT students and employees, the Hingham Institute Study Group on Space Warfare (named after Steve Russell's lodging), conceived the game in summer 1961 and progressed to implementation over the fall of the same year under the lead of Steve Russell, programmer-in-chief. A first version (without gravity or the background starfield) was operational soon thereafter (fall/late 1961) and the game was basically ready in February 1962. Version 2b saw the addition of a background display featuring the slowly moving stars of the heavens (Peter Samson's Expensive Planetarium, March 1962) and was announced in the first issue of Decuscope (the DEC users' information) in April 1962. The program, complemented by a few patches, was presented to the public at the MIT Science Open House in May 1962. Finally, the program was refactored into its final form (final as far as the original group of authors was concerned), Spacewar! 3.1, in September 1962. Later, other programmers took over to adapt the game for the upgraded hardware and to add minor features, namely Monty Preonas (ddp) and the coder known as dfw.

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).

A variety of special input devices, so called "control boxes", including even a repurposed joystick from a missile control console of USAF surplus supplies, were developed for use with the game and attached to the PDP-1. Facilities outside of MIT that were not so lucky to have their own control boxes had to rely on the testword switches on the operator's console for input. (The game is known to have been temporarily banned at BBN and other locations for the wear of console switches excerted by heavy gaming.) The kind of control input to be processed by the game could be selected by the start address of the program.

The game was written in assembler code for MIT's Macro assembler (ported from a previous implementation for the TX-0 computer). Special contributions were, aside from Peter Samson's Expensive Planetarium that could have well served as a stand-alone program, the addition of the gravity computations by Dan Edward and his ingenious outline-compiler which allowed only the inclusion of gravity. Even with the extensive JIT-code produced by the outline-compiler the memory condition were not tense, allowing for ample space for patches and even the parallel use of the online-debugger ddt. (Stories of swapping in and out values of shared storage locations for terse memory are urban myths and do not withstand an inspection of the source code.) Resources were not so much restricted by the amount of memory available or the particular execution time, but by the requirements of refreshing the screen at a steady frame rate and the delay caused by the display's response to any plotting commands. (While an internal instruction completed in 5 microseconds, the display required 50 microseconds to respond with a completion pulse. This was caused by some cooling circuits in the display, which prevented the beam from oscillating or "ringing" while jumping at high speeds from one plotting location to the next.) Therefore, the real expensive article was a dot on the display.

While the game was for some years, with a few exceptions, available on DEC machines only, it saw its spreading by frequent ports to other platforms in the 1970s and provided a popular entertainment to the happy few who had access to a computer with a suitable screen.

PDP-1 sense switches

Sense Switches

Some settings to modify the game's behavior could be adjusted by flipping one of the sense switches, an array of 6 switches dedicated to user interaction on the PDP-1's console. You may set these in the "Sense Switches / Setup" dialog, or, more conveniently, using the options menu options menu icon at the top right of the screen. The menu items always reflect the options available with the particular program. You may also use the keyboard to toggle sense switches by pressing the SHIFT key and the appropriate number key (1..6).
(There are some more options in the "Sense Switches / Setup" dialog, like the emulation speed or keyboard settings.)

Hacking Parameters

Most versions of Spacewar! (but the very earliest) started 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. The parameters are bounded to sane values (e.g. value parts or bit-wise shift-steps are extracted and handled internally) — Please mind that, since these hacks are actually injected into the binary code of the program, they have to be set anew, when a different version of Spacewar! has been loaded.

Note: While called "constants" in the comments, the entries in this setup table weren't actually parameters, but entire instruction that could have even been replaced by jumps to subroutines that would return the 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 is sticking with the original instructions and allows the adjustment of their operands (in a somewhat user-friendly fashion).

Spacewar! - The CBS Opening

The "CBS Opening" Maneuver

A well established way to set up a game of Spacewar! was dubbed the "CBS Opening" (named for its remarkable similarity to the network company's logo, see this image): Both players would turn their ships orthogonally to an imaginary axis to the central star and would fire their thrusters (for about 2 to 3 seconds) to enter a stable orbit around the gravitational center. Orbits established, they would align their ships, ready to launch their torpedoes against the opponent.

Players are encouraged to use gravity as a friend rather than engaging in a quite hopeless attempt to fight against it.

Usage / UX-Notes

Gossip & Comments

Lost and Found:

The following features were either identified or rediscoverd while researching for this project:

There are still some facts missing:

In case you would happen to have additional informations, please contact me.

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 costumer 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.

Research

Further Reading

Related Games

Play Minnesota Spacewar, a reconstruction of a Albert W. Kuhfeld's flavor of Spacewar!, featuring "Minnosota Hyperspace". (This application is actually up for a re-write.)

PDP-1 Sense Switches

The PDP-1's control console provided an array of switches, the “sense switches”, which were used to control some of the game's behavior (“off” = default settings):

(unknown)

(unknown)

(unknown)

(unknown)

(unknown)

(unknown)

Emulation:

(On: display each frame, Off: double frames, no flicker)