airesources/Ruby/hlt/map.rb
# Fetch all entities in relationship to the entered entity keyed by distance
# entity: the source entity to find distances from
# return: Hash containing all entities with their designated distances
Fetch all entities in relationship to the entered entity keyed by distance
entity: the source entity to find distances from
return: Hash containing all entities with their designated distances
Fetch all entities in relationship to the entered entity keyed by distance entity : the source entity to find distances from return : Hash containing all entities with their designated distances
def nearby_entities_by_distance(entity)
    result = Hash.new { |h, k| h[k] = [] }
    (ships + planets).each do |foreign_entity|
      next if entity == foreign_entity
      result[entity.calculate_distance_between(foreign_entity)] << foreign_entity
    end
    result
  end
def nearby_entities_by_distance ( entity ) result = Hash . new { | h , k | h [ k ] = [ ] } ( ships + planets ) . each do | foreign_entity | next if entity == foreign_entity result [ entity . calculate_distance_between ( foreign_entity ) ] << foreign_entity end result end
Fetch all entities in relationship to the entered entity keyed by distance
entity: the source entity to find distances from
return: Hash containing all entities with their designated distances
Fetch all entities in relationship to the entered entity keyed by distance entity : the source entity to find distances from return : Hash containing all entities with their designated distances
# any new key is initialized with an empty array
entity
<not_specific>