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

Method distance_squared_to

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

Computes the square of the distance from this location to the specified location. If on different planets, returns the maximum integer.

(&self, o: MapLocation)

Source from the content-addressed store, hash-verified

199 /// Computes the square of the distance from this location to the specified
200 /// location. If on different planets, returns the maximum integer.
201 pub fn distance_squared_to(&self, o: MapLocation) -> u32 {
202 if self.planet == o.planet {
203 ((self.x - o.x) * (self.x - o.x) + (self.y - o.y) * (self.y - o.y)) as u32
204 } else {
205 u32::max_value()
206 }
207 }
208
209 /// Returns the Direction from this location to the specified location.
210 /// If the locations are equal this method returns Center.

Callers 3

all_locations_withinMethod · 0.80
is_adjacent_toMethod · 0.80
is_within_rangeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected