|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrobocraft.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 |
depositEnergon(int amount)
Create a new energon cube in front of you, and deposit some of your energon into it. |
GameObject |
getAirObjectAtLocation(MapLocation loc)
Sense any GameObjects 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 |
GameObject |
getGroundObjectAtLocation(MapLocation loc)
Sense any GameObjects 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 ObjectType |
getType()
wrapper for corresponding GameObject method; does not throw an exception |
static boolean |
isActive()
wrapper for corresponding Robot method; does not throw an exception |
void |
moveBackward()
Move one square backward. |
void |
moveForward()
Move this robot forward one square in its current direction. |
void |
pickupEnergon()
Grab some energon from the EnergonCube in front of you. |
abstract void |
run()
This is the main entry point into the player. |
MapLocation |
senseEnemyQueen()
Special ability for queens to get the location of the enemy queen. |
GameObject[] |
senseNearbyObjects()
Get an array of all GameObjects in your current sensor range, excepting the calling robot. |
void |
setDirection(Direction newDirection)
Set your robot's direction. |
void |
spawn(ObjectType type)
Create a new 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 TerrainType getTerrainType(MapLocation loc) throws GameActionException
TerrainType
class.
GameActionException
- under any of the following circumstances:
public GameObject[] senseNearbyObjects()
Robot
or
EnergonCube
.public MapLocation senseEnemyQueen() throws GameActionException
GameActionException
- under any of the following conditions:
public Message getNextMessage()
public GameObject getGroundObjectAtLocation(MapLocation loc) throws GameActionException
loc
- the location of the square you are sensing.
GameActionException
- under any of the following circumstances:
public GameObject getAirObjectAtLocation(MapLocation loc) throws GameActionException
loc
- the location of the square you are sensing.
GameActionException
- under any of the following circumstances:
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 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 pickupEnergon() throws GameActionException
GameActionException
- under any of the following conditions:
public void depositEnergon(int amount) throws GameActionException
amount
- the amount of energon to put into the new cube.
(Must be at least 1). Your energon supply will be decreased by
this amount.
GameActionException
- under any of the following conditions:
FlyerRobot
.amount
energon.public void spawn(ObjectType 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). It does not require that you have enough energon to
spawn the given robot type. The energon lost when spawning a
Robot is half the MAX_ENERGON that robot can carry.
Note that QueenRobots can spawn any type of robot, and all other robots can only spawn robots of the same type. (Flyers can spawn Flyers, etc.).
Also, no robot can spawn a QueenRobot or an EnergonCube.
type
- the type of robot to spawn in the square directly
in front of you.
GameActionException
- under any of the following conditions:
type
.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 static Team getTeam()
public static ObjectType 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 |