Getting Started
- In the Robot menu, select Editor
- If you haven't created a robot before, you will be asked to give your robot a name. You will also be asked for your initials.
- The editor will then display a sample Java class file where the your robot's name is the class name. Your task is to edit this file to program your robot's behavior.
Behavior
You will notice a method called run containing an infinite loop. This method is executed at the start of a battle. The loop repeatedly runs the robot's primary behavior. Behaviors your robot can do include:
- moving
- Rotating
- Rotating the turret
- Rotating the scanner. The scanner sits on the robot's turret and will rotate as the turret does. When the scanner detects another robot, your robot's scanner event method will be called. The scanner can also be rotated independently, but this is tricky.
- Firing a bullet. Bullets can be fired with varing forces. However, bullet fireing heats up the robuts gun; too hot, and the gun won't fire until it cools. The heat generated by the bullet depends on its force.
Events
Much of your code will be methods that are called in reaction to an event. Events that can be responded to include:
- Hitting another robot with your bullet
- Being hit by another robot's bullet
- Hitting another robot
- Hitting a wall
- Detecting another robot with your scanner.
- Your death of the death of another robot. (Some robots have been know to do a agony or victory dance.)
Each event method is passed a parameter that contains information about the event, such as the bearing
Attributes
You can retrieve your robots attributes, such as energy (life) level, gut temperature, bearing, etc.
API
For details on how to program a robot see the My First Robot description, http://robowiki.net/wiki/Robocode/My_First_Robot, and the Robot API: http://robocode.sourceforge.net/docs/robocode/
Comments (0)
You don't have permission to comment on this page.