class GoToPosition

Public Class Methods

angle_range(from, to) click to toggle source
# File high_skills/GoToPosition.rb, line 20
def GoToPosition.angle_range from, to
(from/180.0*Math::PI)..(to/180.0*Math::PI)
end
new(position, validity_proc) click to toggle source
Calls superclass method RubyHighSkill.new
# File high_skills/GoToPosition.rb, line 47
def initialize position, validity_proc
  super()
  @agentInfo = Java::sk.fiit.jim.agent.AgentInfo.getInstance
  @agentModel = Java::sk.fiit.jim.agent.models.AgentModel.getInstance
  @tacticalInfo = Java::sk.fiit.jim.agent.models.TacticalInfo.getInstance
  
  @target_position_global = position
  @validity_proc = validity_proc

end

Public Instance Methods

abs(number) click to toggle source
# File high_skills/GoToPosition.rb, line 159
def abs number
  Math.abs number
end
back?(target_position) click to toggle source
# File high_skills/GoToPosition.rb, line 147
def back? target_position
  Angles.angle_diff(target_phi, Math::PI) < Math::PI / 6.0
end
back_and_close?() click to toggle source
# File high_skills/GoToPosition.rb, line 127
def back_and_close?
  @@back_range.include?(@target_position_phi) and (@target_position.getR <= @@strafe_distance)
end
checkProgress() click to toggle source
# File high_skills/GoToPosition.rb, line 155
  def checkProgress
#    raise "Fallen!" if me.on_ground?
  end
close_enough?() click to toggle source
# File high_skills/GoToPosition.rb, line 115
def close_enough?
  @target_position.getR < 0.5
end
is_current_skill?(possibilities) click to toggle source
# File high_skills/GoToPosition.rb, line 110
def is_current_skill? possibilities
  current_skill_name = currentSkill.nil? ? "null" : currentSkill.name
  possibilities.member?(current_skill_name)
end
is_on_position?() click to toggle source
# File high_skills/GoToPosition.rb, line 119
def is_on_position?
      abs(@agentModel.getPosition().getXYDistanceFrom(@target_position_global)) < 0.5
end
left_and_close?() click to toggle source
# File high_skills/GoToPosition.rb, line 131
def left_and_close?
  (@target_position.r <= @@strafe_distance) and @@left_strafe_range.include?(Angles.normalize(@target_position_phi))
end
left_and_distant?() click to toggle source
# File high_skills/GoToPosition.rb, line 139
def left_and_distant?
  @@left_range.include? Angles.normalize(@target_position_phi)
end
pickLowSkill() click to toggle source
# File high_skills/GoToPosition.rb, line 58
def pickLowSkill
       if not @validity_proc.call
             return nil
       end

       if @target_position_global == nil
           return nil
       else
           @agentModel = Java::sk.fiit.jim.agent.models.AgentModel.getInstance
           @target_position = @agentModel.relativize(@target_position_global)
       end
  
   @target_position_phi = @target_position.getPhi()
   
   if @target_position_phi != nil
      @target_position_phi2 = @target_position_phi
   elsif @target_position_phi == nil and plan.see_ball?
      @target_position_phi = @target_position_phi2
   end

  case
              when me.on_ground?
                      #puts "--onGround"
              return  
      when is_on_position?
              @agentInfo.loguj("close ")
              #puts "--onPosition"
                      return nil
      when left_and_close?:
              #puts "--leftAndClose"
              return get_skill("step_left")
      when right_and_close?:
              #puts "--rightAndClose"
              return get_skill("step_right")
      when back_and_close?:
              #puts "--backAndClose"
              return get_skill("walk_back")
      when straight?:
              #puts "--straight"
              return get_skill("walk_forward")
      when left_and_distant?:
              #puts "--turnLeft"
              return get_skill("turn_left_cont_20")
      when right_and_distant?:
              #puts "--turnRight"
              return get_skill("turn_right_cont_20")
      else
              return nil
      
  end   
end
right_and_close?() click to toggle source
# File high_skills/GoToPosition.rb, line 135
def right_and_close?
  (@target_position.r <= @@strafe_distance) and @@right_strafe_range.include?(Angles.normalize(@target_position_phi))
end
right_and_distant?() click to toggle source
# File high_skills/GoToPosition.rb, line 143
def right_and_distant?
  @@right_range.include? Angles.normalize(@target_position.getPhi())
end
straight?() click to toggle source
# File high_skills/GoToPosition.rb, line 123
def straight?
  @@straight_range1.include?(@target_position_phi) or @@straight_range2.include?(@target_position_phi)
end