Programming Pinball Machines
Programming Pinball Machines
ABSTRACT
The University of Southern California has recently created
a Bachelor’s Program in Computer Science (Games) and
a Master’s Program in Computer Science (Game Develop-
ment). As part of this effort, we are currently working on
creating a motivational project class on programming pin-
ball machines, where the students interface a PC to an ex-
isting pinball machine and then re-program the pinball ma-
chine with a pinball game developed by them. In Summer
and Fall 2008, we performed a feasibility study with the ob-
jective to develop the computer interface between a PC and
a recent Lord of the Rings pinball machine, the software to
drive the interface, libraries that provide abstractions of this Figure 1: Lord of the Rings Pinball Machine
interface, and a program that uses these libraries to imple-
ment an engaging pinball game. In this paper, we describe
the results of this successful feasibility study. As far as we Computer Interface, Game Development, Pinball Class, Pin-
know, this is the first time that anyone has managed to con- ball Machines, Teaching Computer Science
trol an existing pinball machine completely and re-program
it with a new complete (but simple) pinball game. 1. INTRODUCTION
The faculty members of the Department of Computer Sci-
Categories and Subject Descriptors ence at the University of Southern California believe that
K.3.2 [Computers and Education]: Computer and Infor- teaching computer science hands on via the development
mation Science Education—Computer Science Education, of games helps them to motivate students to learn com-
Curriculum; K.8.0 [Personal Computing]: General— puter science. They have therefore created a Bachelor’s
Games; B.4.m [Hardware]: Input/Output and Data Com- Program in Computer Science (Games) and a Master’s Pro-
munications—Miscellaneous gram in Computer Science (Game Development), which not
only provide students with all the necessary computer sci-
ence knowledge and skills for working anywhere in indus-
General Terms try or pursuing advanced degrees but also enable them to
∗Figure 3 uses parts of images by Cassidy Thomas, obtained be immediately productive in the game-development indus-
from the Internet Pinball Database at www.ipdb.org. The try [19]. In this paper, we describe our experience with
game music of Pinhorse is a mix of “Fearless Flight” from a feasibility study for a motivational project class on pro-
Null Space, “March of the Nucleotides” from Bit Shifter and gramming pinball machines, where the students interface a
other pieces from Castlevania. The pinball project was sup-
ported in part by a grant from the USC Fund for Innova- PC to an existing pinball machine and then re-program the
tive Undergraduate Teaching. Daniel Wong did his research pinball machine with a pinball game developed by them.
in Summer 2008 as a summer scholar in the undergradu- Solid-state pinball machines basically consist of a computer
ate merit research program, funded by the Viterbi School that reads the switches and controls the lights, solenoids,
of Engineering, and received a scholarship from the Rose speakers and the dot-matrix display [13]. A pinball game is
Hill Foundation in Fall 2008. We thank the Orange County determined by the input-output behavior of the computer,
Pinball League for their hospitality.
that is, what outputs the computer activates and when it
activates them in response to its input-output history. The
pinball class will cover how to build a hardware interface to
the pinball machine, how to design and implement the soft-
ware interface for the low and high level real-time control
of the pinball machine (including how to best represent the
rules of the pinball game), and how to write the rules of the
pinball game.
10. IMPLEMENTING THE GAME Pinhorse uses sound effects to inform the players of the out-
comes of their actions. For example, Pinhorse plays voice
Shots consist of sequences (usually of length two) of switch
recordings to reinforce which shot the second player is ex-
edges in quick succession, which allows Pinhorse to detect
pected to make next, which greatly improved the player ex-
whether the shot was sufficiently strong to complete success-
perience. Pinhorse also uses sound effects to encourage the
fully and what the direction of the shot was. Some shots con-
second player to act quickly when his time runs out. Finally,
sist of more than one sequence of switch edges, which allows
Pinhorse plays background music during game play.
the player to complete it in different ways. Pinhorse adds
every switch edge to a small buffer and then scans the buffer
in an attempt to match a shot (shot recognition). For the 11. CURRENT STATUS / FUTURE WORK
first player, recognized shots are added to the end of a queue. Pinhorse was intended to help us improve the computer and
For the second player, recognized shots are compared to the software interface and demonstrate the feasibility of writing
first shot in the queue. If they match, the first shot in the a pinball game within a semester. The Pinhorse program
queue is removed (shot matching). Pinhorse knows that the consists of about 680 lines of code, the helper classes for
second player has matched all shots of the first player once shot recognition, shot matching and light patterns consist of
the queue is empty and then starts a bonus mode where the about 1600 lines of code, and the software interface consists
second player can make extra shots to increase their score. of about 2500 lines of code. Almost all of this code can be
reused to speed up the development of future pinball games
Pinball games require both visual and audio cues to com- and to increase their complexity.
municate the current state of the game to the players and
create the right mood. Pinhorse uses the DMD to display Pinhorse works well, with three minor issues: First, Pin-
the current player, the number of shots made by the first horse occasionally fails to detect shots due to switch edge-
player or the number of shots still to be made by the sec- detection errors and adjustment problems. For example, the
ond player, the next shot to be made by the second player pinball can sometimes squeeze by the upper switch of the
and the remaining time. However, since the pinball action right orbit without triggering it, which could be prevented
is fast paced, Pinhorse makes extensive use of the lights to only by adjusting the switch position. Second, pinball games
give visual cues to the player. enter a ball-find mode when the pinball gets stuck some-
where and no switches trigger. Pinhorse, however, has very
Pinhorse uses a variety of lighting effects. The software short rounds and thus enters the ball-find mode only when
interface addresses the lights according to the architecture the pinball is missing at the end of the round. A stuck pin-
imposed by the I/O Power Driver Board. We therefore im- ball thus ends the turn of a player. Finally, the first player
plemented a wrapper that allows Pinhorse to reason about can define as many as 10 to 12 shots in the 60 seconds that
lights by Cartesian coordinates. These coordinates are de- we allotted for each round, which can be difficult for the sec-
rived as the projections of the lights onto the playfield glass ond player to replicate. Pinball Horse could be made easier
with a system of power-ups that the second player can earn the hardware and software interface to program a complete
with particular shots and that then increase their remaining (but simple) pinball game that makes use of all of these
time or turn off features of the pinball machine that ran- aspects. Thus, our project extends the start of the art sub-
domize the movement of the pinball, such as the slingshots stantially. Additional information and a video of Pinhorse,
or pop bumpers. our pinball game, in action can be found on our webpages
at idm-lab.org/pinball.
12. RELATED WORK / CONCLUSIONS
Several universities have recently introduced game develop- 13. REFERENCES
ment classes, see for example the issue of the Communi- [1] H. Barrows. How to Design a Problem-Based Curriculum
for the Preclinical Years. Springer, 1985.
cations of the ACM on “Creating a Science of Games” [18],
[2] J. Bork. Controlling a pinball machine using Linux. Linux
the proceedings of the First to Third Annual Microsoft Aca- Journal, 139, 2005.
demic Days Conference on Game Development in Computer [3] J. Bork. Reverse engineering a microcomputer-based control
Science Education and the proceedings of the ACM Techni- unit. Master’s thesis, Industrial Technology, Bowling Green
cal Symposium on Computer Science Education, including State University, Bowling Green (Ohio), 2005.
[14]. Game development classes typically develop only soft- [4] D. Clark. An inexpensive realtime testbed - the pinball
ware that does not interface to the physical world, such as player project. In Proceedings of the IEEE Workshop on
real-time strategy games. Real-Time Applications, pages 86–88, 1994.
[5] D. Clark. Progress toward an inexpensive real-time testbed:
The pinball player project. In Proceedings of the Real-Time
Simulations of pinball machines have, in research, been Educational: Second Workshop, pages 72–79, 1997.
used to develop and evaluate machine learning algorithms [6] D. Cliburn. Games across the curriculum: Can we quantify
[10, 17, 16]. In teaching, they have been used to teach artifi- their effectiveness? (birds of a feather session). In ACM
cial intelligence as part of “Artificial Intelligence” (CS6361) Technical Symposium on Computer Science Education,
at Georgia Institute of Technology (USA) in Winter 1999 2007.
taught by Sven Koenig (one of the authors of this paper). [7] R. Cohen. Designing an experimental pinball wizard. The
Electronic System Design Magazine, 19, 1989.
Actual pinball machines have, in research, been used to [8] S. Gustafsson, J. Munoz, S. Norell, D. Real, and Y. Xiao.
Smart pinball project - final report. Technical report,
study hybrid system control [12] and to develop and evaluate Skolan för Elektro- och Systemteknik, Royal Institute of
machine learning algorithms by an undergraduate student of Technology, Stockholm (Sweden), 2004.
Sven Koenig (one of the authors of this paper) at Georgia [9] J. Holbrook, B. Fasse, and J. Gray. Creating a classroom
Institute of Technology (USA) in 1999. In teaching, they culture and promoting transfer with ’launcher units’. In
have been used to teach real-time and embedded systems as American Educational Research Association, 2001.
part of “Introduction to Embedded and Real-Time Program- [10] M. Johnson. Algorithms for pinball simulation, ball
ming” (CS160) at Brown University (USA) in Spring 2007, tracking and learning flipper control. Master’s thesis,
Department of Electrical Engineering and Computer
“Smart Product Design Laboratory” (ME218a) at Stanford Science, Massachussetts Institute of Technology, Boston
University (USA) in 2007, “Designing with Microcontrollers” (Massachussetts), 1993.
(EE476) at Cornell University (USA) in Spring 2007 and [11] J. Kolodner, D. Crismond, J. Gray, J. Holbrook, and
“Special Topics in Electrical Engineering: Pinball Machine S. Puntambekar. Learning by design: From theory to
Project” (ENEE 488Q) at the University of Maryland at Col- practice. In Proceedings of the International Conference of
lege Park (USA) in Spring 1997. A similar effort existed at the Learning Sciences, pages 223–229, 1998.
Brooklyn College (USA) around 1997 [5]. Pinball machines [12] G. Lichtenberg and J. Neidig. An example of hybrid
systems control: The pinball machine. Technical Report
have also been used to teach signal and image processing 2003.13, Lehrstuhl für Automatisierungstechnik and
as part of “Project Course in Signal Processing and Digital Prozessinformatik, Ruhr-Universität Bochum, Bochum
Communication” (EQ2430/EQ2440) at Kungliga Tekniska (Germany), 2003.
Högskolan (Sweden) in Spring 2004 and “Project: Pinball” [13] M. Rossignoli. The Complete Pinball Book. Schiffer, 1999.
(EOH 2004) of the ACM Special Interest Group for Com- [14] N. Sturtevant, H. Hoover, J. Schaeffer, S. Gouglas,
puter Architecture at the University of Illinois at Urbana M. Bowling, F. Southey, M. Bouchard, and G. Zabaneh.
Champaign (USA) in Spring 2004. Multidisciplinary students and instructors: A second-year
games course. In ACM Technical Symposium on Computer
Science Education, 2008.
One of these efforts attempted to build a pinball machine [15] S. Williams. Putting case-based instruction into context:
from scratch, which allows them to customize the hardware Examples from legal and medical education. Journal of the
for easier control. Other efforts used old electro-mechanical Learning Sciences, 2(4):367–427, 1992.
pinball machines, which are easier to control than newer [16] N. Winstead. Some explorations in reinforcement learning
solid-state pinball machines. The state of the art in con- techniques applied to the problem of learning to play
trolling a pinball machine was as follows: Some efforts con- pinball. In Proceedings of the AAAI-03 Workshop on
trolled the flippers by modifying the hardware [4]. Some Entertainment and AI/A-Life, pages 1–5, 1996.
tracked the ball via input from the playfield switches [12] or [17] N. Winstead and A. Christiansen. Pinball: Planning and
learning in a dynamic real-time environment. In AAAI-94
an overhead camera [8, 7]. The most sophisticated project so Fall Symposium on Control of the Physical World by
far mimicked the microcomputer-based control unit to read Intelligent Agents, pages 153–157, 1994.
the switches and control the solenoids [3, 2]. We, on the [18] M. Zyda. Creating a science of games. Communications of
other hand, provide a hardware and software interface that the ACM, 50(7), 2007.
controls all aspects of an existing solid-state pinball machine [19] M. Zyda and S. Koenig. Teaching artificial intelligence
(including the lights, solenoids, DMD and speaker) without playfully. In Proceedings of the AAAI-08 Education
needing to modify its hardware. Furthermore, we have used Colloquium, 2008.