Package robocode
Class _RobotBase
java.lang.Object
robocode._RobotBase
- All Implemented Interfaces:
Runnable
,IBasicRobot
- Direct Known Subclasses:
_Robot
,JuniorRobot
This is the base class of all robots used by the system.
You should not inherit your robot on this class.
You should create a robot that is derived from the Robot
, AdvancedRobot
,
JuniorRobot
, TeamRobot
, or RateControlRobot
class instead.
- Since:
- 1.4
- Author:
- Flemming N. Larsen (original), Pavel Savara (contributor)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe output stream your robot should use to print. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
finalize()
Called by the system to 'clean up' after your robot.final void
setOut
(PrintStream out) Do not call this method!final void
setPeer
(IBasicRobotPeer peer) Do not call this method! Your robot will simply stop interacting with the game.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface robocode.robotinterfaces.IBasicRobot
getBasicEventListener, getRobotRunnable
-
Field Details
-
out
The output stream your robot should use to print.You can view the print-outs by clicking the button for your robot in the right side of the battle window.
Example:
// Print out a line each time my robot hits another robot public void onHitRobot(HitRobotEvent e) { out.println("I hit a robot! My energy: " + getEnergy() + " his energy: " + e.getEnergy()); }
-
-
Method Details
-
finalize
Called by the system to 'clean up' after your robot. You may not override this method. -
setOut
Do not call this method!This method is called by the game when setting the output stream for your robot.
- Specified by:
setOut
in interfaceIBasicRobot
- Parameters:
out
- the new output print stream for this robot
-
setPeer
Do not call this method! Your robot will simply stop interacting with the game.This method is called by the game. A robot peer is the object that deals with game mechanics and rules, and makes sure your robot abides by them.
- Specified by:
setPeer
in interfaceIBasicRobot
- Parameters:
peer
- the robot peer supplied by the game
-