airesources/Ruby/hlt/map.rb
# Check whether there is a straight-line path to the given point, without
# obstacles in between.
# ship: Source entity
# target: target entity
# ignore: Array of entity types to ignore
# return: array of obstacles between the ship and target
Check whether there is a straight-line path to the given point, without
obstacles in between.
ship: Source entity
target: target entity
ignore: Array of entity types to ignore
return: array of obstacles between the ship and target
Check whether there is a straight - line path to the given point without obstacles in between . ship : Source entity target : target entity ignore : Array of entity types to ignore return : array of obstacles between the ship and target
def obstacles_between(ship, target, ignore=[])
    obstacles = []
    entities = []
    entities.concat(planets) unless ignore.include?(:planets)
    entities.concat(ships) unless ignore.include?(:ships)
    entities.each do |foreign_entity|
      next if foreign_entity == ship || foreign_entity == target
      if intersect_segment_circle(ship, target, foreign_entity, fudge=ship.radius + 0.1)
        obstacles << foreign_entity
      end
    end
    obstacles
  end
def obstacles_between ( ship , target , ignore = [ ] ) obstacles = [ ] entities = [ ] entities . concat ( planets ) unless ignore . include? ( :planets ) entities . concat ( ships ) unless ignore . include? ( :ships ) entities . each do | foreign_entity | next if foreign_entity == ship || foreign_entity == target if intersect_segment_circle ( ship , target , foreign_entity , fudge = ship . radius + 0.1 ) obstacles << foreign_entity end end obstacles end
Check whether there is a straight-line path to the given point, without
obstacles in between.
Check whether there is a straight - line path to the given point without obstacles in between .
ship
<not_specific>
target
<not_specific>
ignore
<not_specific>