All I Ever Needed To Know About Programming I Lear

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/228962901

All I Ever Needed to Know About Programming, I Learned From Re-writing


Classic Arcade Games

Article · January 2005

CITATIONS READS

14 188

2 authors:

Katrin Becker James R. Parker


Mount Royal University The University of Calgary
146 PUBLICATIONS 1,360 CITATIONS 159 PUBLICATIONS 3,164 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Katrin Becker on 19 May 2014.

The user has requested enhancement of the downloaded file.


All I Ever Needed to Know About Programming, I Learned From
Re-writing Classic Arcade Games
Katrin Becker J. R. Parker
Graduate Division of Educational Research, Digital Media Laboratory
Faculty of Education University of Calgary
University of Calgary jparker@ucalgary.ca
beckerk@ucalgary.ca

students write games, and classic arcade games are


Abstract especially suited for this role. Others are also
recognizing the value of games in the curriculum:
Microsoft Research chose games curricula as one
The quest for interesting, engaging, yet doable
of their two major focuses for funding in 2004 [3].
programming assignments is an ongoing one.
Authentic, realistic examples have often been
drawn from business, and games have often been 2. Traditional Project Fare
overlooked as being too narrow in scope. This
paper explains why computer games, especially As the twenty-first century begins to unfold,
classic arcade games are ideal vehicles for we continue the frequently intense reflection on
learning to program. Games are important popular the previous century, and one of the areas under
cultural objects that should not be dismissed. scrutiny is formal education. The Taylorian model
Indeed, classic arcade games embody virtually all of education, that is, the scientific management of
of the components necessary for a thorough learning has, among other things, resulted in
grounding in software design, and can easily be widespread mathematical sequencing of
applied to many advanced topics. Various classic curriculum into uniform, incremental steps. This
arcade games are examined to demonstrate where has also resulted in the notion that the ‘proper’
they connect with computer science pedagogy. way to teach science is in a step-wise fashion,
beginning with very simple problems and
1. Introduction examples, and progressing slowly to more
complex ones [4], often culminating in “the
capstone course.” Perhaps it is no coincidence that
According to the Computing Research
the term used to describe such a course comes
Association’s report of May 2005, enrollment in
from masonry – a medium not renowned for its
computing science programs has declined an
malleability.
average of 39% since 2000 [1]. This trend shows
In Computer Science, this serial, graduated
no signs of abating, especially with the current
order of instruction resulted in novice ‘projects’
trend towards outsourcing of high tech jobs,
that involved writing programs that did little more
primarily to the Far East. Although there is an
than sort lists of simple data (like names). In more
unarguable drop in demand for high tech
recent times this has been updated to include
professionals, it is predicted that the drop in
writing programs to manage employee records –
demand will be considerably less than the drop in
maybe even implementing graphical interfaces for
enrollments [2]. This trend has many
the user menus. But, guess what? They are still
consequences, among them: How will we fill the
sorting lists, only now the data is more complex.
need for programmers of all kinds and games
The actual problem is much the same.
programmers in particular in the near future? How
Little by little, educators are beginning to
can we interest freshman in choosing computer
question the absoluteness of this serial, graduated
science? This is still where most of our games
order and considering more dynamic ones. Until
programmers begin. Part of the answer for both of
fairly recently, this has been “a hidden but
these questions is to teach programming by having
dominant aspect of contemporary curriculum,

becker-parker Page 1 9/19/2005 3:20 PM


from first grade through college. Only The challenge is to demonstrate that games
Kindergarten, and doctoral seminars seem able to embody many, if not all of the fundamental
develop more interactive, dynamic, and complex concepts important to a thorough grounding in
forms of order.” p. 36 [5] These days, terms like computer science.
deep learning, engagement, authentic learning,
and student-centered are in vogue. We’ve begun to 4. Games and Pedagogy
accept that we should come up with interesting,
engaging, and challenging problems for our Gameplay is directly tied to programming:
students to connect with. more complex gameplay = more complex and
However, we are often at a loss for ideas – we different algorithms to implement. Always. This
need problems that meet stated objectives, can be does not include simply adding more of
solved to a reasonable minimum standard, and yet something: the complexity of the program is
leave room to challenge the better students. Often roughly the same if you implement 5 lives for
additional functionality added to a typical Frogger as it would be if you were to implement
assignment simply involves more code without 5000. There is, however a difference between one
also requiring greater complexity. This is clearly and many, and an even greater difference between
not effective. We want the problems to be a frog that can be made to move across the road
interesting for our students while still forcing them and be killed by passing cars, and one that gets
into contact with the necessary content. If building killed by trucks, but thrown to another location by
on a student’s expertise results in a more engaging a car.
problem, we should look seriously at how students Games are highly visual. For one thing, if a
spend their time. Problems drawn from accounting student miscounts the number of objects to be
or management are common, but seriously, how drawn on the screen, it is immediately obvious.
many students do you know that do accounting as Students can see their algorithms in action. In
a hobby or pastime? other words, on-screen behaviour of the game
elements as well as the player control can often be
3. Games and Students mapped directly onto specific algorithms, and they
can be traced while the algorithm is running. This
Casual polls of students enrolled in the kind of immediate feedback is game-like itself,
introductory computer science class at the and tends to encourage experimentation with the
institution where the authors teach indicate that programs and algorithms. This cannot be said, for
two thirds to three quarters of all freshmen in example, of doing the monthly payroll run for our
computer science became interested in computer employee program.
science because they play computer and video The importance of program testing is also easy
games. This includes students who have not to convey within the context of games. Anyone
declared a major, and those who have declared who has ever played a game, which coincidentally
majors in other disciplines. At least half of the includes virtually all college students, recognize
students enrolled in the second introductory course the importance of a software product (i.e. their
express a desire to be involved in the games game) working properly. In fact approaches to
industry at a level beyond simply being testing can easily be related to what students
consumers. By and large, students understand already do while they are playing games (“Try it
games far better than they understand employee and see what happens.”). Further, the whole notion
records keeping, and ‘widget’ manufacturing, both of ‘cheats’ and cheat codes in games stems from
of which are sources of favorite entry-level testing elements that have remained in the game
programming problems. Current wisdom implies once it ships. This concept is extremely useful
that learning is most effective when we build on when discussing software testing and debugging.
what the learner already knows, and using Two common objections to the use of games,
situations they are familiar with [6, 7]. If they also aside from those objections that stem from a
care about these problems, that is even better. general disapproval of games as frivolous, are 1)
Students care about games. This is not in dispute. that the graphics (and audio) are irrelevant

becker-parker Page 2 9/19/2005 3:20 PM


anywhere but in a graphics course, and 2) that the games for the purposes of teaching programming,
event-driven nature of most games situate them in and they are interconnected.
a restricted sub-class of programming problem: i.e. First, classic arcade games are immediately
event-driven programming. The conclusion of familiar to most students, and many students
these objections is that games are applicable to already know how to play them. The value of fully
only a select set of courses, and to only a select set understanding how a program is supposed to work
of modules within those courses. is essential to the generation of correct solutions
To address the first objection, GUI’s are great and should not be underestimated. Minesweeper
fun, but admittedly complicate an already complex for example, while not a classic game, is still a
introduction to programming [8], and in the game that almost all students have tried - it is part
opinion of the authors, should not be the focus of of their PC (and has been for a very long time).
fundamental courses. The ACM curriculum lists This puts the problem they are to solve in a
GUI programming as a minor element in the context with which they are already familiar [10].
introductory sequence [9], and thus de- While the implementation of Minesweeper is no
emphasizing this aspect here will not put students more difficult than the well-known Game of Life
at a disadvantage. Many games can be (it is in fact marginally simpler), the difference is
implemented quite effectively without the use of that they knew Minesweeper when they were mere
sophisticated GUIs or graphics and sound, so this computer users. Writing it themselves and seeing
is not an essential element of games for our their efforts behave just like the real thing forces
purposes. Further, because of the state of hardware them to cross a significant perceptual boundary:
at the time these games were developed, classic they become the “creators”. They go from
arcade games lend themselves especially well to experiencing the “magic” to being the
this approach. “magicians”.
Secondly, the event-driven programming can Second, these games were designed when
be made optional in virtually all of the games hardware was limited and graphics were, relatively
described in this paper by converting them into speaking, crude. This means that the internal
turn-based play. Event-driven programming is complexity of the program is, relatively speaking,
admittedly a difficult concept. Early courses in CS low. It also means that we can afford to gloss over
and programming used to avoid event driven code some of the graphical aspects of games without
entirely, but more and more students are using loss of credibility, or student interest. In fact,
Java in first and second year. This language many of these games can be designed and built as
encourages objects early in the presentation ASCII games with nothing more than a
sequence, and can involve the use of events early monochrome text display. Past experience with
too, as they are connected to SWING and AWT this approach in a several first year classes
interfaces. Event-driven programming has become indicates that this approach has little negative
an element of the introductory sequence, albeit a impact on the students’ interest [11].
small one [9], and games can be created that both Implementing a game like Minesweeper, for
include, or exclude event-driven aspects. example, is a problem of a complexity that easily
compares with any other typical late-term first-
5. What’s So Special About Arcade year assignment. Conway’s Game of Life [12] is a
Games? long-time favorite, and although students generally
enjoy implementing this game, they do not get as
For the purposes of this paper, classic arcade excited about it as they do implementing
games are defined to include games that were Minesweeper.
traditionally found in the arcades of the late 70’s The third advantage of using arcade games as
and early 80’s (like Asteroids! and Space opposed to using newer commercial games or
Invaders) as well as games found on early home inventing our own is that multiple excellent
consoles (like Pong). There are three highly working examples exist out there for students to
significant advantages of these classic arcade try and play with (for free). This is sometimes
games over more modern or custom designed cited as an impediment to the use of these games
as assignments – namely – students can simply get

becker-parker Page 3 9/19/2005 3:20 PM


working solutions and attempt to pass them off as potions and bananas are treasures. Obstacles share
their own. True. They can. However, this claim is certain properties and behaviours as a group as
also true for the majority of programming well as having individual differences. Treasures
problems that are assigned to undergraduates, also share properties and attributes, yet it is pretty
regardless of domain. Teaching faculty have been obvious that there is a need for specific
inventing programming assignments for thirty or differences. This kind of clarity is much harder to
so years. Chances are high that somebody, achieve and appears much more contrived when
somewhere has created a solution to the problem using employee records.
you have posed, and offered it on the web. One Almost all games contain the same basic
effective way to address this problem is to allow concepts like list manipulation, subprograms,
students to demonstrate their understanding by random number use, error detection and
having them talk about their own programs and correction, and user interfaces, but some ‘classes’
explain various aspects of them as part of the of game are more valuable than others for
completion requirements. Anyone who didn’t demonstrating specific concepts:
write his or her own code would be unable to 1. Action shooters like Asteroids!, Missile
explain how it works. On the other hand, if they Command and Defender require collisions
can explain, then they have demonstrated that they detection algorithms and distance calculations.
understand the concepts even if they didn’t write 2. Pac-man is an excellent maze puzzle requiring
all the code themselves, and the goals of the path finding and chasing (tracking) algorithms.
assignment will have been met anyways. We still
3. Puzzle games like Tetris and Qbert involve 2D
win.
geometry, packing algorithms (even though the
To summarize, classic arcade games are
user/player does the packing, the program must
obviously a part of the game world that was
still be able to check the moves) and detection
responsible for attracting these students in the first
of reasonably complex win-states. These are
place, which provides an important real-world
excellent for practice with the development of
connection to drive their studies. The games
efficient condition checking.
currently have the added bonus of enjoying a
renaissance of popularity as ‘retro’ games. These 4. Blocks, Breakout!, and Pong all require physics
games were a part of popular culture when game (bouncing). These are perhaps the only group of
technology was far simpler; so they are part of the games best designed as real-time, event driven
culture, yet exist at a level that students can master programs. The games themselves are otherwise
as programmers. And finally, also because they fairly uncomplicated and so provide an effective
are part of this domain, there exist plenty of balance from a programming perspective.
working examples that students can turn to in 5. The side-scrolling platform action adventures
order to help themselves fully understand the like Mario Bros., Donkey Kong, Pitfall, and
problem, as well as to compare against their own Joust include everything from rudimentary
answers. physics to potentially complex inventory and
asset management, and various AI techniques.
6. Which Games Teach What Concepts? 6. Racing and driving games like Indy 500 and
Street Racer feature algorithms in physics, AI
The technology embodied in typical digital and collision detection, but of course can also
games means that almost any concept in computer include all levels (from novice to advanced) of
science is represented in some form in some game graphics, user interfaces, audio, and 3D
[13]. Object-oriented programming is the common animation. [14]
paradigm used in introductory courses. Virtually 7. Finally, Zork, one of the earliest commercially
all of these game programs can be used to available text-based adventure games, contains
demonstrate object-oriented programming, and all of the fundamental elements of modern role-
make the concepts of polymorphism and playing games, but without the multi-million
inheritance clear and straightforward: of course dollar development budget, timelines, and
trees and boulders are kinds of obstacles, while development teams. Role-playing games are

becker-parker Page 4 9/19/2005 3:20 PM


especially useful for practice in parsing, and this solution. The midrange solution will have 3
various AI algorithms. homes, 5 rows of vehicles, and a working Frog
who can move (but not necessarily jump) and
7. Adding or Removing Complexity ONE OF: two kinds of river beast, ---OR--- a
boulevard to rest on (with NO time limit for the
Novice problems are defined in this paper as Frog’s stay). The Frog should be able to ride on
those that have limited data types and complexity the critters in the river instead of sliding off. The
and contain a smaller number of distinct best solution will have 5 homes, 5 rows of
algorithms. They expressly do not require the use vehicles, one Frog, AND 5 rows of river beasts all
of object-oriented constructs like inheritance and working correctly. The boulevard will have a time
polymorphism. They are ideal for learners just limit, and the turtles must sometimes dive. The
beginning to program, they could be implemented "full-function" Frogger is bonus, and can be
in languages like ‘C’, or even Pascal, and posed in offered as a challenge for more advanced students.
a first course on programming. More complex It includes the girl Frog; alligators whose mouths
problems can be simplified by altering the open, and snakes on logs and on the boulevard.
gameplay, or providing ‘plug-ins’ (routines or Frogger himself should be permitted multiple
utilities that students can use without seeing the incarnations.
code inside) and so can also be turned into novice Note that each stage introduces not only a new
assignments. For example, the flood-fill algorithm level of complexity to the gameplay, but, more
in Minesweeper makes the game too complex for importantly from the perspective of its value as a
many novices because it requires an understanding programming assignment, introduces additional
of recursion, so providing a utility that does it for complexity to the programming in the form of new
them reduces the level of complexity to that algorithms.
roughly equivalent to the Game of Life. Similarly,
maze games and platform action side-scrollers can 8. Conclusions
have their ‘worlds’ simplified to allow a novice or
intermediate programmer to deal with the Arcade games have a great deal to offer as
programming issues at hand without becoming subjects for programming assignments. They
bogged down in issues that essentially deal with encompass all of the elements necessary for a
matters of degree, rather than kind. fundamental grounding in computer science as
Alternately, some of the “simpler” games can well as many aspects of more advanced study,
still be appropriate for more advanced classes by regardless of the student’s eventual application
focusing on animation, or graphics, or multi-player area. Classic arcade games are especially suited to
modes. The problem of saving state, even for a this task. Being part of the popular culture, these
text-based action game can become a problem in games are readily recognizable cultural objects,
file formats or data architecture. giving them a built-in connection to the real world,
Virtually all games listed here can be staged. thus creating the authenticity necessary for
Problems that can be staged are those that allow effective student engagement.
for varying levels of completion within the same A key requirement in the solution of any
assignment. For example, a game like Frogger problem is to fully understand that problem.
allows for multiple stages of completion with even Having a working example of a solution with
the simplest level having the attributes of a which students can interact is important. Having
working game. Frogger is a particularly good multiple examples is even better, but creating
example for it is currently playing a dual role as these for a newly made-up problem is time
both classic arcade game, and lightweight console consuming. Multiple working examples of classic
game. In Frogger, a low-level but still working arcade games already exist in the public domain.
solution would have only a single Frog that moves Modern games are typically very complex and
correctly on the screen, 2 rows of vehicles moving take full advantage of the latest developments in
in opposite directions along the highway and one hardware resources. Having been created with
home at the top. There is no boulevard or river in twenty-five year old technology, classic games are

becker-parker Page 5 9/19/2005 3:20 PM


perforce less sophisticated then newer games. This To close with one final thought, the more
means that recreating these objects is within the games get used as pedagogical tools, the more
reach of novice programmers, while modern they will gain in general acceptance. This is
games are generally not (Halo 2, anyone?). almost certain to be a good thing.

9. Appendix: Classic Games and What We Can Learn with Them

Classic Arcade Games


st nd
1 = 1 year; 2 = 2 year; 3+ = Senior level or Grad Course MP = can be designed as multiplayer
A/T = ASCII or Text-based; A/G = Animation and Graphics; T/P = Trajectories and other Physics; IM = Inventory Management
Y = Yes (blank = no) N = Novice, I = Intermediate, A = Advanced
Suitable for: Pedagogy
Game Type of game
1 2 3+ A/T A/G T/P IM MP Other algorithms
Asteroids! Action shooter Y Y Y Y N,I,A Y Y Collision, AI
Attaxx Reversi Y Y Y N Y Y AI
Blocks, Break Out Bouncing object Y Y Y N Y Y ?
Qbert Puzzle Y Y -
Frogger Simple strategy Y Y Y
Collision, path-
Indy 500, Street racer Racing Y Y Y IA Y Y
finding, AI
Lunar Lander Gravity, physics Y Y Y NIA Y
Minesweeper, Gold Monkey Grid puzzle Y Y Y Y Y Flood-fill
Missile Command, Defender Action shooter, vector Y Y Y NIA Y Y Y Distance, AI
Path-finding,
Pac Man Maze Y Y Y N Y
chasing
Donkey Kong, Joust, Mario Platform action adventure,
Y Y Y NIA ? Y Y Chasing, AI
Bros., Pitfall side-scrolling
Pong Bouncing object Y Y Y Y N Y Y
Space Invaders, Space war Shooter Vector Y Y Y NI Y Y ?
Tetris Puzzle, gravity, packing Y Y Y Y N,I Packing
Zork Text-based adventure Y Y Y Y Y Parsing, AI

10. References http://research.microsoft.com/ur/us/fundingopps/G


aming_curriculumRFP_awards.aspx, accessed:
[1] J. Vegso, "Interest in CS as a Major Drops Among July 28 2005.
Incoming Freshmen," in Computing Research [4] S. Cooper, W. Dann, and R. Pausch, "Teaching
News, vol. 17: Computing Research Association, Objects-first In Introductory Computer Science,"
2005, URL: presented at 34th SIGCSE Technical Symposium
http://www.cra.org/CRN/articles/may05/vegso. on Computer Science Education, Reno, Navada,
[2] S. Hamm, "Home Is Where The Work Is," in USA, 2003, URL:
Business Week Online, July 25, 2005 ed, 2005, http://portal.acm.org/citation.cfm?id=611966.
URL: [5] W. E. Doll, A post-modern perspective on
http://www.businessweek.com/magazine/content/0 curriculum. New York: Teachers College Press,
5_30/b3944048_mz011.htm. 1993.
[3] "Computer Game Production Curriculum 2004 [6] J. Lave and E. Wenger, Situated learning:
RFP Awards," in External Research and Programs: legitimate peripheral participation. Cambridge
Mocrosoft Reserach, 2005, [Electronic Source] [England]; New York: Cambridge University
Retrieved from: Press, 1991.

becker-parker Page 6 9/19/2005 3:20 PM


[7] J. S. Bruner, Toward a theory of instruction. sl: sn., Calgary, 2002, [Electronic Source] Retrieved from:
1966. http://www.ucalgary.ca/~jparker, accessed: July 20
[8] E. Roberts, "The dream of a common language: 2005.
The search for simplicity and stability in computer [14] J. R. Parker, Start Your Engines: Developing
science education.," presented at Thirty-Fifth Racing and Driving Games. Scotsdale, AZ:
SIGCSE Technical Symposium on Computer Paraglyph Press, 2005.
Science Education, Norfolk, VA, 2004, URL:
http://doi.acm.org/10.1145/971300.971343. First Year Programming Assignments:
[9] "Computing Curricula 2001: Final Report of the (note: if anyone has difficulty accessing these, please
Joint ACM/IEEE-CS Task Force on Computer send email to the author.)
Science Education," IEEE Computer Press, Los Minesweeper Assignment:
Alamitos, CA December 2001, URL: http://pages.cpsc.ucalgary.ca/~becker/235/Asst/Mine
http://www.acm.org/sigsce/cc2001. Sweeper/MineSweeper.html
[10] E. Soloway, "Learning to Program = Learning to Asteroids Assignment:
Construct Mechanisms and Explanations," http://pages.cpsc.ucalgary.ca/~becker/235/Asst/Aster
Communications of the ACM, Vol. 29 No. 9, pp. oids/Asteroids.html
p850-858, 1986. Space Invaders Assignment:
[11] K. Becker, "Teaching with games: the http://pages.cpsc.ucalgary.ca/~becker/235/Asst/Spac
Minesweeper and Asteroids experience," Journal of eInvaders/Invaders.html
Computing in Small Colleges, Vol. 17 No. 2, pp. Centipede Assignment:
23-33, 2001, URL: http://pages.cpsc.ucalgary.ca/~becker/235/Asst/Centi
http://www.cpsc.ucalgary.ca/~becker/Main/Papers/ pede/Centipede.html
Asteroids.htm. Tetris Assignment:
[12] E. R. Berlekamp, J. H. Conway, and R. K. Guy, http://pages.cpsc.ucalgary.ca/~becker/235/Asst/Tetri
Winning ways, for your mathematical plays. s/tetris.htm
London: Academic Press, 1982. Frogger Assignment:
[13] J. R. Parker and K. Becker, "The Use of Games in http://pages.cpsc.ucalgary.ca/~becker/235/Asst/Frog
the Undergraduate Computer Science Curriculum." ger/Frogger.html

becker-parker Page 7 9/19/2005 3:20 PM

View publication stats

You might also like