|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object robocraft.player.AbstractRobotPlayer
This is the class that contestants will need to extend and implement (in a file RobotPlayer.java). Player actions are performed by calling methods of this class (which inherently remembers which robot ID is associated with it). In addition, subclasses may reference the same methods in GameObject or Robot, but without worrying about exceptions being thrown. For example, call this.getTeam() to get your own team without worrying about an exception being thrown. (Instead of calling getRobot().getTeam()).
Field Summary |
Constructor Summary | |
AbstractRobotPlayer()
|
Method Summary | |
void |
attackAir(MapLocation targetLoc)
Initiate an attack on the AIR in a specified location. |
void |
attackGround(MapLocation targetLoc)
Initiate an attack on the GROUND in a specified location. |
void |
broadcastMessage(Message msg)
Broadcasts a message to all Robots currently in your broadcast range. |
static boolean |
canAttackAir()
wrapper for corresponding Robot method; does not throw an exception |
static boolean |
canAttackGround()
wrapper for corresponding Robot method; does not throw an exception |
static boolean |
canAttackSquare(MapLocation loc)
wrapper for corresponding Robot method that does not throw an exception |
static boolean |
canMove(Direction dir)
wrapper for corresponding Robot method; does not throw an exception. |
static boolean |
canSenseObject(GameObject obj)
wrapper for corresponding Robot method; does not throw an exception |
static boolean |
canSenseSquare(MapLocation loc)
wrapper for corresponding Robot method; does not throw an exception |
void |
depositFlag()
Deposit the flag you are carrying into the square in front of you. |
Robot |
getAirRobotAtLocation(MapLocation loc)
Sense any Robots IN THE AIR at this location. |
static double |
getAttackPower()
wrapper for corresponding Robot method; does not throw an exception |
static int |
getBytecodesPerRound()
wrapper for corresponding Robot method; does not throw an exception |
static ActionType |
getCurrentAction()
wrapper for corresponding Robot method; does not throw an exception |
static Direction |
getDirection()
wrapper for corresponding Robot method; does not throw an exception |
static double |
getEnergonLevel()
wrapper for corresponding Robot method; does not throw an exception |
static Team |
getFlagTeam()
Returns whether your robot is currently carrying a flag. |
Robot |
getGroundRobotAtLocation(MapLocation loc)
Sense any Robots ON THE GROUND at this location. |
static MapLocation |
getLocation()
wrapper for corresponding GameObject method; does not throw an exception |
Message |
getNextMessage()
Retrieve the next message waiting in your message queue. |
static Robot |
getRobot()
Use this method to access your robot |
static int |
getRoundsUntilIdle()
wrapper for corresponding Robot method; does not throw an exception |
static Team |
getTeam()
wrapper for corresponding GameObject method; does not throw an exception |
TerrainType |
getTerrainType(MapLocation loc)
Sense the terrain type at a MapLocation. |
static RobotType |
getType()
wrapper for corresponding GameObject method; does not throw an exception |
int |
getUnitCount(RobotType type)
Get the number of units of a certain RobotType on your team. |
static boolean |
isActive()
wrapper for corresponding Robot method; does not throw an exception |
boolean |
isMapShrinking()
Return whether or not the map is in a state of overtime where it shrinks. |
void |
layMine(double amount)
Create a new mine in front of you, and spend some of your energon on it. |
void |
moveBackward()
Move one square backward. |
void |
moveForward()
Move this robot forward one square in its current direction. |
void |
pickupFlag()
Grab the flag in front of you. |
abstract void |
run()
This is the main entry point into the player. |
MapLocation |
senseEnemyFlag()
Returns the location of the enemy team's flag. |
Mine |
senseMineAhead()
Get the Mine in the square in front of you, if you are carrying a flag. |
Robot[] |
senseNearbyAirRobots()
Get an array of all Robots IN THE AIR in your current sensor range, excepting the calling robot. |
Robot[] |
senseNearbyGroundRobots()
Get an array of all Robots ON THE GROUND in your current sensor range, excepting the calling robot. |
MapLocation |
senseTeamFlag()
Get the location of your team flag. |
void |
setDirection(Direction newDirection)
Set your robot's direction. |
void |
spawn(RobotType type)
Create a new Robot in front of you. |
void |
transferEnergon(double amount)
Transfer a specified amount of energon to the robot in front of you. |
void |
yield()
Ends the current round and gives your robot a slight energon bonus (defined in robocraft.common.GameConstants.YIELD_ENERGON_BONUS). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AbstractRobotPlayer()
Method Detail |
public static Robot getRobot()
public abstract void run()
public boolean isMapShrinking()
public TerrainType getTerrainType(MapLocation loc) throws GameActionException
TerrainType
class.
GameActionException
- under any of the following circumstances:
public Robot[] senseNearbyGroundRobots()
Robot
objects.public Robot[] senseNearbyAirRobots()
Robot
objects.public Mine senseMineAhead() throws GameActionException
Mine
object, or null if no mine there.
GameActionException
- under any of the following circumstances:
public Robot getGroundRobotAtLocation(MapLocation loc)
loc
- the location of the square you are sensing.
GameActionException
- under any of the following circumstances:
public Robot getAirRobotAtLocation(MapLocation loc)
loc
- the location of the square you are sensing.
GameActionException
- under any of the following circumstances:
public static Team getFlagTeam()
public MapLocation senseTeamFlag()
public MapLocation senseEnemyFlag()
public Message getNextMessage()
public int getUnitCount(RobotType type)
type
units on your team.public void yield()
public void setDirection(Direction newDirection) throws GameActionException
GameActionException
- if you are not currently idle, or
if you pass a non-direction direction (i.e. OMNI OR NONE).public void pickupFlag() throws GameActionException
GameActionException
- under any of the following conditions:
public void depositFlag() throws GameActionException
GameActionException
- under any of the following conditions:
public void transferEnergon(double amount) throws GameActionException
amount
- the amount of energon to transfer to the robot in
front of you.
GameActionException
- under any of the following conditions:
amount
energon.public void broadcastMessage(Message msg)
This method will immediately add msg
to
the message queues of all robots in your broadcast range. It
always succeeds.
You are charged a small amount of
energon 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.
msg
- the message you want to broadcast.public void moveForward() throws GameActionException
GameActionException
- under any of the following conditions:
public void moveBackward() throws GameActionException
GameActionException
public void attackGround(MapLocation targetLoc) throws GameActionException
targetLoc
- the location of the square you are attacking.
GameActionException
- under any of the following circumstances:
public void attackAir(MapLocation targetLoc) throws GameActionException
targetLoc
- the location of the square you are attacking.
GameActionException
- under any of the following circumstances:
public void layMine(double amount) throws GameActionException
amount
- the amount of energon to put into the new mine.
Your energon supply will be decreased by this amount.
GameActionException
- under any of the following conditions:
Sentry
.amount
energon.amount
is within GameConstants.MIN_MINE_POWER
and GameConstants.MAX_MINE_POWER
public void spawn(RobotType type) throws GameActionException
This method requires
that the square in front of you is empty and accessable
(i.e. you COULD move forward according to
canMove()
IF you were the robot type you are
spawning). You cannot cause yourself to have less than or
equal to 0 energon by performing a spawn. The energon lost
when spawning is the SPAWN_COST of the new robot.
type
- the type of robot to spawn in the square directly
in front of you.
GameActionException
- under any of the following conditions:
type
.public static Team getTeam()
public static RobotType getType()
public static MapLocation getLocation()
public static double getEnergonLevel()
public static boolean isActive()
public static ActionType getCurrentAction()
public static Direction getDirection()
public static int getRoundsUntilIdle()
public static double getAttackPower()
public static int getBytecodesPerRound()
public static boolean canMove(Direction dir)
public static boolean canAttackAir()
public static boolean canAttackGround()
public static boolean canSenseSquare(MapLocation loc)
public static boolean canSenseObject(GameObject obj)
public static boolean canAttackSquare(MapLocation loc)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |