MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / move_robot

Method move_robot

battlecode-engine/src/world.rs:1037–1046  ·  view source on GitHub ↗

Moves the robot in the given direction. NoSuchUnit - the robot does not exist (within the vision range). TeamNotAllowed - the robot is not on the current player's team. UnitNotOnMap - the robot is not on the map. LocationNotVisible - the location is outside the vision range. LocationOffMap - the location is off the map. LocationNotEmpty - the location is occupied by a unit or terrain. Overheated

(&mut self, robot_id: UnitID, direction: Direction)

Source from the content-addressed store, hash-verified

1035 /// * LocationNotEmpty - the location is occupied by a unit or terrain.
1036 /// * Overheated - the robot is not ready to move again.
1037 pub fn move_robot(&mut self, robot_id: UnitID, direction: Direction) -> Result<(), GameError> {
1038 self.ok_if_can_move(robot_id, direction)?;
1039 self.ok_if_move_ready(robot_id)?;
1040 let dest = match self.my_unit(robot_id).unwrap().location() {
1041 OnMap(loc) => loc.add(direction),
1042 _ => unreachable!(),
1043 };
1044 self.move_to(robot_id, dest);
1045 Ok(())
1046 }
1047
1048 fn move_to(&mut self, robot_id: UnitID, location: MapLocation) {
1049 self.remove_unit(robot_id);

Callers 5

run.pyFile · 0.45
run.pyFile · 0.45
applyMethod · 0.45
test_unit_moveFunction · 0.45
examplefuncsplayerFunction · 0.45

Calls 6

ok_if_can_moveMethod · 0.80
locationMethod · 0.80
my_unitMethod · 0.80
ok_if_move_readyMethod · 0.45
addMethod · 0.45
move_toMethod · 0.45

Tested by 1

test_unit_moveFunction · 0.36