Robocode Lesson: My First Robot

We're going to get our feet wet and make our very first bot!

The following directions assume you have Robocode installed and running. If this is not the case, you need to fix that before reading on.

Robot Editor

  1. With the Robocode program open, click on the 'Robot' menu and the 'Editor' item.
  2. It should give you a little dialog saying it's found a JDK to work with. Click 'OK' to tell it to use the one it found. (If it didn't find anything, you need to install the JDK. You can get it from java.sun.com, or possibly my server.)
  3. With the Robot Editor open, click on the 'File' menu, the 'New' submenu, and the 'Robot' item.
  4. Type in a name for your bot. It does not have to be the name for the bot you will use for the showdown, just [YourName]Bot will work fine. (i.e. JimBot, JulioBot, RufusBot, BuffyBot, etc.)
  5. Next you will be prompted for a package name. Enter your initials. You can make as many bots as you like, but they should all belong to the same package (i.e. use your initials here (and the same set of initials) every single time).
  6. It may give you a message that the directory does not exist. Click 'OK' to tell it to create the directory for you.
  7. You should now be staring at some boilerplate code. Give it a look see and check out what's going on. If you want an explanation of some of the methods, consult the Robocode API.
  8. Compile the code by clicking on the 'Compiler' menu and the 'Compile' option. It may offer to save the file for you, tell it 'OK'. Unless you've made any changes, it should compile successfully. (If it doesn't compile, you get to figure out what you broke and fix it.)

Let Him Fight!

  1. Minimize (or close) the Robot Editor and return to the original Robocode program.
  2. Click the 'Battle' menu and the 'New' item.
  3. If the bot you just made doesn't show up in the list of bots in the dialog, hit 'F5' and it will refresh the list. (If your bot does show up, hitting 'F5' with neither hurt nor help the situation.)
  4. When your bot shows up, double-click on it to add it to the battle, along with several other of the 'sample' bots (your choice).

    To pass it off, let me see it running.

    Print up and turn in the source code ([YourName]Bot.java) file. You cannot print it from the Robot Editor, you will have to open the file in Notepad or JCreator and print it from there.