I would like to get battle results as it is displayed in final table. I want to start battle, which contains let's say 10 rounds and get final results (percent of total points which were obtained by my robot).
There are events/methods onBattleEnded and onBattleCompleted. The first one doesn't have % value and the second seems to be of internal use.
Any idea? Is it possible?
Best regards,
Marcin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I would like to get battle results as it is displayed in final table. I want to start battle, which contains let's say 10 rounds and get final results (percent of total points which were obtained by my robot).
There are events/methods onBattleEnded and onBattleCompleted. The first one doesn't have % value and the second seems to be of internal use.
Any idea? Is it possible?
Best regards,
Marcin
Hi Marcin,
You can control Robocode by creating your own Java application by using the RobocodeEngine class. It is easy to use, and an example is provided here:
http://robocode.sourceforge.net/docs/robocode/robocode/control/package-summary.html
You can add your own IBattleListener implementation to the RobocodeEngine through this method (addBattleListener on RobocodeEngine):
http://robocode.sourceforge.net/docs/robocode/robocode/control/IRobocodeEngine.html#addBattleListener(robocode.control.events.IBattleListener)
You just need to implement the onBattleCompleted(BattleCompletedEvent):
http://robocode.sourceforge.net/docs/robocode/robocode/control/events/IBattleListener.html#onBattleCompleted(robocode.control.events.BattleCompletedEvent)
The BattleCompletedEvent contains the information you need:
http://robocode.sourceforge.net/docs/robocode/robocode/control/events/BattleCompletedEvent.html
... where you can call getIndexedResults() og getSortedResults()
Now it should be trivial to print out the data - just like you want them by extracting data from the BattleResult instances:
http://robocode.sourceforge.net/docs/robocode/robocode/BattleResults.html
I hope this helps?
Thank you, I will try it.
Marcin