class TurnToPosition

Public Class Methods

angle_range(from, to) click to toggle source
# File high_skills/TurnToPosition.rb, line 7
def TurnToPosition.angle_range from, to
      (from/180.0*Math::PI)..(to/180.0*Math::PI)
end
new(target, validity_proc) click to toggle source
Calls superclass method RubyHighSkill.new
# File high_skills/TurnToPosition.rb, line 16
def initialize target, validity_proc
  super()
  @target = target

  @validity_proc = validity_proc || Proc.new{return true}
  @ending = false
  
  @agentInfo = Java::sk.fiit.jim.agent.AgentInfo.getInstance
end

Public Instance Methods

checkProgress() click to toggle source

def Turn.is_towards? point

me_flattened = my.position.set_z(0.0)
target_vector = point - me_flattened
target_angle = target_vector.phi
diff_against_current = Angles.normalize(target_angle - my.rotation_z)
@@in_place_range1.include?(diff_against_current) or @@in_place_range2.include?(diff_against_current)

end

# File high_skills/TurnToPosition.rb, line 57
def checkProgress
#  raise "Fallen" if me.on_ground?
end
pickLowSkill() click to toggle source
# File high_skills/TurnToPosition.rb, line 26
def pickLowSkill
          is_still_valid = @validity_proc.call
    @ending = true if not is_still_valid   
    return nil if not is_still_valid or @ending

    #@target = @agentInfo.kickTarget()
    me_flattened = my.position.set_z(0.0)
    target_vector = @target - me_flattened
     target_angle = target_vector.phi
     diff_against_current = Angles.normalize(target_angle - my.rotation_z)
     @target_phi = diff_against_current #@target.getPhi()
    
    
    case
      when me.on_ground? : nil
      when @@in_place_range1.include?(Angles.normalize(@target_phi)) : nil
      when @@in_place_range2.include?(Angles.normalize(@target_phi)) : nil
      when @@turn_left_range.include?(Angles.normalize(@target_phi)) : get_skill("test_turn_left")
      when @@turn_right_range.include?(Angles.normalize(@target_phi)) : get_skill("test_turn_right")
      else return get_skill("test_turn_right")
    end
  end