TeamRobot (Robocode 1.2.4-Beta API)

Overview | Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## robocode
Class TeamRobot

    java.lang.Object
      robocode._Robot
          robocode.Robot
              robocode._AdvancedRobot
                  robocode._AdvancedRadiansRobot
                      robocode.AdvancedRobot
                          robocode.TeamRobot

All Implemented Interfaces:
  java.lang.Runnable

    public class TeamRobot

extends AdvancedRobot

An advanced type of robot that supports messages between teammates.

If you have not already, you should create a `Robot` first.

Author:
  Mathew A. Nelson (original)
See Also:
  `Robot`

Field Summary

Fields inherited from class robocode.Robot
`out`

Constructor Summary
`TeamRobot()`

Method Summary
`void` | `broadcastMessage(java.io.Serializable message)` Broadcasts a message to all teammates Example public void run() { broadcastMessage("I'm here!")
`java.lang.String[]` | `getTeammates()` Returns an array of your teammates names Example public void run() { String[] teammates = getTeammates(); for (int i = 0; i < teammates.length; i++) System.out.println(teammates[i]); }
`boolean` | `isTeammate(java.lang.String name)` Checks if a given robot name is one of your teammates.
`void` | `onMessageReceived(MessageEvent event)` This method will be called when your robot receives a message from a teammate.
`void` | `sendMessage(java.lang.String name, java.io.Serializable message)` Sends a message to one (or more) teammates Example public void run() { sendMessage("sample.DroidBot","I'm here!")

Methods inherited from class robocode.AdvancedRobot
`addCustomEvent, clearAllEvents, execute, getAllEvents, getBulletHitBulletEvents, getBulletHitEvents, getBulletMissedEvents, getDataDirectory, getDataFile, getDataQuotaAvailable, getDistanceRemaining, getEventPriority, getGunTurnRemaining, getHitByBulletEvents, getHitRobotEvents, getHitWallEvents, getRadarTurnRemaining, getRobotDeathEvents, getScannedRobotEvents, getTurnRemaining, isAdjustGunForRobotTurn, isAdjustRadarForGunTurn, isAdjustRadarForRobotTurn, onCustomEvent, onDeath, onSkippedTurn, removeCustomEvent, setAhead, setBack, setEventPriority, setFire, setFireBullet, setInterruptible, setMaxTurnRate, setMaxVelocity, setResume, setStop, setStop, setTurnGunLeft, setTurnGunRight, setTurnLeft, setTurnRadarLeft, setTurnRadarRight, setTurnRight, waitFor`

Methods inherited from class robocode._AdvancedRadiansRobot
`getGunHeadingRadians, getGunTurnRemainingRadians, getHeadingRadians, getRadarHeadingRadians, getRadarTurnRemainingRadians, getTurnRemainingRadians, setTurnGunLeftRadians, setTurnGunRightRadians, setTurnLeftRadians, setTurnRadarLeftRadians, setTurnRadarRightRadians, setTurnRightRadians, turnGunLeftRadians, turnGunRightRadians, turnLeftRadians, turnRadarLeftRadians, turnRadarRightRadians, turnRightRadians`

Methods inherited from class robocode._AdvancedRobot
`endTurn, getGunHeadingDegrees, getHeadingDegrees, getMaxWaitCount, getRadarHeadingDegrees, getWaitCount, setTurnGunLeftDegrees, setTurnGunRightDegrees, setTurnLeftDegrees, setTurnRadarLeftDegrees, setTurnRadarRightDegrees, setTurnRightDegrees, turnGunLeftDegrees, turnGunRightDegrees, turnLeftDegrees, turnRadarLeftDegrees, turnRadarRightDegrees, turnRightDegrees`

Methods inherited from class robocode.Robot
`ahead, back, doNothing, finalize, fire, fireBullet, getBattleFieldHeight, getBattleFieldWidth, getEnergy, getGunCoolingRate, getGunHeading, getGunHeat, getHeading, getHeight, getName, getNumRounds, getOthers, getRadarHeading, getRoundNum, getTime, getVelocity, getWidth, getX, getY, onBulletHit, onBulletHitBullet, onBulletMissed, onHitByBullet, onHitRobot, onHitWall, onPaint, onRobotDeath, onScannedRobot, onWin, resume, run, scan, setAdjustGunForRobotTurn, setAdjustRadarForGunTurn, setAdjustRadarForRobotTurn, setAllColors, setBodyColor, setBulletColor, setColors, setColors, setGunColor, setRadarColor, setScanColor, stop, stop, turnGunLeft, turnGunRight, turnLeft, turnRadarLeft, turnRadarRight, turnRight`

Methods inherited from class robocode._Robot
`getBattleNum, getGunCharge, getGunImageName, getLife, getNumBattles, getRadarImageName, getRobotImageName, setGunImageName, setPeer, setRadarImageName, setRobotImageName, uninitializedException`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TeamRobot

    public TeamRobot()

Method Detail

### isTeammate

    public boolean isTeammate(java.lang.String name)

  Checks if a given robot name is one of your teammates.

  Example

         public void onScannedRobot(ScannedRobotEvent e)
         {
             if (isTeammate(e.getName())
                 return;
             else
                 fire(1);
         }

  Parameters:
    `name` - The name to check

### getTeammates

    public java.lang.String[] getTeammates()

  Returns an array of your teammates names

  Example

         public void run()
         {
             String[] teammates = getTeammates();
             for (int i = 0; i < teammates.length; i++)
                 System.out.println(teammates[i]);
         }

  Returns:
    String array containing teammate names

### broadcastMessage

    public void broadcastMessage(java.io.Serializable message)
                          throws java.io.IOException

  Broadcasts a message to all teammates

  Example

         public void run()
         {
             broadcastMessage("I'm here!");
         }

  Parameters:
    `message` - The message to broadcast
  Throws:
    `java.io.IOException`

### sendMessage

    public void sendMessage(java.lang.String name,
                            java.io.Serializable message)
                     throws java.io.IOException

  Sends a message to one (or more) teammates

  Example

         public void run()
         {
             sendMessage("sample.DroidBot","I'm here!");
         }

  Parameters:
    `name` - The intended recipient of the message
    `message` - The message to broadcast
  Throws:
    `java.io.IOException`

### onMessageReceived

    public void onMessageReceived(MessageEvent event)

  This method will be called when your robot receives a message from a teammate. You should override it in your robot if you want to be informed of this event.

  Example

         public void onMessageReceived(MessageEvent event) {
           out.println(event.getSender() + " sent me: " + event.getMessage());
         }

  Parameters:
    `event` - The event set by the game
  See Also:
    `MessageEvent`, `Event`

Overview | Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD