def __init__(self, world, robot): if world.robot_in_possession: self.angle = utils.get_avoiding_angle_to_point(world, robot, world.robot_in_possession.vector) if not self.angle: self.angle = utils.attacker_get_rotation_to_point(robot.vector, world.robot_in_possession.vector) else: error("Attempting to block while no robot in possession") self.angle = 0 super(TurnToBlockingAngle, self).__init__(world, robot)
def get_goal(self, world, robot): ''' Selects a goal for robot ''' ''' if robot.has_ball(world.ball): return attacker.Score(world, robot) else: return attacker.GetBall(world, robot)''' if self.current_task == 'move-grab': return attacker.GetBall(world, robot) elif self.current_task == 'turn-move-grab': return attacker.GetBall(world, robot) elif self.current_task == 'turn-shoot': if robot.has_ball(world.ball): return attacker.Score(world, robot) else: info("Trying to turn-shoot without ball. Using GetBall instead.") return attacker.GetBall(world, robot) elif self.current_task == 'receive-pass': if world.our_defender.has_ball(world.ball): return attacker.AttackPosition(world, robot) else: return attacker.GetBall(world, robot) elif self.current_task == 'receive-turn-pass': if world.their_robots[0].has_ball(world.ball) or world.their_robots[1].has_ball(world.ball): return attacker.AttackPosition(world, robot) elif robot.has_ball(world.ball): return attacker.AttackerPass(world, robot) else: return attacker.GetBall(world, robot) elif self.current_task == 'intercept': return attacker.AttackerBlock(world, robot) elif self.current_task == 'score-zone': return attacker.AttackPosition(world, robot) elif world.game_state == 'normal-play': if world.our_attacker.has_ball(world.ball): info("Attacker has ball so trying to score") return attacker.Score(world, robot) elif world.our_defender.has_ball(world.ball): info("Defender has ball so going to attack position") return attacker.AttackPosition(world, robot) elif any([r.has_ball(world.ball) for r in world.their_attackers]): info("Opponent in our half has ball so going to score position") return attacker.AttackPosition(world, robot) elif any([r.has_ball(world.ball) for r in world.their_defenders])\ and world.is_possible_vector_position(world.our_attacker, world.our_attacker.get_blocking_position(world)): info("Opponent in their half has ball so blocking") return attacker.AttackerBlock(world, robot) elif world.is_possible_position(world.our_attacker, world.ball.x, world.ball.y): info("Ball is in possible position so getting ball") return attacker.GetBall(world, robot) else: info("All else failed so going to attack position") return attacker.AttackPosition(world, robot) elif self.current_task == 'test-obstacle': print(math.degrees(utils.get_avoiding_angle_to_point(world, world.our_attacker.vector, world.ball.vector))) from position import Vector print(utils.find_obstacle(world, robot.vector, world.ball.vector)) return attacker.GetBall(world, robot)
def __init__(self, world, robot): position = robot.get_blocking_position(world) self.angle = utils.get_avoiding_angle_to_point(world, robot.vector, position) if not self.angle: self.angle = utils.attacker_get_rotation_to_point(robot.vector, position) super(TurnToFaceBlockingPosition, self).__init__(world, robot)
def __init__(self, world, robot): self.angle = utils.get_avoiding_angle_to_point(world, robot.vector, world.our_defender.vector) if not self.angle: self.angle = utils.attacker_get_rotation_to_point(robot.vector, world.our_defender.vector) super(TurnToDefenderToReceive, self).__init__(world, robot)
def __init__(self, world, robot): position = world.get_new_score_zone() self.angle = utils.get_avoiding_angle_to_point(world, robot.vector, position) if not self.angle: self.angle = utils.attacker_get_rotation_to_point(robot.vector, position) super(TurnToScoreZone, self).__init__(world, robot)
def __init__(self, world, robot): self.angle = utils.get_avoiding_angle_to_point(world, robot.vector, world.ball.vector) #self.angle = utils.attacker_get_rotation_to_point(robot.vector, world.ball.vector) if not self.angle: self.angle = utils.attacker_get_rotation_to_point(robot.vector, world.ball.vector) super(TurnToBall, self).__init__(world, robot)
def is_robot_facing_position(world, r, pos): angle = utils.get_avoiding_angle_to_point(world, r.vector, pos) if not angle: return utils.attacker_get_rotation_to_point(r.vector, pos) return abs(angle) < ROTATION_THRESHOLD