示例#1
0
 def alert(self):
     #fd=self.state.ball
     yy = self.projector2(self.state.ball)
     if yy >= 35 and yy <= 55:
         return SA(V2D(0, yy - self.config.position.y), V2D(0, 0))
     else:
         return SA()
示例#2
0
    def compute_strategy(self, state, id_team, id_player, clever):
        print("oooooooooooooooooooooooooooooooooooooooooo", id_team, id_player)

        vod = 0
        if id_team == 1:
            vod = T1_SENS * COEFF_FORCEUR
            vo = T1_BUT
        elif id_team == 2:
            vod = T2_SENS * COEFF_FORCEUR
            vo = T2_BUT
        position = state.player(id_team, id_player).position
        ball_to_player = state.ball.position.distance(
            state.player(id_team, id_player).position)
        goal_to_player = state.player(id_team, id_player).position.distance(
            V2D(vo, GAME_HEIGHT / 2))
        goal_to_ball = V2D(vo, GAME_HEIGHT / 2) - state.ball.position
        ball = PLAYER_RADIUS + BALL_RADIUS
        print("vhg")
        if usefull().has_ball(state, position):
            print("SA")
            return SA(V2D(0, 0), goal_to_ball)
        else:
            print("kje")
            return SA(
                state.ball.position -
                state.player(id_team, id_player).position, V2D(0, 0))
示例#3
0
    def compute_strategy(self):
        print("oco", self.id_team, self.id_player)
        if (self.state.ball.position.distance(self.config.position) <=
            (PLAYER_RADIUS + BALL_RADIUS)):
            if abs(self.goal2.x - (self.config.position.x)) <= 40:
                print("abs")
                return SA(V2D(0, 0),
                          (self.goal2 - self.state.ball.position).norm_max(5))
            else:
                print("abs")
                yp = usefull().near_of_me(self.config, self.autre, self.state)
                e = usefull().has_ball_dvt2(self.config.position, yp.position,
                                            self.id_team)
                print("qui", e)
                if e:
                    print(self.goal)
                    return SA(V2D(0, 0),
                              (self.goal2 -
                               self.state.ball.position).norm_max(2))
                else:
                    return SA(V2D(0, 0),
                              (self.goal2 -
                               self.state.ball.position).norm_max(0.9))

        else:
            print("IIIo")
            return SA(self.state.ball.position - self.config.position,
                      V2D(0, 0))
示例#4
0
    def shoot(self):
        #print("prince")
        #        print(self.autre_player.position.angle,self.autre_player.position.angle-math.pi/2)
        yy = (GAME_HEIGHT - self.autre_player.position.y) * 1.5
        while abs(yy - self.autre_player.position.y) <= 5:
            yy = yy * 1.5

        y = V2D(75, yy) - self.state.ball.position
        return SA(V2D(), y)
示例#5
0
 def projector(self, ball):
     while (ball.position.x <=
            self.config.position.x) and ball.vitesse != V2D(0, 0):
         if ball.vitesse == V2D(0, 0):
             break
         ball.vitesse.norm = ball.vitesse.norm - settings.ballBrakeSquare * ball.vitesse.norm**2 - settings.ballBrakeConstant * ball.vitesse.norm
         ## decomposition selon le vecteur unitaire de ball.speed
         ball.vitesse = ball.vitesse.norm_max(settings.maxBallAcceleration)
         ball.position += ball.vitesse
     return ball.position.y
示例#6
0
    def compute_strategy(self):
        if self.trou() and not self.check_shoot():
            printn("trou")
            return SA(V2D(), V2D())
        if self.clever.two_to_two_goal_attack == 1 and self.autre_ball():
            self.clever.two_to_two_goal_attack = 0
            return self.to_change(TO_GOAL)
        if self.clever.one_to_one_goal_attack == 1 and self.autre_ball():
            self.clever.one_to_one_goal_attack = 0
            self.clever.alert = 1
            return self.to_change(TO_GOAL)

        return self.attack_o()
示例#7
0
    def shoot(self):
        #print("prince")
        #        print(self.autre_player.position.angle,self.autre_player.position.angle-math.pi/2)
        yp = usefull().near_of_me(self.config, self.autre, self.state)
        yy = (GAME_HEIGHT - yp.position.y)
        if yp.position.y >= GAME_HEIGHT / 2:
            fk = -1
        else:
            fk = 1
        while abs(yy - yp.position.y) <= 6:
            yy = yy * 1.5 * fk

        y = V2D(75, yy) - self.state.ball.position
        return SA(V2D(), y)
示例#8
0
    def attack(self):

        jd = self.next_position_ball_state()
        yy = self.projector_ball_goal_x(jd)
        #        yy=jd.position.y
        #        if (self.config.position.y >=yy+1 or self.config.position.y <=yy-1) and jd.vitesse.norm>0.2:
        #            return SA(V2D(0,yy -self.config.position.y),V2D())
        return SA(jd.position - self.config.position, V2D())
示例#9
0
 def attack(self):
     yy = usefull().next_position_ball(self.state.ball)
     yu = usefull().next_position_ball(yy)
     yi = usefull().next_position_ball(yu)
     yo = usefull().next_position_ball(yi)
     yp = usefull().next_position_ball(yo)
     ##        if (self.config.position.y >=yy+1 or self.config.position.y <=yy-1) and self.state.ball.vitesse.norm>0.2:
     ##            return SA(V2D(0,yy -self.config.position.y),V2D())
     return SA((yp.position - self.config.position).norm_max(0.6), V2D())
示例#10
0
 def compute_strategy(self):
     id_team = self.id_team
     id_player = self.id_player
     state = self.state
     vod = 0
     if id_team == 1:
         vod = T1_SENS * COEFF_FORCEUR
         vo = T1_BUT
     elif id_team == 2:
         vod = T2_SENS * COEFF_FORCEUR
         vo = T2_BUT
     position = self.ma_position
     ball_to_player = self.state.ball.position.distance(
         self.state.player(self.id_team, self.id_player).position)
     goal_to_player = self.state.player(self.id_team,
                                        self.id_player).position.distance(
                                            V2D(vo, GAME_HEIGHT / 2))
     goal_to_ball = self.goal2 - self.ma_position
     ball = PLAYER_RADIUS + BALL_RADIUS
     if self.have_ball():
         return SA(V2D(0, 0), goal_to_ball + V2D(0, randint(-75, 75)))
     else:
         return SA(self.ball.position - self.ma_position)
示例#11
0
    def compute_strategy(self):
        print("oooooooooooooooooooooooo", self.id_team, self.id_player)

        if (self.state.ball.position.distance(self.config.position) <=
            (PLAYER_RADIUS + BALL_RADIUS)):

            e = usefull().has_ball_dvt2(self.config.position,
                                        self.autre_player.position,
                                        self.id_team)
            print("dvt", e, "goal2", self.goal2, "40",
                  abs(self.goal2.x - (self.config.position.x)), "last_shoot",
                  self.config._last_shoot)
            if e:
                if abs(self.goal2.x - (self.config.position.x)) <= 40:
                    y = self.goal2 - self.state.ball.position

                else:

                    y = (self.goal2 - self.state.ball.position).norm_max(3)
                print("y", y)
                return SA(V2D(), y)
            else:
                dis = self.ball - self.autre_player.position
                moi = self.config.position
                s = usefull().next_position_player(dis, self.autre_player)
                jj = usefull().has_ball_merge(self.state, s, 10)
                print("s", s, "jj", jj)
                if jj:
                    if abs(self.goal2.x - (self.config.position.x)) <= 40:
                        y = self.goal2 + V2D(0, 5) - self.state.ball.position
                        return SA(V2D(0, 0), y)
                    else:
                        yy = GAME_HEIGHT - self.autre_player.position.y

                        while abs(yy - self.autre_player.position.y) <= 5:
                            yy = yy * 1.5

                        y = V2D(self.ball.x + 40 * self.sens,
                                yy) - self.state.ball.position
                    y = (y).norm_max(1)
                    print("df", y)
                    return SA(V2D(0, 0), y)
                else:
                    print("else dvt")
                    return SA(V2D(0, 0),
                              (self.goal2 -
                               self.state.ball.position).norm_max(1))

        else:

            return SA(self.state.ball.position - self.config.position,
                      V2D(0, 0))
示例#12
0
 def __init__(self, id_team, id_player, state, clever):
     AS.__init__(self, "goal_one_to_one")
     self.va_au_goal = 1
     self.id_team = id_team
     self.id_player = id_player
     self.player = 0
     if id_team == 1:
         self.goal = GOAL1
         self.sens = T2_SENS
         self.autre = 2
     elif id_team == 2:
         self.goal = GOAL2
         self.sens = T2_SENS
         self.autre = 1
     self.clever = clever
     self.config = state.player(id_team, id_player)
     self.state = state
     self.ball = state.ball.position
     self.goal_zone = self.goal + V2D(ZONE_GOAL * self.sens, 0)
     self.autre_player = state.player(self.autre, self.player)
示例#13
0
    def compute_strategy(self):
        if (self.state.ball.position.distance(self.config.position) <=
            (PLAYER_RADIUS + BALL_RADIUS)):
            e = usefull().has_ball_dvt2(self.config.position,
                                        self.autre_player.position,
                                        self.id_team)
            if e:
                if abs(self.goal2.x - (self.config.position.x)) <= 40:
                    y = self.goal2 - self.state.ball.position

                else:
                    y = (self.goal2 - self.state.ball.position).norm_max(3)
                return SA(V2D(), y)
            else:
                dis = self.ball - self.autre_player.position
                moi = self.config.position
                s = usefull().next_position_player(dis, self.autre_player)
                jj = usefull().has_ball_merge(self.state, s, 10)
                if jj:
                    if abs(self.goal2.x - (self.config.position.x)) <= 40:
                        y = self.goal2 + V2D(0, 5) - self.state.ball.position
                        return SA(V2D(0, 0), y)
                    else:
                        yy = GAME_HEIGHT - self.autre_player.position.y

                        while abs(yy - self.autre_player.position.y) <= 5:
                            yy = yy * 1.5

                        y = V2D(self.ball.x + 40 * self.sens,
                                yy) - self.state.ball.position
                    y = (y).norm_max(1)
                    return SA(V2D(0, 0), y)
                else:
                    return SA(V2D(0, 0),
                              (self.goal2 -
                               self.state.ball.position).norm_max(1))

        else:
            return SA(self.state.ball.position - self.config.position,
                      V2D(0, 0))