Games in Introductory Computer Science

Greetings all

I am a professor of computer science, and I’m always looking for exciting new projects to engage and challenge my students. I’m a gamer, and I enjoy using games to teach concepts of computer science. This semester, in my CS1 class, my students wrote a text-based adventure game set in a local state park; this project was based on John Estell’s SIGCSE Nifty assignment, which you can read about here: http://nifty.stanford.edu/2002/EstellNifty2002/

I also presented my students with the Robo Battle Pigs AI Challenge, which I wrote about here: http://www.java-gaming.org/forums/index.php?topic=11750.0 Unfortunately, few students took part in the RBP AI Challenge, which I attribute to the fact that it was an optional part of an optional assignment given at the end of an already-busy semester; we’ll try again next semester.

I started this thread to pick the collective brain for new ideas on games in computer science education. Did you develop any simple (CS1/CS2) games that helped you understand deeper concepts of CS? Do you have any ideas for such projects that would be exciting, engaging, and challenging, but also educational and solvable within a few weeks in CS1 or CS2?

Thank you for any thoughts you wish to share. I recently registered here, and I’ll be floating around the forums to join in the discussion as well.

What is CS1/CS2.

I doubt you mean that submarine sonar term.

  • a simple MUD
  • Tetris
  • Tic-Tac-Toe
  • Omok (graphically more challenging than Tic-Tac-Toe, but simpler than Tetris)

CS is Computer Science in this context.

I wish my cs professors give us tasks like those. Now in algorithm analisys and design our profesor continually speaks of algorithm that take hours to perform an array search (without exagerating), then, i get home and try to squeeze a milli or two from my game rendering loop :-\ . I have found really useful that subject, but the way i’m learning it is so disapointing.

One of the projects we had at uni was a networked multiplayer game (done in teams of 5ish). That was a rather good one as not only did we have to figure out syncronising multiple games across a network, but it was also a good introduction to proper multi-threading work (this being pre-NIO networking).

We ended up doing a remake of Chu-Chu Rocket. Annoyingly we were about the only team to choose the game project (there was a list of about 10) and lots of teams went for the rather easy “yet another website” option.

[quote]I started this thread to pick the collective brain for new ideas on games in computer science education.
[/quote]
I think there could be alot of value in using a game type project to get students excited about cs. But I question the actual pedagogical value of the excercise. Whats the model for teaching intro cs now? When I took it was read in a file, perform some function and output a file or a report. Not exactly what K+R C is good for, but you use what they give ya…

Anyway, what’s the goal in intro cs? To teach the students about real time applications (games, embedded systems)? Batch processing? Event driven applications? When I was in school all the business majors were required to take cs 101, so the real time and event driven stuff wouldn’t have served them very well. So sum up, it appears the approach should fit the audience.

Sorry about the jargon. CS1 and CS2 are traditional generic names for the first two introductory courses for computer science majors. They have different course numbers at different universities, so we adopt the “CS1/2” nomenclature. The syllabus for this sequence depends on the language and pedagogy being used, but in modern classes they usually include (using the Java names):

  • branching and selection using “if” and “switch” statements
  • loops (while, for, do)
  • functional decomposition, design of functions, actual vs. formal parameters
  • elementary OO design, semantics of inheritance and polymorphism
  • simple (quadratic) sorting algorithms, simple searching algorithms (e.g. binary search)

To use my own examples again, the simple text adventure game was designed to enforce the concepts of functional decomposition and modular program design. It was the largest program that the students wrote, and so they learned that the way one organizes ~100 lines of code does not scale up to ~1000 lines. (In a few semesters, they will hopefully learn how to deal with 10000+ lines too). The RBP AI Challenge problem was designed to enforce the logic of selection: processing game state, running it through a series of if/switch statements, and coming up with a well-formed response. This is the kind of project I’m especially interested in developing: something that’s fun but that also has explicit and well-defined educational goals, while still falling within the framework of the CS1/CS2 sequence.

Thanks to those who posted so far. Orangy Tang, what course level was the networked multiplayer game? I’d expect that at maybe 300-400 level, though I know of a few profs who have introduced RMI in CS2.

[quote]Thanks to those who posted so far. Orangy Tang, what course level was the networked multiplayer game? I’d expect that at maybe 300-400 level, though I know of a few profs who have introduced RMI in CS2.
[/quote]
FYI, most of these guys aren’t American so they’re most likely not familiar with our education system and the numbering of courses… :wink:

That would have been a second year, second semester project, although I have no idea what the US equivilant would be. No RMI though - we were just using plain old sockets and our own message protocol.

Ah, forgot about that. Apologies for any confusion. By “300-400” level above, I mean 3rd-4th year undergraduate courses.

In response to your other message, you make an excellent point, that the approach needs to fit the audience. From a practical standpoint, not all interesting game ideas can be incorporated into a class, since they may not match the educational goals in a given semester. I’m hoping that we can pool our resources and come up with some common threads of what makes a good game project for students.

I have one colleauge who had his CS2 students write a network-playable version of Scrabble that was pretty impressive. I think it was functional modulo special point squares (“double word score” etc) and dictionary checking. He used this example to introduce and reinforce many design patterns, as one of his pedagogic strategies involved the early introduction of objects and patterns. From what I gather, he was very happy with this, although it took the lion’s share of the semester to get it working.

I"ve been shown a Java based 3D environment that one university was using to engage beginning CS students.

I think it was RIT but I don’t entirely remember. It was a few years ago.

First of all, I’d hope you’re aware of http://www.experimentalgameplay.com/ - obviously, that’s not undergraduates, but every game was written in under a week. That’s some pretty serious inspiration.

Re: the robots, I’d imagine another issue could be that it’s just plain damn hard. Until you’ve spent a considerable amount of time writing logic for robotwars simulators, and learnt the dos and donts, there’s a really big steep learning curve to overcome in making the response’s in any way “effective”. If they aren’t effective, they aren’t encouraging.

IME, the best undergrad games (and non-games) were the ones:

  • very quickly got something intersting on the screen
  • had almost infinite directions for students to explore
  • could be run with very inefficient code perfectly effectively

For instance, one we had on our course was Mandelbrot generators. We were given the colour algorithm (hue-based) and told to render 10x10 pixel patches, on a window 400x400, and then when that was complete render over the top with 1x1 patches. We were also given screenshots of what a 400x400 @ 10x10 looked like with the given colour algo. Everyone could get to that point easily. Plenty of people screwed up, but they had very little code to check, and soon fixed it. People with terrible painting algorithms (they never taught ANY of the AWT rendering system :(, like paint/update/repaint/etc!) still could test and debug the 10x10 version rapidly, and if they started to get fed up with the 1x1 pixels being much slower could easily optimize it with anything that broke the algorithm also breaking the first-pass, so it again was quick to discover and fix bugs.

Other suggestions I’d give for particular games, from personal experience:

  • 2-player overhead racing game with two levels: one is all on one screen, the other is divided across four screens. Teaches a lot about OOP of co-ordinate systems, rendering algos, etc, and gives the opportunity to write smooth-scrolling by implementing a simplistic camera
  • 4-player networked board games, e.g. scrabble - simple rules, everyone already knows them off by heart, and there’s no dependence on performance at all, so ultra-simple use of BufferedReader and PrintWriter are all you need. Most students can get a simple one-to-many chat window running in java in just a couple of days, and that’s all you need to run most of such a game (with some basic parsing on incoming messages). Again, huge opportunities for students to research and evolve their networking into better, leaner, more effective API’s
  • flat-shaded triangle-rendered terrain that players “fly” over and attempt to shoot each other - this is stunningly simple to implement, with proper guidance, and yet incredibly impressive to most people with no programming background, who are generally amazed to be able to make their own 3D system so rapidly. It also has the twin benefit of showing (for many people for what is, sadly, the first time in their lives) how incredibly useful maths is in real-world / game dev situations - I’ve seen a lot of people who found vector algebra extremely dull change their minds when they discovered that the relatively small amount of rules they had to learn are enough to build arbitrarily complex 3D renderers. This is especially true in showing them how the effort of memorizing and mastering the fundamentals of vector algebra provide a toolset that for every graphical problem they encounter they can nearly always break it up into a series of basic algebra ops, and so “invent” for themselves nifty rendering effects etc.

(it also has the benefit of sidestepping something painful in games dev - character/ground collision detection + walking on a 3d landscape)

You could have students creating a simple Chatbot- it’s not exactly a game but it covers most of the areas you mentioned as well as teaching the importance of separating data and code ( one of the things it’s easy to miss as a student, cramming everything into variables in the source rather than reading it in from an external source ) and chatbots are quite amusing- I remember the fun we had when we first downloaded a version of Eliza and started adjusting the conversations paths in it.

You could probably get similar outcomes from an Animal/Vegetable/Mineral type guessing game, come to think of it- that has a very simple interface to design and although the entertainment value is questionable the A/V/M keyrings seem to be curiously popular at the moment.

If your looking for games to demonstrate specific programming concepts. text adventures are just big state engines.

For my second CS course in college, the final project was to edit a very basic 2D engine into a game. The professor alternated each semester, assigning Space Invaders one, and Centipede another. Everything was pre-written except the game’s logic. It was up to the student to glue all the pieces together.

The game was managed by a 2 dimentional array. Objects were placed in the array according to their location. The array was very small (15x15), so locations were limited, and thus the game was very simple. The pre-written code received the array and drew graphics to the screen. The array actually held Image objects (java.awt.Image). An element was null if there was nothing to be drawn.

Not many students finished the final project. I think there were 2 or 3 out of 50 who completed it. (Hell yeah I completed it- with an A!) The project definatly turned me on to game programming. Right after I finished the project I ripped apart the pre-written engine files and decompiled them. I used them as a starting point for my own engine. I eventually found my way here and the rest is history.

The final project wasn’t just plunked down on students. Every assignment throughout the semester had some graphical component. The class’s first assignment had students move a “Dog” to its “Bone”. The assignment’s premise was to teach students about objects and how to talk to them. Adding a small graphical component to simple assignments really seems to help make things click with beginning students. It doesn’t have to be much. Sometimes students just need to “see” that their code is doing something. Even a simple “Hello World” assignment can be made more interesting if the program displays “Hi!” as a graphic rather than a text dump. What’s even better is if you expose the advanced code so students can play around with things. Perhaps give extra credit to those who figure out how to do special things. Idealy, assignments should have basic requirements for an A grade, but also have additional criteria students can look into if they are interested. This gives curious people something to wet their appetite.

[quote] flat-shaded triangle-rendered terrain that players “fly” over and attempt to shoot each other - this is stunningly simple to implement, with proper guidance, and yet incredibly impressive to most people with no programming background, who are generally amazed to be able to make their own 3D system so rapidly.
[/quote]
blah:

any suggestions for where I could go to get more details on this? My ap high school kids would LOVE it.