MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / is_adjacent_to

Method is_adjacent_to

battlecode-engine/src/location.rs:263–269  ·  view source on GitHub ↗

Determines whether this location is adjacent to the specified location, including diagonally. Note that squares are not adjacent to themselves, and squares on different planets are not adjacent to each other.

(&self, o: MapLocation)

Source from the content-addressed store, hash-verified

261 /// including diagonally. Note that squares are not adjacent to themselves,
262 /// and squares on different planets are not adjacent to each other.
263 pub fn is_adjacent_to(&self, o: MapLocation) -> bool {
264 if self.planet != o.planet {
265 return false;
266 }
267 let dist_squared = self.distance_squared_to(o);
268 dist_squared <= 2 && dist_squared != 0
269 }
270
271 /// Whether this location is within the distance squared range of the
272 /// specified location, inclusive. False for locations on different planets.

Callers 2

ok_if_can_repairMethod · 0.80
ok_if_can_loadMethod · 0.80

Calls 3

distance_squared_toMethod · 0.80
is_on_mapMethod · 0.80
map_locationMethod · 0.80

Tested by

no test coverage detected