Example #1
0
def setup_2s_kickoff(agent: MyHivemind):
    x_pos = [round(drone.location.x) for drone in agent.drones]
    x_pos.extend([round(friend.location.x) for friend in agent.friends])
    if sorted(x_pos) == [-2048, 2048]:
        for drone in agent.drones:
            if round(drone.location.x) == agent.side() * -2048:
                drone.push(KickOff())
                drone.action = Action.Going
            elif round(drone.location.x) == agent.side() * 2048:
                drone.push(Shadow())
                drone.action = Action.Shadowing
    elif sorted(x_pos) == [-256, 256]:
        for drone in agent.drones:
            if round(drone.location.x) == agent.side() * -256:
                drone.push(KickOff())
                drone.action = Action.Going
            elif round(drone.location.x) == agent.side() * 256:
                drone.push(Shadow())
                drone.action = Action.Shadowing
    elif -2048 in x_pos or 2048 in x_pos:
        for drone in agent.drones:
            if round(abs(drone.location.x)) == 2048:
                drone.push(KickOff())
                drone.action = Action.Going
            else:
                drone.push(Shadow())
                drone.action = Action.Shadowing
    elif -256 in x_pos or 256 in x_pos:
        for drone in agent.drones:
            if round(abs(drone.location.x)) == 256:
                drone.push(KickOff())
                drone.action = Action.Going
            else:
                drone.push(Shadow())
                drone.action = Action.Shadowing
Example #2
0
def setup_3s_kickoff(agent: MyHivemind):
    x_pos = [round(drone.location.x) for drone in agent.drones]
    x_pos.extend([round(friend.location.x) for friend in agent.friends])
    if sorted(x_pos) in [[-2048, -256, 2048], [-2048, 0, 2048],
                         [-2048, 256, 2048]]:
        for drone in agent.drones:
            if round(drone.location.x) == agent.side() * -2048:
                drone.push(KickOff())
                drone.action = Action.Going
            elif round(drone.location.x) == agent.side() * 2048:
                target = agent.friend_goal.location + 2 * (
                    agent.ball.location - agent.friend_goal.location) / 3
                drone.push(Goto(target))
                drone.action = Action.Cheating
            else:
                drone.push(GotoBoost(closest_boost(agent, drone.location)))
                drone.action = Action.Boost
    elif sorted(x_pos) == [-256, 0, 256]:
        for drone in agent.drones:
            if round(drone.location.x) == agent.side() * -256:
                drone.push(KickOff())
                drone.action = Action.Going
            elif round(drone.location.x) == agent.side() * 256:
                target = agent.friend_goal.location + 2 * (
                    agent.ball.location - agent.friend_goal.location) / 3
                drone.push(Goto(target))
                drone.action = Action.Cheating
            else:
                drone.push(GotoBoost(closest_boost(agent, drone.location)))
                drone.action = Action.Boost
    elif -2048 in x_pos or 2048 in x_pos:
        for drone in agent.drones:
            if round(abs(drone.location.x)) == 2048:
                drone.push(KickOff())
                drone.action = Action.Going
            elif round(drone.location.x) == agent.side() * -256:
                target = agent.friend_goal.location + 2 * (
                    agent.ball.location - agent.friend_goal.location) / 3
                drone.push(Goto(target))
                drone.action = Action.Cheating
            elif round(drone.location.x) == 0:
                drone.push(GotoBoost(closest_boost(agent, drone.location)))
                drone.action = Action.Boost
            else:
                if 0 in x_pos:
                    target = agent.friend_goal.location + 2 * (
                        agent.ball.location - agent.friend_goal.location) / 3
                    drone.push(Goto(target))
                    drone.action = Action.Cheating
                else:
                    drone.push(GotoBoost(closest_boost(agent, drone.location)))
                    drone.action = Action.Boost
Example #3
0
 def run(self, drone: CarObject, agent: MyHivemind):
     target = agent.ball.location + Vector3(0, 200 * agent.side(), 0)
     local_target = drone.local(target - drone.location)
     defaultPD(drone, local_target)
     defaultThrottle(drone, 2300)
     if local_target.magnitude() < 650:
         drone.pop()
         drone.push(Flip(drone.local(agent.foe_goal.location - drone.location)))
Example #4
0
def push_shot(drone: CarObject, agent: MyHivemind):
    left = Vector3(4200 * -agent.side(),
                   agent.ball.location.y + (1000 * -agent.side()), 0)
    right = Vector3(4200 * agent.side(),
                    agent.ball.location.y + (1000 * -agent.side()), 0)
    targets = {
        "goal": (agent.foe_goal.left_post, agent.foe_goal.right_post),
        "upfield": (left, right)
    }
    shots = find_hits(drone, agent, targets)
    if len(shots["goal"]) > 0:
        drone.clear()
        drone.push(shots["goal"][0])
        drone.action = Action.Going
    elif len(shots["upfield"]) > 0:
        drone.clear()
        drone.push(shots["upfield"][0])
        drone.action = Action.Going
Example #5
0
 def run(self, drone: CarObject, agent: MyHivemind):
     target = Vector3(0, 3116 * agent.side(), 0)
     local_target = drone.local(target - drone.location)
     defaultPD(drone, local_target)
     defaultThrottle(drone, 2300)
     if local_target.magnitude() < 400:
         drone.pop()
         drone.push(DiagonalKickoff())
         drone.push(Flip(drone.local(agent.ball.location - drone.location)))
Example #6
0
def push_shot(drone: CarObject, agent: MyHivemind):
    left = Vector3(4200 * -agent.side(), agent.side() * 5120, 0)
    right = Vector3(4200 * agent.side(), agent.side() * 5120, 0)
    targets = {"goal": (agent.foe_goal.left_post, agent.foe_goal.right_post)}
    if not agent.conceding:
        drones = copy(agent.drones)
        drones.remove(drone)
        team = agent.friends + drones
        for teammate in team:
            a = teammate.location
            b = teammate.location + 2000 * teammate.forward
            local_a = drone.local(a)
            angle_a = math.atan2(local_a.y, local_a.x)
            if angle_a > 0:
                targets["teammate" + str(team.index(teammate))] = (b, a)
            else:
                targets["teammate" + str(team.index(teammate))] = (a, b)
    targets["upfield"] = (left, right)
    shots = find_hits(drone, agent, targets)
    if len(shots["goal"]) > 0:
        drone.clear()
        drone.push(shots["goal"][0])
        drone.action = Action.Going
    elif shots.get("teammate0") is not None and len(
            shots.get("teammate0")) > 0:
        drone.clear()
        drone.push(shots["teammate0"][0])
        drone.action = Action.Going
    elif shots.get("teammate1") is not None and len(
            shots.get("teammate1")) > 0:
        drone.clear()
        drone.push(shots["teammate1"][0])
        drone.action = Action.Going
    elif len(shots["upfield"]) > 0:
        drone.clear()
        drone.push(shots["upfield"][0])
        drone.action = Action.Going