Re: extend robot.... overwrite fire()?
pepijndevos wrote:
> hi,
>
> i'm relatively new to both java and robocode.
> when i build a robot i extend one of JuniorRobot, Robot or
> AdvancedRobot.
>
You can also extend Droid or TeamRobot.
> then i overwrite the run() method to run my own code.
>
The correct term is override. =) However, most bots have a lot of code
in the event handlers, which you also override.
> but can i write a robot with some basic behavior and extend that
> instead of robot?
>
No, you cannot. Robocode will only recognize bots that are extended, and
thus linked in, with its internals. If you copied the code from the
robot class none of your methods like getX(), getGunHeading(), etc would
work because they would not receive the correct updates from the
Robocode engine.
> and can i overwrite methods like fire() or ahead()?
> if so, can i copy the source code from the robot class and edit it?
> imagin a fire() method that does not check for gun heat and does not
> decreas my life... rapidfire robot
Well, you could, but it would prevent the calls from reaching the parent
class, so nothing would actually happen.
Take a look at Robowiki.net for a bunch of ideas and code snippets.
Julian (aka Skilgannon)