I’ve seen programming games that can teach you Java by programming the AI of your robot. Of course, it was Java specific, and as nice as Java might be, there could still be some reasons for you to want to learn something else. Other games might teach their own language, which wouldn’t be very useful directly. Enter RealTimeBattle.
RealTimeBattle is a programming game, in which robots controlled by programs are fighting each other. The goal is to destroy the enemies, using the radar to examine the environment and the cannon to shoot. You can play RTB on many different platforms, but my favorite feature is the fact that robots can be constructed in almost any programming language.
You talk to the server by using the standard input and output. You don’t need any specific functions from a library. You just need to be able to send and receive regular text. What you do with the information might make use of various properties of your specific language, but so long as you can manipulate text, you can program a robot to compete.
RTB is now at version 1.0.8.