Skip to main content

skip to main content

developerWorks  >  Java technology  >

Secrets from the Robocode masters: RoboLeague

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Introductory

Christian Schnell (Christian.D.Schnell@t-online.de), Student, Technical University of Berlin

Jun 2002

This tip was published in the "Cloak and turret: Learn secrets from the Robocode masters" article in the May 2002 issue of the IBM developerWorks journal.

Sooner or later, many engaged robot authors want to learn about the others. What other robots are out there? Which of them can defeat my bot, who had better not challenge me and why? This is how I felt after a while, so I surfed around and found out that there is a need for RoboLeague.

Design a league

There are several ways to approach building a league. My initial idea was to have a global, open-ended league of robots. The set of robots should be allowed to change and updates to individual robots should be allowed without affecting their rank. As I found more than 200 robot classes, I decided on the well-known league/division model that is applied often in sports to reduce the number of fights (which, of course, grows exponentially with the league size). This model splits the league into several divisions, plays them through, promotes and demotes at neighboring divisions, and calls that a season. This model is open-ended in contrast to tournament models, but there is a good chance that tournament models will be supported in the future.

Cooperatively, Mathew Nelson (creator of Robocode) and I worked out proper interfaces for the Robocode game engine to use the engine as an object, instead of only as a process. This (together with other improvements) reduced the time for a single battle around factor 10 and cleared the path for bigger division sizes. A second obstacle I came across was non-conforming robot names. To solve this, robots have editable names in RoboLeague.

Early in the design, I decided to present results to the user in HTML, making it easy to publish them on the Internet. I turned that design decision into an opportunity to get in touch with Extensible Markup Language (XML) in Java programming. Consequently, all persistent data produced by RoboLeague is formatted in XML, and the HTML pages are produced by means of XSL Transformations (XSLT). (The XSLT files are editable to the user, yielding something like HTML "skins.") I will use XSLT XML to XML transformations to implement (the unavoidable) updates on the persistent XML structures, avoiding data loss as much as possible.

Internally, RoboLeague is composed of:

  • Robot directory. Maps between symbolic and Robocode robot class and versions. Figure 1 shows the Robot directory window, displaying the known robots currently installed along with their name, class name, and version.

  • Grouping engine. Uses the Robocode game engine and implements the execution of groupings (simple battles with symbolic names) on it.

  • Division engine. Uses a Grouping engine and implements the execution of a division's seasons on it.

  • League engine. Uses a Division engine and implements the execution of a league's seasons on it and the GUI classes.

Figure 1. The robot directory window, showing which known robots are currently installed (among other things)
The robot directory window, showing which known robots are currently installed (among other things)

Note that Grouping, Division, and League are different competition models. Each of them is designed as an engine class, an engine listener interface, and a data model class that encapsulates the engine's setup and results data. RoboLeague keeps XML in the outermost classes to make it one of several ways of storing data model objects persistently. This approach allows external projects to easily embed each engine. Other tournament-like competition models may be added in the future.

Apart from the absolute ranking (all divisions concatenated), an individual results page is produced for each robot, on which any 1-on-1 meeting that it has fought in the past is considered and shown summed per opponent. Figure 2 shows part of the GUI for league setup.


Figure 2. Super league setup
Super league setup

Figures 3 and 4 show the results for a season and individual robot, respectively. You can clearly see there that every robot has its strengths (well, almost) and weaknesses. At the end, every one of them has their own little challenge.


Figure 3. The HTML results front page, showing the results of the latest season
The HTML results front page, showing the results of the latest season

Figure 4. The HTML details page for robot cs.Lurch
The HTML details page for robot cs.Lurch


Back to top


Host or participate in a league

From the RoboLeague Web page (see Resources), download RoboLeague and start your own private league today. Alternatively, join a league, such as The Gladiatorial League, or declare yourself the administrator of a public league and post rules for participants like the following to start your own tournaments:

  1. Download Robocode from the IBM alphaWorks Robocode Web site.
  2. Create a bot.
  3. Upload your bot to the tournament site.
  4. Check back in a week to see the current results and standings of your bot.
  5. Download opponents that have beaten you and fine tune your robot strategies.
  6. Upload your improved bot to the tournament site and see if you improve in the standings.

Want to enter a tournament and see how your own bot fares against the competition? Visit the IBM alphaWorks Robocode Web page (see Resources) to find the latest tournaments and learn how to enter them.



Resources

  • Read all of the Secrets from the Robocode masters . This page will be updated as new tips become available.

  • Robocode's creator, Mathew Nelson, maintains the official Robocode site. This should be the first stop for anyone serious about Robocode.

  • RoboLeague by Christian Schnell is a league and season manager for Robocode. It ensures that all possible groupings indeed play their matches, manages the results, and produces HTML status reports.

  • "Rock 'em, sock 'em Robocode" (developerWorks, January 2002) disarms Robocode and starts you on your way to building your own customized lean, mean, fighting machine.

  • In "Rock 'em, sock 'em Robocode: Round 2" (developerWorks, May 2002), Sing Li looks at advanced robot construction and team play.

  • New to Java? Check out "Introduction to Java programming" (developerWorks, November 2004), a tutorial that steps you through the fundamentals of Java language programming.

  • developerWorks: Hundreds of articles about every aspect of Java programming.


About the author

Christian Schnell is currently finishing his Diplom in Informatik at the Technical University of Berlin and has worked on RDBM and other projects.




Rate this page


Please take a moment to complete this form to help us better serve you.



YesNoDon't know
 


 


12345
Not
useful
Extremely
useful
 


Back to top