battlecode.common
public interface RobotController
RobotPlayer is
constructed, it is passed an instance of RobotController that
controls the newly created robot.| Modifier and Type | Method and Description |
|---|---|
void |
addMatchObservation(String observation)
Adds a custom observation to the match file, such that when it is analyzed, this observation will appear.
|
void |
attackSquare(MapLocation loc)
Attacks the given location
Also applies to NOISETOWER, but does not deal damage in that case
Creates a long-range noise at the targeted location
|
void |
attackSquareLight(MapLocation loc)
NOISETOWER only
'Attacks' the given location
Does not deal damage, but creates a short-range noise at the targeted location
|
void |
breakpoint()
If breakpoints are enabled, calling this method causes the game engine to
pause execution at the end of this round, until the user decides to
resume execution.
|
void |
broadcast(int channel,
int data)
Broadcasts a message to the global message board.
|
boolean |
canAttackSquare(MapLocation loc)
Returns whether the given location is within the robot's attack range.
|
boolean |
canMove(Direction dir)
Tells whether this robot can move in the given direction.
|
boolean |
canSenseObject(GameObject o)
Returns true if the given object is within the robot's sensor range
|
boolean |
canSenseSquare(MapLocation loc)
Returns true if the given location is within the robot's sensor range
|
void |
construct(RobotType type)
After a delay, kills the soldier and spawns a robot of the given building type
|
double |
getActionDelay()
Gets the robot's current action delay.
|
int |
getConstructingRounds()
Returns the number of turns left in the current construction.
|
RobotType |
getConstructingType()
Returns the RobotType of the structure the robot is constructing.
|
long |
getControlBits()
Gets this robot's 'control bits' for debugging purposes.
|
double |
getHealth()
Gets the robot's current health (hitpoints).
|
MapLocation |
getLocation()
Gets the robot's current location.
|
int |
getMapHeight() |
int |
getMapWidth() |
Robot |
getRobot()
Use this method to access your robot.
|
Team |
getTeam()
Gets the Team of this robot.
|
long[] |
getTeamMemory()
Returns the team memory from the last game of the match.
|
RobotType |
getType()
Gets this robot's type (SOLDIER, HQ, etc.)
|
boolean |
isActive()
Returns if the robot is active (able to move, construct, and attack)
|
boolean |
isConstructing()
Returns whether the robot is currently constructing a structure.
|
void |
move(Direction dir)
Move in the given direction if possible
Creates a short-range noise at the destination location
|
int |
readBroadcast(int channel)
Retrieves the message stored at the given radio channel.
|
void |
resign()
Causes your team to lose the game.
|
int |
roundsUntilActive()
Returns the number of rounds until the robot is active again
|
void |
selfDestruct()
Kills your robot and deals area damage within distanceSquared 2 equal to
GameConstants.SELF_DESTRUCT_BASE_DAMAGE plus the robot's current hp multiplied by GameConstants.SELF_DESTRUCT_DAMAGE_FACTOR. |
MapLocation[] |
senseBroadcastingRobotLocations()
Returns an array of all the locations of the robots that have broadcasted in the last round (unconstrained by sensor range or distance)
|
MapLocation[] |
senseBroadcastingRobotLocations(Team t)
Returns an array of all the locations of the robots that have broadcasted in the last round, filtered by team (unconstrained by sensor range or distance)
|
Robot[] |
senseBroadcastingRobots()
Returns an array of all the robots that have broadcasted in the last round (unconstrained by sensor range or distance)
|
Robot[] |
senseBroadcastingRobots(Team t)
Returns an array of all the robots that have broadcasted in the last round, filtered by team (unconstrained by sensor range or distance)
|
double[][] |
senseCowGrowth()
Gives a representation of the cow growths of each location of the map (unconstrained by sensor range or distance)
|
double |
senseCowsAtLocation(MapLocation loc)
Returns the number of cows currently at a given location.
|
MapLocation |
senseEnemyHQLocation()
Returns location of the enemy team's HQ (unconstrained by sensor range or distance)
|
MapLocation |
senseHQLocation()
Returns location of the allied team's HQ (unconstrained by sensor range or distance)
|
MapLocation |
senseLocationOf(GameObject o)
Sense the location of the given object.
|
<T extends GameObject> |
senseNearbyGameObjects(Class<T> type)
Returns all game objects of a given type nearby the robot
|
<T extends GameObject> |
senseNearbyGameObjects(Class<T> type,
int radiusSquared)
Returns all game objects of a given type nearby the robot
|
<T extends GameObject> |
senseNearbyGameObjects(Class<T> type,
int radiusSquared,
Team team)
Returns all game objects of a given type nearby the robot of a given team
|
<T extends GameObject> |
senseNearbyGameObjects(Class<T> type,
MapLocation center,
int radiusSquared,
Team team)
Senses all game objects of a given type within a given search area specified by the parameters (constrainted by sensor range and distance)
|
GameObject |
senseObjectAtLocation(MapLocation loc)
Returns the object at the given location, or
null
if there is no object there. |
MapLocation[] |
sensePastrLocations(Team t)
Returns the locations of PASTRS filtered by a team (unconstrained by sensor range or distance)
|
int |
senseRobotCount()
Gets the team's current robot count (with weighting).
|
RobotInfo |
senseRobotInfo(Robot r)
Sense the RobotInfo for the given robot.
|
double |
senseTeamMilkQuantity(Team t)
Sense the milk level for a given team.
|
TerrainTile |
senseTerrainTile(MapLocation loc)
Senses the terrain at the given location.
|
void |
setIndicatorString(int stringIndex,
String newString)
Sets one of this robot's 'indicator strings' for debugging purposes.
|
void |
setTeamMemory(int index,
long value)
Sets the team's "memory", which is saved for the next game in the
match.
|
void |
setTeamMemory(int index,
long value,
long mask)
Sets this team's "memory".
|
void |
sneak(Direction dir)
Sneak in the given direction if possible
|
void |
spawn(Direction dir)
HQ ONLY.
|
void |
wearHat()
Puts a hat on the robot.
|
void |
win() |
void |
yield()
Ends the current round.
|
double getActionDelay()
double getHealth()
MapLocation getLocation()
int getMapWidth()
int getMapHeight()
Team getTeam()
this.getRobot().getTeam().TeamRobot getRobot()
RobotType getType()
boolean isConstructing()
RobotType getConstructingType()
int getConstructingRounds()
double senseTeamMilkQuantity(Team t)
int senseRobotCount()
GameObject senseObjectAtLocation(MapLocation loc) throws GameActionException
null
if there is no object there.GameActionException - if loc is not within sensor range (CANT_SENSE_THAT)<T extends GameObject> T[] senseNearbyGameObjects(Class<T> type)
senseNearbyGameObjects(Class, MapLocation, int, Team)<T extends GameObject> T[] senseNearbyGameObjects(Class<T> type, int radiusSquared)
senseNearbyGameObjects(Class, MapLocation, int, Team)<T extends GameObject> T[] senseNearbyGameObjects(Class<T> type, int radiusSquared, Team team)
senseNearbyGameObjects(Class, MapLocation, int, Team)<T extends GameObject> T[] senseNearbyGameObjects(Class<T> type, MapLocation center, int radiusSquared, Team team)
type - - type of game object to sense, eg: Robot.classcenter - - center of the given search radiusradiusSquared - - return objects this distance away from the centerteam - - filter game objects by the given team. If null is passed, objects from all teams are returnedRobot[] senseBroadcastingRobots()
Robot[] senseBroadcastingRobots(Team t)
t - - filter robots by the given team.MapLocation[] senseBroadcastingRobotLocations()
MapLocation[] senseBroadcastingRobotLocations(Team t)
t - - filter robots by the given team.MapLocation senseLocationOf(GameObject o) throws GameActionException
GameActionException - if object is not within sensor range (CANT_SENSE_THAT)RobotInfo senseRobotInfo(Robot r) throws GameActionException
GameActionException - if robot is not within sensor range (CANT_SENSE_THAT)boolean canSenseObject(GameObject o)
boolean canSenseSquare(MapLocation loc)
MapLocation senseHQLocation()
MapLocation senseEnemyHQLocation()
MapLocation[] sensePastrLocations(Team t)
t - - filter PASTR locations by the given teamdouble[][] senseCowGrowth()
double senseCowsAtLocation(MapLocation loc) throws GameActionException
loc - - location to sense at (must be within sensor range)GameActionExceptionint roundsUntilActive()
boolean isActive()
void move(Direction dir) throws GameActionException
dir - GameActionException - if the robot cannot move in this directionvoid sneak(Direction dir) throws GameActionException
dir - GameActionException - if the robot cannot move in this directionboolean canMove(Direction dir)
boolean canAttackSquare(MapLocation loc)
void attackSquare(MapLocation loc) throws GameActionException
GameActionException - if the robot cannot attack the given squarevoid attackSquareLight(MapLocation loc) throws GameActionException
GameActionException - if the robot cannot attack the given squarevoid broadcast(int channel,
int data)
throws GameActionException
channel - - the channel to write to, from 0 to BROADCAST_MAX_CHANNELSdata - - one int's worth of data to writeGameActionException - if the channel is invalidint readBroadcast(int channel)
throws GameActionException
channel - - radio channel to query, from 0 to BROADCAST_MAX_CHANNELSGameActionException - if the channel is invalidvoid spawn(Direction dir) throws GameActionException
dir - the direction to spawn robot inGameActionException - if this robot is not the HQ (CANT_DO_THAT_BRO)GameActionException - if this robot is currently inactive (NOT_ACTIVE)GameActionException - if location is already occupied (CANT_MOVE_THERE)GameActionException - if the maximum robot count has already been reached (CANT_DO_THAT_BRO)void construct(RobotType type) throws GameActionException
type - GameActionException - if it's not a soldier constructing or if the soldier is not constructing a structurevoid yield()
void selfDestruct()
throws GameActionException
GameConstants.SELF_DESTRUCT_BASE_DAMAGE plus the robot's current hp multiplied by GameConstants.SELF_DESTRUCT_DAMAGE_FACTOR.
Destroys all cows in all effected squares and creates a long-range noise at the robot's former locationGameActionException - if it's not a soldiervoid resign()
void win()
void wearHat()
throws GameActionException
GameActionException - if you have action delay or if you do not have enough milkvoid setIndicatorString(int stringIndex,
String newString)
stringIndex - the index of the indicator string to set. Must satisfy
stringIndex >= 0 && stringIndex < GameConstants.NUMBER_OF_INDICATOR_STRINGSnewString - the value to which the indicator string should be setTerrainTile senseTerrainTile(MapLocation loc)
long getControlBits()
void addMatchObservation(String observation)
observation - the observation you want to inject into the match filevoid setTeamMemory(int index,
long value)
GameConstants.TEAM_MEMORY_LENGTH
longs. If this method is called more than once with the same index
in the same game, the last call is what is saved for the
next game.index - the index of the array to setvalue - the data that the team should remember for the next gameArrayIndexOutOfBoundsException - if index is less
than zero or greater than or equal to GameConstants.TEAM_MEMORY_LENGTHgetTeamMemory(),
setTeamMemory(int, long, long)void setTeamMemory(int index,
long value,
long mask)
setTeamMemory(int, long) provides. For example,
if mask == 0xFF then only the eight least significant bits of
the memory will be set.index - the index of the array to setvalue - the data that the team should remember for the next gamemask - indicates which bits should be setArrayIndexOutOfBoundsException - if index is less
than zero or greater than or equal to GameConstants.TEAM_MEMORY_LENGTHgetTeamMemory(),
setTeamMemory(int, long)long[] getTeamMemory()
GameConstants.TEAM_MEMORY_LENGTH.
If setTeamMemory was not called in the last game, or there was no last game, the
corresponding long defaults to 0.setTeamMemory(int, long),
setTeamMemory(int, long, long)void breakpoint()