def things_near(self, location, radius=None): """Return all thigns within radius of location.""" if radius is None: radius = self.perceptiable_distance radius2 = radius * radius return [(thing, radius2 - distance_squared(location, thing.location)) for thing in self.things if distance_squared(location, thing.location) <= radius2]
def things_near(self, location, radius=None): if radius is None: radius = PERCEPTIBLE_DISTANCE radius2 = radius * radius return [(thing, radius2 - distance_squared(location, thing.location)) for thing in self.things if distance_squared(location, thing.location) <= radius2]
def things_near(self, location, radius=None): """Return all things within radius of location.""" if radius is None: radius = self.perceptible_distance radius2 = radius * radius return [(thing, radius2 - distance_squared(location, thing.location)) for thing in self.things if distance_squared(location, thing.location) <= radius2]
def h(self, node): #print(node) """h function is straight-line distance from a node's state to goal.""" locs = getattr(self.graph, 'locations', None) if locs: if type(node) is str: return int(distance_squared(locs[node], locs[self.goal])) return int(distance_squared(locs[node.state], locs[self.goal])) else: return infinity
def things_near(self, location, radius=None): """Return all things within radius of location.""" if radius is None: radius = self.perceptible_distance radius2 = radius * radius return [(thing, thing.location, thing.number if str(type(thing)) == "<class '__main__.NumberBlock'>" else None) for thing in self.things if distance_squared(location, thing.location) <= radius2]
def length_squared(self): return utils.distance_squared(Vector._ORIGIN, self)
def distance_squared(self, other): return utils.distance_squared(self, other)