[Home]RobocodeDeathMatch/PortingYourBot

Robo Home | RobocodeDeathMatch | Changes | Preferences | AllPages

Difference (from prior author revision) (major diff, minor diff)

Changed: 1,16c1,16

Basic rules



To port your bot you need to extend DeathMatchRobot? (which extends AdvancedRobot). Then you need to rename some methods:
* You must rename run() to runDeathMatch()(it behaves exactly the same as your good old run method, but it is recalled every time you respawn).
* onHitByBullet?(robocode.HitByBulletEvent?) to onHitByBulletDM?(same parameter)
* onHitWall?(robocode.HitWallEvent?) to onHitWallDM?(same parameter)
* onHitRobot?(robocode.HitRobotEvent?) to onHitRobotDM?(same parameter)
* it's easier if you rename onScannedRobot(robocode.ScannedRobotEvent) to onScannedRobotDM?(same parameter) because your bot has now 500 energy and dies when you have 400 (and then respawns with 500). The event in onScannedRobot will return energy - 400. It's as you want.

Some others things:




* getEnergy() returns the energy -400; that means energy until you are killed (normal).
* public ScoreDM? getScore() returns an object from which you can get the score of each bot (how many kills and deaths).
* int getFragLimit?() returns the limit of frags after which the game stops or 0 if there's no frag limit.
* long getTimeLimit?() returns the time limit in ticks, or 0 if there's no time limit.
* the event received in onRobotDeath?(robocode.RobotDeathEvent?) is in fact a robocode.RobotDeathEventDM?. You can invoke one more method: String getKiller().
* the same appears for onDeath: the event received in onDeath(robocode.DeathEvent?) is in fact a robocode.DeathEventDM?. You can invoke one more method: String getKiller(), if you want vengence :).

Basics



*In order to play in RDM, your bot need to extends robocode.DeathMatchRobot?.
*Just build your bot as usual the same methods are available.
*The only things you need to do is rename the run() methods to runDeathMatch().
*That's all!!!

On the robocode screen you will see that your bot as between 400 and 500 energy, this is normal. But the getEnergy() and ScannedRobotEvent.getEnergy() will still return a number between 0 and 100 (can be negative if a bot is dead).

Additional methods



*public long getTimeLimit?() : return the time limit for this game, if the time limit is 0 the no time limit is used, see rules for more info about time limit.
*public int getFragLimit?() : return the frag limit for this game, if the frag limit is 0 the no frag limit is used, see rules for more info about frag limit.
* public ScoreDM? getScore() : return a ScoreDM? object wich contain the number of frag and death for each bot, call get public ScoreDM?.RobotScore? getScore(String robotName) to get the score for a particular bot, see rules for more info about score.
* onRobotDeath?(robocode.RobotDeathEvent?) : Is called by the game when a bot is dead and will reappear. The event is in fact a robocode.RobotDeathEventDM? (wich is a subclass of RobotDeathEvent?) wich contain one more method : public String getKiller() and will return the name of the killer.
* onDeath(robocode.DeathEvent?) : Is called by the game when your bot is dead and will reappear. The event is in fact a robocode.DeathEventDM? (wich is a subclass of DeathEvent?) wich contain one more method : public String getKiller() and will return the name of the killer. So if you are thinking about vengeance...


Changed: 22c22,27
Interesting... Are you sure there's not a way around renaming all these methods? With CoopRobot, nothing needs to be renamed, and all the same stuff is accomplished. I can email you the source code to CoopRobot if you'd like to see how it's done; the only reason it's not open source is so people don't modify it and introduce incompatibility issues with their bots. -- Vuen

Old discussion since it's fixed :) -- Synnalagma

Interesting... Are you sure there's not a way around renaming all these methods? With CoopRobot, nothing needs to be renamed, and all the same stuff is accomplished. I can email you the source code to CoopRobot if you'd like to see how it's done; the only reason it's not open source is so people don't modify it and introduce incompatibility issues with their bots. -- Vuen

Great proposition, I tried to think about it but not found a solution since getAllEvents? (and all this methods) don't have the event already dispatched. My email is synnalagma__AT__hotmail.com -- Synnalagma

Basics

On the robocode screen you will see that your bot as between 400 and 500 energy, this is normal. But the getEnergy() and ScannedRobotEvent.getEnergy() will still return a number between 0 and 100 (can be negative if a bot is dead).

Additional methods

If you want to correct this text (especially my english), you will be welcomed. -- Synnalagma

Other consideration you want to add

Old discussion since it's fixed :) -- Synnalagma

Interesting... Are you sure there's not a way around renaming all these methods? With CoopRobot, nothing needs to be renamed, and all the same stuff is accomplished. I can email you the source code to CoopRobot if you'd like to see how it's done; the only reason it's not open source is so people don't modify it and introduce incompatibility issues with their bots. -- Vuen

Great proposition, I tried to think about it but not found a solution since getAllEvents? (and all this methods) don't have the event already dispatched. My email is synnalagma__AT__hotmail.com -- Synnalagma


Robo Home | RobocodeDeathMatch | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited November 9, 2003 15:30 EST by Synnalagma (diff)
Search: