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

Method ok_if_can_move

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

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.

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

Source from the content-addressed store, hash-verified

994 /// * LocationOffMap - the location is off the map.
995 /// * LocationNotEmpty - the location is occupied by a unit or terrain.
996 fn ok_if_can_move(&self, robot_id: UnitID, direction: Direction) -> Result<(), GameError> {
997 let unit = self.my_unit(robot_id)?;
998 let new_location = unit.location().map_location()?.add(direction);
999
1000 self.ok_if_can_sense_location(new_location)?;
1001 if !self.is_occupiable(new_location).unwrap() {
1002 Err(GameError::LocationNotEmpty)?;
1003 }
1004 Ok(())
1005 }
1006
1007 /// Whether the robot can move in the given direction, without taking into
1008 /// account the unit's movement heat. Takes into account only the map

Callers 2

can_moveMethod · 0.80
move_robotMethod · 0.80

Calls 6

my_unitMethod · 0.80
map_locationMethod · 0.80
locationMethod · 0.80
addMethod · 0.45
is_occupiableMethod · 0.45

Tested by

no test coverage detected