|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RobotController
A RobotController allows contestants to make their robot sense and interact
with the game world. When a contestant's RobotPlayer
is
constructed, it is passed an instance of RobotController
that
controls the newly created robot.
Method Summary | ||
---|---|---|
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)
ARTILLERY only Attacks the given location and height. |
|
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)
ARTILLERY only |
|
boolean |
canMove(Direction dir)
Tells whether this robot can move in the given direction. |
|
boolean |
canSenseObject(GameObject o)
|
|
boolean |
canSenseSquare(MapLocation loc)
Returns true if the given location is within the team's shared sensor range |
|
void |
captureEncampment(RobotType type)
Captures the encampment soldier is standing on. |
|
int |
checkResearchProgress(Upgrade upgrade)
HQ ONLY. |
|
void |
defuseMine(MapLocation loc)
SOLDIER only Defuses a mine on the target square. |
|
long |
getControlBits()
Gets this robot's 'control bits' for debugging purposes. |
|
double |
getEnergon()
|
|
MapLocation |
getLocation()
|
|
int |
getMapHeight()
|
|
int |
getMapWidth()
|
|
Robot |
getRobot()
Use this method to access your robot. |
|
double |
getShields()
|
|
Team |
getTeam()
Gets the Team of this robot. |
|
long[] |
getTeamMemory()
Returns the team memory from the last game of the match. |
|
double |
getTeamPower()
|
|
RobotType |
getType()
Gets this robot's type (SOLDIER, HQ, etc.) |
|
boolean |
hasUpgrade(Upgrade upgrade)
Checks whether a given upgrade has been researched and is available. |
|
boolean |
isActive()
|
|
void |
layMine()
SOLDIER only Lays mines. |
|
void |
move(Direction dir)
Move in the given direction if possible. |
|
int |
readBroadcast(int channel)
Retrieves the message stored at the given radio channel. |
|
void |
researchUpgrade(Upgrade upgrade)
HQ ONLY. |
|
void |
resign()
Causes your team to lose the game. |
|
int |
roundsUntilActive()
|
|
MapLocation[] |
senseAllEncampmentSquares()
|
|
MapLocation[] |
senseAlliedEncampmentSquares()
|
|
double |
senseCaptureCost()
Checks how much power it costs to start a capture an encampment on this turn |
|
boolean |
senseEncampmentSquare(MapLocation loc)
Checks if the given map location is an encampment square. |
|
MapLocation[] |
senseEncampmentSquares(MapLocation center,
int radiusSquared,
Team team)
Senses all encampment squares owned by the given team within the given circular area Allows a team-based filter which can be one of the following parameters: Null - Senses _all_ encampments on the map Neutral - Senses all encampments not owned by the allied team, so neutral or enemy Allied Team - Senses all encampments owned by the allied team Note that you cannot sense all enemy-owned encampments |
|
MapLocation |
senseEnemyHQLocation()
|
|
boolean |
senseEnemyNukeHalfDone()
Senses the enemy team's NUKE research progress - only HQ can do this |
|
MapLocation |
senseHQLocation()
|
|
MapLocation |
senseLocationOf(GameObject o)
Sense the location of the given object. |
|
Team |
senseMine(MapLocation location)
Senses whether a mine exists at a given location |
|
MapLocation[] |
senseMineLocations(MapLocation center,
int radiusSquared,
Team team)
Returns all mines within a given search radius specified by the parameters |
|
int |
senseMineRoundsLeft()
SOLDIER only Checks how many rounds are left for the current mine being laid, if any. |
|
|
senseNearbyGameObjects(Class<T> type)
Returns all game objects of a given type nearby the robot |
|
|
senseNearbyGameObjects(Class<T> type,
int radiusSquared)
Returns all game objects of a given type nearby the robot |
|
|
senseNearbyGameObjects(Class<T> type,
int radiusSquared,
Team team)
Returns all game objects of a given type nearby the robot of a given team |
|
|
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 |
|
MapLocation[] |
senseNonAlliedMineLocations(MapLocation center,
int radiusSquared)
Similar to senseMineLocations(MapLocation, int, Team) except the team is "non-allied"
which includes both known enemy and neutral mines. |
|
GameObject |
senseObjectAtLocation(MapLocation loc)
Returns the object at the given location, or null
if there is no object there. |
|
RobotInfo |
senseRobotInfo(Robot r)
Sense the RobotInfo for the given robot. |
|
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 |
spawn(Direction dir)
HQ ONLY. |
|
void |
suicide()
Kills your robot and ends the current round. |
|
void |
wearHat()
Puts a hat on the robot. |
|
void |
yield()
Ends the current round. |
Method Detail |
---|
double getEnergon()
double getShields()
double getTeamPower()
MapLocation getLocation()
int getMapWidth()
int getMapHeight()
Team getTeam()
this.getRobot().getTeam()
.
Team
Robot getRobot()
RobotType getType()
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 returned
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[] senseAllEncampmentSquares()
senseEncampmentSquares(MapLocation, int, Team)
MapLocation[] senseAlliedEncampmentSquares()
senseEncampmentSquares(MapLocation, int, Team)
MapLocation[] senseEncampmentSquares(MapLocation center, int radiusSquared, Team team) throws GameActionException
center
- - center location of circle to search for encampment squaresradiusSquared
- - radius around the center to search for encampment squaresteam
- - team filter (null, allied team, or neutral team, see usage above)
GameActionException
- - attempting to search all enemy encampment squaresTeam senseMine(MapLocation location)
location
- to scan
MapLocation[] senseMineLocations(MapLocation center, int radiusSquared, Team team)
center
- - center of the search arearadiusSquared
- - radius around the center to include minesteam
- - only return mines of this team. If null is passed, all team's mines are returned
MapLocation[] senseNonAlliedMineLocations(MapLocation center, int radiusSquared)
senseMineLocations(MapLocation, int, Team)
except the team is "non-allied"
which includes both known enemy and neutral mines.
center
- - center of the search arearadiusSquared
- - radius around the center to include
senseMineLocations(MapLocation, int, Team)
MapLocation senseHQLocation()
MapLocation senseEnemyHQLocation()
boolean senseEnemyNukeHalfDone() throws GameActionException
GameActionException
- if not HQboolean senseEncampmentSquare(MapLocation loc)
int roundsUntilActive()
boolean isActive()
void move(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
void broadcast(int channel, int data) throws GameActionException
channel
- - the channel to write to, from 0 to MAX_RADIO_CHANNELS
data
- - one int's worth of data to write
GameActionException
int readBroadcast(int channel) throws GameActionException
channel
- - radio channel to query, from 0 to MAX_RADIO_CHANNELS
GameActionException
void spawn(Direction dir) throws GameActionException
dir
- the direction to spawn robot in
IllegalStateException
- if this robot is not the HQ
GameActionException
- if this robot is currently inactive (NOT_ACTIVE)
GameActionException
- if location is already occupied (CANT_MOVE_THERE)boolean hasUpgrade(Upgrade upgrade)
upgrade
- cannot be nullvoid layMine() throws GameActionException
GameActionException
int senseMineRoundsLeft() throws GameActionException
GameActionException
void defuseMine(MapLocation loc) throws GameActionException
GameActionException
void captureEncampment(RobotType type) throws GameActionException
type
-
GameActionException
double senseCaptureCost()
void researchUpgrade(Upgrade upgrade) throws GameActionException
upgrade
-
GameActionException
int checkResearchProgress(Upgrade upgrade) throws GameActionException
upgrade
-
GameActionException
void yield()
GameConstants.POWER_COST_PER_BYTECODE * (GameConstants.BYTECODE_LIMIT
- RobotMonitor.getBytecodesUsed())
.
Never fails.
void suicide()
void resign()
void wearHat() throws GameActionException
GameActionException
void setIndicatorString(int stringIndex, String newString)
stringIndex
- the index of the indicator string to set. Must satisfy
stringIndex >= 0 && stringIndex < GameConstants.NUMBER_OF_INDICATOR_STRINGS
newString
- 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 game
ArrayIndexOutOfBoundsException
- if index
is less
than zero or greater than or equal to GameConstants.TEAM_MEMORY_LENGTH
getTeamMemory()
,
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 set
ArrayIndexOutOfBoundsException
- if index
is less
than zero or greater than or equal to GameConstants.TEAM_MEMORY_LENGTH
getTeamMemory()
,
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()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |