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 :).
If you want to correct this text (especially my english), you will be welcomed. -- Synnalagma
Other consideration you want to add
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