Public Member Functions | |
RoboAPIImplementor (RoboSim &rsim_, RobotData &actingRobot_) | |
AttackResult | meleeAttack (int power, GridCell &adjacent_cell) |
AttackResult | rangedAttack (int power, GridCell &nonadjacent_cell) |
AttackResult | capsuleAttack (int power_of_capsule, GridCell &cell) |
void | defend (int power) |
void | move (int steps, Direction way) |
void | pick_up_capsule (GridCell &adjacent_cell) |
void | drop_capsule (GridCell &adjacent_cell, int power_of_capsule) |
BuildStatus | getBuildStatus () |
GridCell * | getBuildTarget () |
int | getInvestedBuildPower () |
void | setBuildTarget (BuildStatus status, GridCell *location) |
void | setBuildTarget (BuildStatus status, GridCell *location, vector< uint8_t > message) |
void | build (int power) |
void | repair (int power) |
void | charge (int power, GridCell &ally) |
void | sendMessage (vector< uint8_t > message, int power) |
vector< vector< GridCell > > | getVisibleNeighborhood () |
vector< vector< GridCell > > | getWorld (int power) |
void | scanEnemy (Robot_Specs &enemySpecs, Robot_Status &enemyStatus, GridCell toScan) |
Private Member Functions | |
bool | isAdjacent (GridCell adjacent_cell) |
bool | calculateHit (int attack, int defense) |
AttackResult | processAttack (int attack, GridCell &cell_to_attack, int power) |
void | finalizeBuilding (vector< uint8_t > creation_message) |
Private Attributes | |
RoboSim & | rsim |
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).
Definition at line 93 of file RoboSim.hpp.
|
inline |
Constructor
actingRobot_ | data for robot attempting to act in the simulator |
Definition at line 104 of file RoboSim.hpp.
Referenced by processAttack().
|
inlinevirtual |
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 188 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::Robot_Status::charge, robot_api::RobotData::investedPower, robot_api::RobotData::player, robot_api::Robot_Status::power, and robot_api::RobotData::status.
|
inlineprivate |
Did the attacker hit the defender?
attack | attack skill of attacker (including bonuses/penalties) |
defense | defense skill of defender (including bonuses) |
Definition at line 126 of file RoboSim.hpp.
Referenced by processAttack().
|
virtual |
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 306 of file RoboSim.cpp.
References robot_api::ALLY, robot_api::BLOCKED, robot_api::CAPSULE, robot_api::GridCell::contents, robot_api::EMPTY, robot_api::RobotUtility::findShortestPath(), robot_api::GridCell::occupant_data, robot_api::RobotData::player, robot_api::SELF, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
inlinevirtual |
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 210 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::Robot_Status::charge, robot_api::GridCell::contents, robot_api::GridCell::occupant_data, robot_api::RobotData::player, robot_api::Robot_Status::power, robot_api::SELF, robot_api::RobotData::status, RoboSim::worldGrid, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
inlinevirtual |
Defend: increase defense
power | power to use for defense (may not exceed defense skill) |
Implements WorldAPI.
Definition at line 145 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::Robot_Status::charge, robot_api::Robot_Specs::defense, robot_api::Robot_Status::defense_boost, robot_api::RobotData::player, robot_api::Robot_Specs::power, robot_api::RobotData::specs, and robot_api::RobotData::status.
|
virtual |
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 469 of file RoboSim.cpp.
References robot_api::CAPSULE, robot_api::GridCell::capsule_power, robot_api::GridCell::contents, robot_api::EMPTY, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
private |
Definition at line 500 of file RoboSim.cpp.
References robot_api::RobotData::assoc_cell, robot_api::CAPSULE, robot_api::Robot_Status::charge, RoboSim::checkSpecsValid(), Robot::createRobot(), robot_api::EMPTY, robot_api::FORT, robot_api::Robot_Status::health, robot_api::NOTHING, robot_api::GridCell::occupant_data, robot_api::RobotData::player, robot_api::Robot_Specs::power, RBP_CALL_CONSTRUCTOR, robot_api::ROBOT, robot_api::RobotData::robot, robot_api::SELF, robot_api::RobotData::specs, robot_api::RobotData::status, robot_api::WALL, and RoboSim::WALL_HEALTH.
|
inlinevirtual |
Tells us what we're in the middle of building.
Implements WorldAPI.
Definition at line 160 of file RoboSim.hpp.
References robot_api::RobotData::whatBuilding.
|
inlinevirtual |
Implements WorldAPI.
Definition at line 165 of file RoboSim.hpp.
References robot_api::RobotData::invested_assoc_cell.
|
inlinevirtual |
Implements WorldAPI.
Definition at line 170 of file RoboSim.hpp.
References robot_api::RobotData::investedPower.
|
inlinevirtual |
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 266 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::Robot_Specs::defense, RoboSim::getSanitizedSubGrid(), robot_api::RobotData::player, robot_api::SELF, robot_api::RobotData::specs, RoboSim::worldGrid, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
inlinevirtual |
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 283 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, RoboSim::getSanitizedSubGrid(), robot_api::RobotData::player, robot_api::SELF, RoboSim::worldGrid, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
inlineprivate |
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 112 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
virtual |
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 189 of file RoboSim.cpp.
References robot_api::ALLY, robot_api::BLOCKED, robot_api::CAPSULE, robot_api::GridCell::contents, robot_api::EMPTY, robot_api::GridCell::occupant_data, robot_api::RobotData::player, robot_api::SELF, robot_api::GridCell::wallforthealth, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
virtual |
move: move robot
steps | how far to move |
way | which way to move |
Implements WorldAPI.
Definition at line 362 of file RoboSim.cpp.
References robot_api::DOWN, robot_api::EMPTY, robot_api::FORT, robot_api::LEFT, robot_api::RIGHT, robot_api::SELF, and robot_api::UP.
|
virtual |
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 431 of file RoboSim.cpp.
References robot_api::CAPSULE, robot_api::GridCell::capsule_power, robot_api::GridCell::contents, robot_api::EMPTY, robot_api::GridCell::x_coord, and robot_api::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 123 of file RoboSim.cpp.
References calculateHit(), robot_api::GridCell::contents, robot_api::Robot_Specs::defense, robot_api::Robot_Status::defense_boost, robot_api::DESTROYED_TARGET, robot_api::EMPTY, robot_api::FORT, robot_api::Robot_Status::health, robot_api::HIT, robot_api::RobotData::invested_assoc_cell, robot_api::MISSED, robot_api::NOTHING, robot_api::GridCell::occupant_data, RoboAPIImplementor(), rsim, robot_api::SELF, robot_api::RobotData::specs, robot_api::RobotData::status, RoboSim::turnOrder, RoboSim::turnOrder_pos, robot_api::WALL, and robot_api::GridCell::wallforthealth.
|
virtual |
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 246 of file RoboSim.cpp.
References robot_api::ALLY, robot_api::BLOCKED, robot_api::CAPSULE, robot_api::GridCell::contents, robot_api::EMPTY, robot_api::RobotUtility::findShortestPath(), robot_api::GridCell::occupant_data, robot_api::RobotData::player, robot_api::SELF, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
inlinevirtual |
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 197 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::Robot_Specs::charge, robot_api::Robot_Status::charge, robot_api::Robot_Status::health, robot_api::RobotData::player, robot_api::Robot_Status::power, robot_api::RobotData::specs, and robot_api::RobotData::status.
|
inlinevirtual |
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 295 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::Robot_Specs::attack, robot_api::Robot_Status::capsules, robot_api::Robot_Specs::charge, robot_api::Robot_Status::charge, robot_api::GridCell::contents, robot_api::Robot_Specs::defense, robot_api::Robot_Status::defense_boost, robot_api::Robot_Status::health, robot_api::GridCell::occupant_data, robot_api::RobotData::player, robot_api::Robot_Specs::power, robot_api::Robot_Status::power, robot_api::SELF, robot_api::RobotData::specs, robot_api::RobotData::status, RoboSim::worldGrid, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
inlinevirtual |
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 238 of file RoboSim.hpp.
References robot_api::RobotData::assoc_cell, robot_api::RobotData::buffered_radio, robot_api::RobotUtility::findNearestAlly(), robot_api::GridCell::occupant_data, robot_api::RobotData::player, RoboSim::turnOrder, RoboSim::worldGrid, and a::x.
|
inlinevirtual |
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 181 of file RoboSim.hpp.
|
virtual |
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 581 of file RoboSim.cpp.
References robot_api::BLOCKED, robot_api::CAPSULE, robot_api::GridCell::contents, robot_api::EMPTY, robot_api::NOTHING, robot_api::GridCell::x_coord, and robot_api::GridCell::y_coord.
|
private |
Definition at line 97 of file RoboSim.hpp.
|
private |
Definition at line 96 of file RoboSim.hpp.
Referenced by processAttack().