One of the things I’m least likely to be doing (at similar positions in the list to “watching American Idol” and “krunking”) is playing flash-style internet games on websites that specialize in banner ads. However, I recently ended up playing this game called Light-Bot, which is the first game I’ve seen (though I expect there are many others – like I said, I don’t do this much) to incorporate basic computer programming concepts.
There’s a robot placed on a grid, and the player has to write a program to tell the robot what to do in order to accomplish the goal. The programming language consists of seven commands (go forward, turn right, jump, etc.), which are represented with pictures instead of words, and the player drags the pictures onto a program grid (not the grid the robot is on), and they are executed in the order specified.
Two of the commands are subroutine calls – there are two extra program grids representing the subroutines. It’s even possible to get the robot into an infinite loop by having a subroutine call itself. Also, each portion of a program has a maximum length – twelve commands for the main body, and eight commands for each subroutine. Part of the challenge is utilizing the subroutines well enough to fit the program in the allotted space.
It occurred to me that the levels in the game would be interesting candidates for a genetic algorithm experiment. The lack of syntax (any random blending of two programs will always be syntactically valid) and the limited length of the programs would make it easy to write a simulator, and the problem space could be quite challenging (I gave up on level nine or so). A related problem would be determining if a particular level is solvable or not. I’ll put it on my list of programming projects.
UPDATE: So I ended up doing this. You can read more about it on this post.