|
||||||||
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,
RobotLevel height)
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(Message msg)
Adds a message for your robot to broadcast. |
|
boolean |
canAttackSquare(MapLocation loc)
Returns true if the given location is within this 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 o is within sensor range. |
|
boolean |
canSenseSquare(MapLocation loc)
Returns true if this robot can sense the location loc . |
|
Message[] |
getAllMessages()
Retrieves an array of all the messages in your incoming message queue. |
|
long |
getControlBits()
Gets this robot's 'control bits' for debugging purposes. |
|
Direction |
getDirection()
Gets the direction this robot is currently facing. |
|
double |
getEnergon()
Gets the current energon of this robot. |
|
double |
getFlux()
Returns this robot's current flux level. |
|
MapLocation |
getLocation()
Gets the current location of this robot. |
|
double |
getMaxEnergon()
Gets the maximum energon of this robot. |
|
Message |
getNextMessage()
Retrieve the next message waiting in your incoming message queue. |
|
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. |
|
boolean |
hasBroadcasted()
Returns true if this robot has already broadcasted this turn. |
|
boolean |
isAttackActive()
Returns true if this robot's attack cooldown is nonzero. |
|
boolean |
isMovementActive()
Returns true if this robot's movement cooldown is nonzero. |
|
void |
moveBackward()
Queues a backward movement to be performed at the end of this robot's turn. |
|
void |
moveForward()
Queues a forward movement to be performed at the end of this robot's turn. |
|
void |
regenerate()
Causes each allied robot within its attack radius to regenerate GameConstants.REGEN_AMOUNT energon at the beginning
of its next turn. |
|
void |
resign()
Causes your team to lose the game. |
|
int |
roundsUntilAttackIdle()
Returns the number of rounds until this robot's attack cooldown reaches zero. |
|
int |
roundsUntilMovementIdle()
Returns the number of rounds until this robot's movement cooldown reaches zero. |
|
MapLocation[] |
senseAlliedArchons()
Returns the locations of all the archons on the calling robot's team. |
|
PowerNode[] |
senseAlliedPowerNodes()
Returns an array containing all of the power nodes owned by this robot's team. |
|
MapLocation[] |
senseCapturablePowerNodes()
Returns an array containing the locations of all of the nodes that this team can capture. |
|
boolean |
senseConnected(PowerNode p)
Returns true if the node p is connected to
this robot's team's power core. |
|
MapLocation |
senseLocationOf(GameObject o)
Sense the location of the object o . |
|
|
senseNearbyGameObjects(Class<T> type)
Sense objects of type type that are within this sensor's range. |
|
GameObject |
senseObjectAtLocation(MapLocation loc,
RobotLevel height)
Returns the object at the given location and height, or null
if there is no object there. |
|
boolean |
senseOpponentConnected(PowerNode p)
Returns true if the node p is connected to
this robot's team's opponent's power core. |
|
boolean |
senseOwned(PowerNode p)
Returns true if there is an allied tower at the power node p . |
|
PowerNode |
sensePowerCore()
Returns this robot's team's power core. |
|
RobotInfo |
senseRobotInfo(Robot r)
Sense the RobotInfo for the robot r . |
|
TerrainTile |
senseTerrainTile(MapLocation loc)
Senses the terrain at loc , if loc was ever
within this robot's sensor range. |
|
void |
setDirection(Direction dir)
Queues a direction change to be performed at the end of this robot's turn. |
|
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(RobotType type)
Queues a spawn action to be performed at the end of this robot's turn. |
|
void |
suicide()
Kills your robot and ends the current round. |
|
void |
transferFlux(MapLocation loc,
RobotLevel height,
double amount)
Transfers the specified amount of flux to the robot at location loc and RobotLevel height . |
|
void |
yield()
Ends the current round. |
Method Detail |
---|
double getEnergon()
double getMaxEnergon()
double getFlux()
MapLocation getLocation()
Direction getDirection()
Message getNextMessage()
Message[] getAllMessages()
Team getTeam()
this.getRobot().getTeam()
.
Team
Robot getRobot()
RobotType getType()
GameObject senseObjectAtLocation(MapLocation loc, RobotLevel height) 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)
type
that are within this sensor's range.
MapLocation senseLocationOf(GameObject o) throws GameActionException
o
.
GameActionException
- if o
is not within sensor range (CANT_SENSE_THAT)RobotInfo senseRobotInfo(Robot r) throws GameActionException
r
.
GameActionException
- if r
is not within sensor range (CANT_SENSE_THAT)boolean canSenseObject(GameObject o)
o
is within sensor range.
boolean canSenseSquare(MapLocation loc)
loc
.
MapLocation[] senseAlliedArchons()
PowerNode[] senseAlliedPowerNodes()
MapLocation[] senseCapturablePowerNodes()
boolean senseConnected(PowerNode p)
true
if the node p
is connected to
this robot's team's power core. Note that p
does not need to
be within sensor range.
boolean senseOwned(PowerNode p)
true
if there is an allied tower at the power node p
.
Note that p
does not need to be within sensor range.
boolean senseOpponentConnected(PowerNode p) throws GameActionException
true
if the node p
is connected to
this robot's team's opponent's power core.
GameActionException
- if p
is not within this robot's sensor range (CANT_SENSE_THAT)PowerNode sensePowerCore()
int roundsUntilMovementIdle()
boolean isMovementActive()
void moveForward() throws GameActionException
type().moveDelayOrthogonal
for
orthogonal movement and type().moveDelayDiagonal
for
diagonal movement).
GameActionException
- if this robot is already moving (ALREADY_ACTIVE)
GameActionException
- if this robot does not have enough flux to move (NOT_ENOUGH_FLUX)
GameActionException
- if the destination terrain is not traversable by
this robot (CANT_MOVE_THERE)
GameActionException
- if the destination is occupied by another GameObject
at the same height (CANT_MOVE_THERE)void moveBackward() throws GameActionException
GameActionException
moveForward()
void setDirection(Direction dir) throws GameActionException
dir
- the direction the robot should face
GameActionException
- if this robot is already moving (ALREADY_ACTIVE)boolean canMove(Direction dir)
int roundsUntilAttackIdle()
boolean isAttackActive()
boolean canAttackSquare(MapLocation loc)
void attackSquare(MapLocation loc, RobotLevel height) throws GameActionException
SCORCHER
, attacks every square in the robot's
attack range at ground level instead; loc
and height
are ignored.
GameActionException
- if this robot's attack cooldown is not zero (ALREADY_ACTIVE)
GameActionException
- if this robot is not a SCORCHER
and it cannot attack the given height or location (OUT_OF_RANGE)boolean hasBroadcasted()
void broadcast(Message msg) throws GameActionException
You are charged a small amount of flux for every message that you
broadcast. The cost of sending a message is equal to
(GameConstants.BROADCAST_FIXED_COST +
GameConstants.BROADCAST_COST_PER_BYTE*sizeBytes)
where sizeBytes
is the size of the message, in bytes.
Each robot can only broadcast one message per round.
msg
- the message you want to broadcast; cannot be null
.
GameActionException
- if this robot already has a message queued in the current round (ALREADY_ACTIVE).
GameActionException
- if this robot does not have enough flux to pay for the broadcast (NOT_ENOUGH_FLUX).void spawn(RobotType type) throws GameActionException
GameConstants.WAKE_DELAY
rounds.
type
- the type of robot to spawn; cannot be null.
IllegalStateException
- if this robot is not an ARCHON
GameActionException
- if this robot is currently moving (ALREADY_ACTIVE)
GameActionException
- if this robot does not have enough flux to spawn a robot of type type
(NOT_ENOUGH_FLUX)
GameActionException
- if loc
is already occupied (CANT_MOVE_THERE)void transferFlux(MapLocation loc, RobotLevel height, double amount) throws GameActionException
loc
and RobotLevel height
. The robot
receiving the transfer must be adjacent to or in the same location as the
robot giving the transfer. Robots may not transfer more flux than they
currently have.
amount
- the amount of flux to transfer to the specified robotloc
- the MapLocation
of the robot to transfer toheight
- the RobotLevel
of the robot to transfer to
IllegalArgumentException
- if amount
is negative, zero, or NaN.
GameActionException
- if the robot does not have amount
flux (NOT_ENOUGH_FLUX).
GameActionException
- if loc
is not the same as or adjacent to this robot's location (CANT_SENSE_THAT).
GameActionException
- if there is no robot at the given location and height (NO_ROBOT_THERE).void yield()
GameConstants.YIELD_BONUS * GameConstants.UNIT_UPKEEP * Clock.getBytecodesLeft() / GameConstants.BYTECODE_LIMIT
.
Never fails.
void suicide()
void resign()
void regenerate() throws GameActionException
GameConstants.REGEN_AMOUNT
energon at the beginning
of its next turn. Each robot may only regenerate once per turn.
This action can only be activated by scouts and costs
GameConstants.REGEN_COST
flux.
IllegalStateException
- if this robot is not a scout
GameActionException
- if this robot does not have GameConstants.REGEN_COST
flux (NOT_ENOUGH_FLUX)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)
loc
, if loc
was ever
within this robot's sensor range. Otherwise, returns null
.
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 |