class WalkNew

Public Class Methods

new(haveToBeTurnedToTarget,radius_ball,radius_speed,validity_proc) click to toggle source
Calls superclass method RubyHighSkill.new
# File high_skills/walkNew.rb, line 25
def initialize haveToBeTurnedToTarget,radius_ball,radius_speed,validity_proc
  super()
  @haveToBeTurnedToTarget = haveToBeTurnedToTarget
  @radius_ball = radius_ball
  @radius_speed = radius_speed
  @validity_proc = validity_proc
  @agentInfo = Java::sk.fiit.jim.agent.AgentInfo.getInstance
  @agentModel = Java::sk.fiit.jim.agent.models.AgentModel.getInstance  
  
  if(@haveToBeTurnedToTarget)
    @@go1 = 0..15
    @@go2 = 335..360
  else
    @@go1 = 0..30
    @@go2 = 330..360
  end
  
end

Public Instance Methods

ballInRange?(range) click to toggle source
# File high_skills/walkNew.rb, line 101
def ballInRange? range
  range.include?(Math.toDegrees(@ball.phi))
end
ball_unseen() click to toggle source
# File high_skills/walkNew.rb, line 129
def ball_unseen
  EnvironmentModel.SIMULATION_TIME - WorldModel.getInstance.getBall.getLastTimeSeen()
end
checkProgress() click to toggle source
# File high_skills/walkNew.rb, line 125
  def checkProgress
#    raise "Fallen!" if me.on_ground?
  end
close_enough?(radius) click to toggle source
# File high_skills/walkNew.rb, line 105
def close_enough? radius
  @ball.r < radius
end
left_and_distant?(target_position) click to toggle source
# File high_skills/walkNew.rb, line 117
def left_and_distant? target_position
  @@left_range.include?(Angles.normalize(target_position.phi))
end
pickLowSkill() click to toggle source
# File high_skills/walkNew.rb, line 44
def pickLowSkill
  @ball = WorldModel.getInstance.getBall.getRelativePosition
  @kickTarget = @agentInfo.kickTarget()
  
  case
    when (not @validity_proc.call) : 
      puts "validity"
      return nil
    when @ball.r < @radius_ball :
      puts "ball radius" 
      return nil
    when EnvironmentModel.beamablePlayMode :
      puts "beam" 
      return nil
    when @agentModel.falled? :
      puts "fall" 
      return nil
    when ball_unseen > 3 :
      puts "ball unseen" 
      return nil
    when (@haveToBeTurnedToTarget and not turned_to_goal?) 
      puts "not turned to goal"
      return nil
    when ((ballInRange? @@go1) or (ballInRange? @@go2)) :
      if close_enough?(@radius_speed)
        puts "go and blizko"
        return get_skill("walk_forward")
      else
        puts "go and daleko"
        return get_skill("walk_forward")
      end
      
  when (ballInRange? @@left and (ballInRange? @@front1 or ballInRange? @@front2)) :
      puts "vlavo vpredu" 
      if(@ball.r<0.5 and @haveToBeTurnedToTarget)
        return get_skill("walk_forward")
      else
        return get_skill("turn_left_cont_20")
      end
    when (ballInRange? @@right and (ballInRange? @@front1 or ballInRange? @@front2)) :
      puts "vpravo vpredu"
      if (@ball.r<0.5 and @haveToBeTurnedToTarget)
        return get_skill("walk_forward")  
      else
        return get_skill("turn_right_cont_20")
      end
    when (ballInRange? @@left and ballInRange? @@back) :
      puts "vlavo vzadu"  
      return get_skill("turn_left_90")
    when (ballInRange? @@right and ballInRange? @@back) :
      puts "vpravo vzadu"  
      return get_skill("turn_right_90")    
  end    
  return nil
  
end
right_and_distant?(target_position) click to toggle source
# File high_skills/walkNew.rb, line 121
def right_and_distant? target_position
  @@right_range.include?(Angles.normalize(target_position.phi))
end
straight?(target_position) click to toggle source
# File high_skills/walkNew.rb, line 113
def straight? target_position
  Angles.angle_diff(target_position.phi, 0.0) < Math::PI / 6.0 
end
turned_to_goal?() click to toggle source
# File high_skills/walkNew.rb, line 109
def turned_to_goal?
  @@range1.include?(@kickTarget.phi) or @@range2.include?(@kickTarget.phi)
end