From RoboWiki
Jump to: navigation, search

A group of robots can be packaged together as a team. Robots on a team should extend TeamRobot so that they can identify teammates and send/receive messages to/from teammates. There are two active competitions that make use of teams: the Teams division of the RoboRumble uses 5-bot teams, and the Twin Duel uses 2-bot teams.


Teams 101

Some basic concepts that will not help you to make a good team, but can clarify the ideas:

A team is a group of bots that fight together to beat an enemy team. You can make a team of as many bots as you want, but teams are usually made of 5 bots. Bots in a team can be of different classes, or they can be 5 instances of the same bot.

You implement them by extending the TeamRobot class, that provides some functions to exchange information about bots and to check if a bot is your friend or your foe. Robocode provides also an special interface called Droid, which allows you to implement a special kind of bot without radar, but with an extra 20 energy. When you create a team, the first bot in it is the "leader" and gets an extra 100 energy (200 total, or 220 for a Droid leader).

Note that team play allows for a wide range of team types. For example:

  • 1 team leader (with radar) + 4 droids (without radar, but with 20 extra energy, that receive orders from the leader).
  • 5 normal team bots of the same class.
  • 5 normal bots of different classes (note that you could specialize them in some way).
  • Any combination of the above (e.g., 1 leader + 2 droids + 2 normal bots).
  • 5 droids.

Teams with droids have the advantage of having more energy, but suffer from lack of information and get in serious troubles if the leader gets killed.

Of course, the good part of teams is that they work together to win the battle. There are many different ways to make them work together, and for sure the way they coordinate will make the difference.

  • The simplest way is a collusion where bots belonging to a team avoid shooting each other.
  • A more advanced team will exchange information about themselves and the enemies to gather intelligence and decide their actions.
  • Another step could be to coordinate the bots to avoid "colliding" (in a wide sense) and may be coordinating fire.
  • Next step should be to create real team strategies, for example flock movements.

Implementing a team creates some problems that you won't find in 1v1 or melee. For example:

  • Assigning the "good spots" to the bots (only one at one spot).
  • Dealing with friendly fire and line-of-sight.
  • Coordinating team movements.
  • Identifying the bots on your team.

Identifying teammates

To determine if a bot is a teammate, you can use the TeamRobot.isTeammate(String name) method. For instance, from onScannedRobot(ScannedRobotEvent e), you may have something like if (isTeammate(e.getName())) { return; }, so that you don't target your teammates.

For specifically identifying each member on your team (e.g., for coordinating team efforts and assigning specific roles), you will need to do a little work.

All teammates of same class

If every bot on your team is an instance of the same class, it is easy to identify each one because Robocode assigns each bot a specific number.

static public int getBotNumber(String name) {
 	String n = "0";
 	int low = name.indexOf("(")+1; int hi = name.lastIndexOf(")");
 	if (low >= 0 && hi >=0) { n = name.substring(low, hi); }
 	return Integer.parseInt(n);

Teammates of any mix of classes

The above approach won't work if there is more than one class of bots in a team because for each class, the numbering starts back at 1. For example:

LeaderBot (no number if there is only one of them)
BigBadBot 1
BigBadBot 2
SmallGoodBot 1
SmallGoodBot 2

So how do you deal with a situation like this?

if(getEnergy()>199.0){ //220 if leader is a droid, 200 otherwise.
	String[] teammates = getTeammates();
	Vector v = new Vector();
	for(int i = 0; i < teammates.length; i++){
	teammates = (String[]) v.toArray();
	}catch(Exception e){}

Then just have all bots store the String[] message and do lookups in that array to get the ID of a bot. (Bot ID = position in array.)

Team styles

To date, the best 5-bot teams are simply 5 instances of a strong Melee bot with some basic team awareness, such as avoiding friendly fire and staying away from each other. Polylunar is the highest ranking 5-bot team that deviates from this pattern, using an aggressive style of close-range/gang-up movement strategy. There has not been much effort put into teams-specific strategy, so there is still room for exploration in team play.

In the Twin Duel, LunarTwins (ancestor of Polylunar) is a very successful team that uses a close-range/gang-up style of movement, which is extremely effective in 2v2. Some Twin Duel teams use a 1v1 style of movement (e.g., KomariousTeam), but most other successful teams use a hybrid style of movement and strategy that is similar to Melee.

Personal tools