Public Member Functions | |
Robot.AttackResult | meleeAttack (int power, Robot.GridCell adjacent_cell) throws RoboSimExecutionException |
Robot.AttackResult | rangedAttack (int power, Robot.GridCell nonadjacent_cell) throws RoboSimExecutionException |
Robot.AttackResult | capsuleAttack (int power_of_capsule, Robot.GridCell cell) throws RoboSimExecutionException |
void | defend (int power) throws RoboSimExecutionException |
void | move (int steps, Robot.Direction way) throws RoboSimExecutionException |
void | pick_up_capsule (Robot.GridCell adjacent_cell) throws RoboSimExecutionException |
void | drop_capsule (Robot.GridCell adjacent_cell, int power_of_capsule) throws RoboSimExecutionException |
Robot.BuildStatus | getBuildStatus () |
Robot.GridCell | getBuildTarget () |
int | getInvestedBuildPower () |
void | setBuildTarget (Robot.BuildStatus status, Robot.GridCell location) throws RoboSimExecutionException |
void | setBuildTarget (Robot.BuildStatus status, Robot.GridCell location, byte[] message) throws RoboSimExecutionException |
void | build (int power) throws RoboSimExecutionException |
void | repair (int power) throws RoboSimExecutionException |
void | charge (int power, Robot.GridCell ally) throws RoboSimExecutionException |
void | sendMessage (byte[] message, int power) throws RoboSimExecutionException |
Robot.GridCell[][] | getVisibleNeighborhood () |
Robot.GridCell[][] | getWorld (int power) throws RoboSimExecutionException |
void | scanEnemy (Robot.Robot_Specs enemySpecs, Robot.Robot_Status enemyStatus, Robot.GridCell toScan) throws RoboSimExecutionException |
Private Member Functions | |
RoboAPIImplementor (RobotData actingRobot_) | |
boolean | isAdjacent (Robot.GridCell adjacent_cell) |
boolean | calculateHit (int attack, int defense) |
Robot.AttackResult | processAttack (int attack, SimGridCell cell_to_attack, int power) throws RoboSimExecutionException |
void | finalizeBuilding (byte[] creation_message) throws RoboSimExecutionException |
Private Attributes | |
RobotData | actingRobot |
The implementing class for the WorldAPI reference. We can't just use ourselves for this because students could downcast us to our real type and manipulate the simulator in untoward ways (not that any of you would do that, and I would catch it when I reviewed your code anyway, but still).
NOTE: THIS IS A NON-STATIC INNER CLASS!
Definition at line 282 of file RoboSim.java.
|
private |
Private constructor
actingRobot_ | data for robot attempting to act in the simulator |
Definition at line 290 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot.
Referenced by RoboSim.RoboAPIImplementor.processAttack().
void RoboSim.RoboAPIImplementor.build | ( | int | power | ) | throws RoboSimExecutionException |
power | how much power to apply to building the current target. Must not be more than remaining power needed to finish building target. |
Implements WorldAPI.
Definition at line 883 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RobotData.player, and RoboSim.RobotData.status.
|
private |
Did the attacker hit the defender?
attack | attack skill of attacker (including bonuses/penalties) |
defense | defense skill of defender (including bonuses) |
Definition at line 311 of file RoboSim.java.
Referenced by RoboSim.RoboAPIImplementor.processAttack().
Robot.AttackResult RoboSim.RoboAPIImplementor.capsuleAttack | ( | int | power_of_capsule, |
Robot.GridCell | cell | ||
) | throws RoboSimExecutionException |
Capsule attack: attack with a capsule
power_of_capsule | power of the capsule to use in the attack |
cell | GridCell (may be adjacent or nonadjacent) to attack |
Implements WorldAPI.
Definition at line 511 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RobotData.player, RoboSim.RoboAPIImplementor.processAttack(), RoboSim.RobotData.specs, RoboSim.RobotData.status, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
void RoboSim.RoboAPIImplementor.charge | ( | int | power, |
Robot.GridCell | ally | ||
) | throws RoboSimExecutionException |
Spend power to charge an adjacent ally robot. 1-for-1 efficiency.
power | amount of power to use for charging ally |
ally | cell containing ally to charge. Must be adjacent. |
Implements WorldAPI.
Definition at line 905 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, Robot.GridCell.contents, RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.SimGridCell.occupant_data, RoboSim.RobotData.player, RoboSim.RobotData.status, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
void RoboSim.RoboAPIImplementor.defend | ( | int | power | ) | throws RoboSimExecutionException |
Defend: increase defense
power | power to use for defense (may not exceed defense skill) |
Implements WorldAPI.
Definition at line 582 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RobotData.player, RoboSim.RobotData.specs, and RoboSim.RobotData.status.
void RoboSim.RoboAPIImplementor.drop_capsule | ( | Robot.GridCell | adjacent_cell, |
int | power_of_capsule | ||
) | throws RoboSimExecutionException |
drop_capsule: drop a capsule (for an ally to pick up, presumably)
adjacent_cell | where to drop capsule (must be adjacent) |
power_of_capsule | how powerful a capsule to drop |
Implements WorldAPI.
Definition at line 703 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, Robot.GridCell.contents, RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.RobotData.player, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
|
private |
Definition at line 753 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.checkSpecsValid(), Robot.createRobot(), RoboSim.RobotData.invested_assoc_cell, RoboSim.RobotData.investedPower, RoboSim.RobotData.player, RoboSim.RobotData.robot, RoboSim.RobotData.specs, RoboSim.RobotData.status, RoboSim.turnOrder, RoboSim.WALL_HEALTH, and RoboSim.RobotData.whatBuilding.
Referenced by RoboSim.RoboAPIImplementor.setBuildTarget().
Robot.BuildStatus RoboSim.RoboAPIImplementor.getBuildStatus | ( | ) |
Tells us what we're in the middle of building.
Implements WorldAPI.
Definition at line 738 of file RoboSim.java.
Robot.GridCell RoboSim.RoboAPIImplementor.getBuildTarget | ( | ) |
Implements WorldAPI.
Definition at line 743 of file RoboSim.java.
int RoboSim.RoboAPIImplementor.getInvestedBuildPower | ( | ) |
Implements WorldAPI.
Definition at line 748 of file RoboSim.java.
Robot.GridCell [][] RoboSim.RoboAPIImplementor.getVisibleNeighborhood | ( | ) |
Gets a copy of the portion of the world visible to the robot. Range is equal to defense skill. Does not cost any power.
Implements WorldAPI.
Definition at line 965 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.getSubGrid(), RoboSim.RobotData.player, RoboSim.sanitizeGrid(), and RoboSim.worldGrid.
Robot.GridCell [][] RoboSim.RoboAPIImplementor.getWorld | ( | int | power | ) | throws RoboSimExecutionException |
Gets a copy of the entire world. Takes 3 power, plus additional if jamming is taking place (which won't be; jamming is not implemented).
power | to spend attempting to get the world |
Implements WorldAPI.
Definition at line 982 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.getSubGrid(), RoboSim.RobotData.player, RoboSim.sanitizeGrid(), and RoboSim.worldGrid.
|
private |
Utility method to check whether student's robot is adjacent to cell it is attacking. Note: diagonal cells are not adjacent.
adjacent_cell | cell to compare with student's robot's position |
Definition at line 297 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, and Robot.GridCell.x_coord.
Referenced by RoboSim.RoboAPIImplementor.charge(), RoboSim.RoboAPIImplementor.drop_capsule(), RoboSim.RoboAPIImplementor.meleeAttack(), RoboSim.RoboAPIImplementor.pick_up_capsule(), RoboSim.RoboAPIImplementor.rangedAttack(), and RoboSim.RoboAPIImplementor.setBuildTarget().
Robot.AttackResult RoboSim.RoboAPIImplementor.meleeAttack | ( | int | power, |
Robot.GridCell | adjacent_cell | ||
) | throws RoboSimExecutionException |
Melee attack: attack an adjacent grid cell
power | Power to use for attack (may not exceed attack skill) |
adjacent_cell | Adjacent GridCell to attack |
Implements WorldAPI.
Definition at line 389 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, Robot.GridCell.contents, RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.SimGridCell.occupant_data, RoboSim.RobotData.player, RoboSim.RoboAPIImplementor.processAttack(), RoboSim.RobotData.specs, RoboSim.RobotData.status, RoboSim.SimGridCell.wallforthealth, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
void RoboSim.RoboAPIImplementor.move | ( | int | steps, |
Robot.Direction | way | ||
) | throws RoboSimExecutionException |
move: move robot
steps | how far to move |
way | which way to move |
Implements WorldAPI.
Definition at line 593 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RobotData.player, RoboSim.RobotData.status, and RoboSim.worldGrid.
void RoboSim.RoboAPIImplementor.pick_up_capsule | ( | Robot.GridCell | adjacent_cell | ) | throws RoboSimExecutionException |
pick_up_capsule: pick up a capsule
adjacent_cell | GridCell where capsule is that you want to pick up (must be adjacent) |
Implements WorldAPI.
Definition at line 662 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, Robot.GridCell.contents, RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.RobotData.player, RoboSim.RobotData.specs, RoboSim.RobotData.status, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
|
private |
Process attack, assigning damage and deleting destroyed objects if necessary.
attack | attack skill of attacker (including bonuses/penalties) |
cell_to_attack | cell attacker is attacking containing enemy or obstacle |
damage | damage if attack hits |
Definition at line 323 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.calculateHit(), RoboSim.RoboAPIImplementor.RoboAPIImplementor(), RoboSim.RoboAPIImplementor.setBuildTarget(), RoboSim.turnOrder, and RoboSim.turnOrder_pos.
Referenced by RoboSim.RoboAPIImplementor.capsuleAttack(), RoboSim.RoboAPIImplementor.meleeAttack(), and RoboSim.RoboAPIImplementor.rangedAttack().
Robot.AttackResult RoboSim.RoboAPIImplementor.rangedAttack | ( | int | power, |
Robot.GridCell | nonadjacent_cell | ||
) | throws RoboSimExecutionException |
Ranged attack: attack nonadjacent grid cell within certain range
power | Power to use for attack (may not exceed attack skill) |
nonadjacent_cell | non-adjacent GridCell to attack |
Implements WorldAPI.
Definition at line 448 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.RobotData.player, RoboSim.RoboAPIImplementor.processAttack(), RoboSim.RobotData.specs, RoboSim.RobotData.status, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
void RoboSim.RoboAPIImplementor.repair | ( | int | power | ) | throws RoboSimExecutionException |
Spend power to repair yourself. 2 power restores 1 health.
power | amount of power to spend on repairs. Should be even. |
Implements WorldAPI.
Definition at line 892 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RobotData.player, RoboSim.RobotData.specs, and RoboSim.RobotData.status.
void RoboSim.RoboAPIImplementor.scanEnemy | ( | Robot.Robot_Specs | enemySpecs, |
Robot.Robot_Status | enemyStatus, | ||
Robot.GridCell | toScan | ||
) | throws RoboSimExecutionException |
Scans an enemy (or ally), retrieving information about the robot. The cell scanned must be visible (within defense cells from us).
Takes 1 power.
enemySpecs | empty Robot_Specs object to be filled in |
enemyStatus | empty Robot_Status object to be filled in |
toScan | cell containing robot we want to scan |
Implements WorldAPI.
Definition at line 994 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, Robot.GridCell.contents, RoboSim.RobotData.player, RoboSim.RobotData.specs, RoboSim.RobotData.status, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
void RoboSim.RoboAPIImplementor.sendMessage | ( | byte[] | message, |
int | power | ||
) | throws RoboSimExecutionException |
Spend additional power to get radio messages unavailable because of jamming.
power | amount of power to spend to attempt to overcome jamming |
message | 64-byte array containing message to transmit |
power | amount of power to use for sending message |
Implements WorldAPI.
Definition at line 937 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, RoboSim.RobotData.player, RoboSim.turnOrder, and RoboSim.worldGrid.
void RoboSim.RoboAPIImplementor.setBuildTarget | ( | Robot.BuildStatus | status, |
Robot.GridCell | location | ||
) | throws RoboSimExecutionException |
Tells the simulator the robot is beginning to build something in an adjacent cell (or, for capsules, inside itself).
In order to mark a capsule or robot as "done", call this method with both parameters null. This will destroy any in-progress build.
Note that you must not move from your current cell while in the process of building anything other than a capsule. If you do, you will lose any in-progress work on a wall or fort, and a robot will be automatically finalized with however many skill points you've invested up to that point.
status | what we're going to start building (or, in the case of an energy capsule, resume building) |
location | where to direct our building efforts. Must be an adjacent, empty location, or null if status=capsule. |
Implements WorldAPI.
Definition at line 833 of file RoboSim.java.
Referenced by RoboSim.RoboAPIImplementor.processAttack().
void RoboSim.RoboAPIImplementor.setBuildTarget | ( | Robot.BuildStatus | status, |
Robot.GridCell | location, | ||
byte[] | creation_message | ||
) | throws RoboSimExecutionException |
Tells the simulator the robot is beginning to build something in an adjacent cell (or, for capsules, inside itself).
In order to mark a capsule or robot as "done", call this method with both parameters null. This will destroy any in-progress build.
Note that you must not move from your current cell while in the process of building anything other than a capsule. If you do, you will lose any in-progress work on a wall or fort, and a robot will be automatically finalized with however many skill points you've invested up to that point.
status | what we're going to start building (or, in the case of an energy capsule, resume building) |
location | where to direct our building efforts. Must be an adjacent, empty location, or null if status=capsule. |
creation_message | message to send to newly created robot (if we're finalizing one) |
Implements WorldAPI.
Definition at line 838 of file RoboSim.java.
References RoboSim.RoboAPIImplementor.actingRobot, RoboSim.RobotData.assoc_cell, Robot.GridCell.contents, RoboSim.RoboAPIImplementor.finalizeBuilding(), RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.RobotData.player, RoboSim.RobotData.whatBuilding, RoboSim.worldGrid, Robot.GridCell.x_coord, and Robot.GridCell.y_coord.
|
private |
Definition at line 284 of file RoboSim.java.
Referenced by RoboSim.RoboAPIImplementor.build(), RoboSim.RoboAPIImplementor.capsuleAttack(), RoboSim.RoboAPIImplementor.charge(), RoboSim.RoboAPIImplementor.defend(), RoboSim.RoboAPIImplementor.drop_capsule(), RoboSim.RoboAPIImplementor.finalizeBuilding(), RoboSim.RoboAPIImplementor.getVisibleNeighborhood(), RoboSim.RoboAPIImplementor.getWorld(), RoboSim.RoboAPIImplementor.isAdjacent(), RoboSim.RoboAPIImplementor.meleeAttack(), RoboSim.RoboAPIImplementor.move(), RoboSim.RoboAPIImplementor.pick_up_capsule(), RoboSim.RoboAPIImplementor.rangedAttack(), RoboSim.RoboAPIImplementor.repair(), RoboSim.RoboAPIImplementor.RoboAPIImplementor(), RoboSim.RoboAPIImplementor.scanEnemy(), RoboSim.RoboAPIImplementor.sendMessage(), and RoboSim.RoboAPIImplementor.setBuildTarget().