Beispiel #1
0
    def attaque1(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if s.poscoequippier.distance(
                s.ball
        ) < PLAYER_RADIUS + BALL_RADIUS:  #SI le coequippier a la balle

            return a.deplacement(s.pointcampeurgauche)

        elif s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            if s.player.distance(s.poscoequippier) < PLAYER_RADIUS * 25:
                if s.coepdevant == 1:
                    return a.tircoequippier
            elif s.player.distance(s.goaladverse) < (
                    PLAYER_RADIUS *
                    15):  #Si il est dans la surface de tir : shoot
                return a.shootbut
            elif s.playeradverse.distance(s.player) < (PLAYER_RADIUS * 8):
                return a.dr2
            else:

                return a.avanceravecballe
        else:

            return a.deplacement(s.ball)
Beispiel #2
0
    def attaquedroit(self):  #essai

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if s.poscoequippier.distance(
                a.directionball
        ) < PLAYER_RADIUS + BALL_RADIUS:  #SI le coequippier a la balle

            return a.deplacement(s.pointcampeurdroit)

        elif s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            if s.opposantsplusproche[1].distance(
                    s.player) < PLAYER_RADIUS * 10:

                #if s.player.distance(s.poscoequippier) < PLAYER_RADIUS*25 :
                if s.coepdevant == 1:
                    print("DDDDD")
                    return a.tircoequippier + a.deplacement(
                        s.pointattaquantdroit)

            elif s.playeradverse.distance(s.player) < (PLAYER_RADIUS * 15):
                return a.tircoequippier

            elif s.player.distance(s.goaladverse) < (
                    PLAYER_RADIUS *
                    20):  #Si il est dans la surface de tir : shoot
                return a.shootbut

            else:

                return a.avanceravecballe
        else:

            return a.deplacement(a.directionball)
Beispiel #3
0
    def compute_strategy(self, state, id_team, id_player):

        s = Strategies(state, id_team, id_player)
        v = SuperState(state, id_team, id_player)
        a = Actions(state, id_team, id_player)

        if v.player.distance(v.ball) < PLAYER_RADIUS + BALL_RADIUS:
            if id_team == 1:

                tir = (Vector2D(GAME_WIDTH * 3 / 8,
                                GAME_HEIGHT / 2)) - v.player
                return SoccerAction(shoot=tir.normalize() * 3)
            else:

                tir = (Vector2D(GAME_WIDTH * 5 / 8,
                                GAME_HEIGHT / 2)) - v.player
                return SoccerAction(shoot=tir.normalize() * 3)

        else:
            if v.ballecampadverse == 0:
                if id_team == 1:
                    return a.deplacement(
                        Vector2D((GAME_WIDTH / 2) - 5, v.ball.y))
                else:
                    return a.deplacement(
                        Vector2D((GAME_WIDTH / 2) + 5, v.ball.y))
            elif v.player.distance(v.ball) < PLAYER_RADIUS * 10:
                return a.deplacement(v.ball)
Beispiel #4
0
    def gardien2(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)
        id_team = self.id_team
        state = self.state
        id_player = self.id_player

        if id_team == 1:
            if s.ball.x >= GAME_WIDTH / 2:
                if s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
                    shoot = (s.goaladverse - s.player)
                    #return SoccerAction(shoot = shoot.normalize()*1500)
                    return a.shootbut

                elif s.player.distance(
                        s.ball
                ) < PLAYER_RADIUS * 3:  #Ne se déplace que si la balle est proche de lui
                    return a.deplacement(s.ball)

                else:
                    return a.deplacement(s.goalequipe)
            elif s.ball.x < GAME_WIDTH / 2:
                if s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
                    shoot = (s.goaladverse - s.player)
                    #return SoccerAction(shoot = shoot.normalize()*1500)

                else:
                    deplacement = state.ball.position - state.player_state(
                        id_team, id_player).position
                    tir = Vector2D(150, 45) - state.ball.position
                    return SoccerAction(deplacement, tir)

        else:
            if s.ball.x <= GAME_WIDTH / 2:
                if s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
                    shoot = (s.goaladverse - s.player)
                    return SoccerAction(shoot=shoot.normalize() * 1500)

                elif s.player.distance(
                        s.ball
                ) < PLAYER_RADIUS * 3:  #Ne se déplace que si la balle est proche de lui
                    return SoccerAction(acceleration=s.deplacement(s.ball))

                else:
                    return a.deplacement(s.goalequipe)
            elif s.ball.x > GAME_WIDTH / 2:
                deplacement = state.ball.position - state.player_state(
                    id_team, id_player).position
                tir = Vector2D(0, 45) - state.ball.position
                return SoccerAction(deplacement, tir)
Beispiel #5
0
 def compute_strategy(self, state, id_team, id_player):
   
     s = Strategies(state, id_team, id_player)
     v = SuperState(state, id_team, id_player)
     a = Actions(state, id_team, id_player)
     
     if v.player.distance(v.ball) < PLAYER_RADIUS + BALL_RADIUS:
         return a.tircoequippier
     else :
         if v.ballecampadverse == 0:
             if id_team == 1 :
                 return a.deplacement(Vector2D((GAME_WIDTH/2)-5, v.ball.y))
             else :
                 return a.deplacement(Vector2D((GAME_WIDTH/2)+5, v.ball.y))
         else :
             return a.deplacement(v.ball)
Beispiel #6
0
    def attaque2(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if s.player.distance(s.ball) < PLAYER_RADIUS * 10:
            return a.deplacement(a.directionball)
        elif s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            if s.player.distance(s.goaladverse) < (PLAYER_RADIUS * 15):
                return a.shootbut
            elif s.coepdevant == 1:
                return a.tircoequippier
            else:
                return a.avanceravecballe

        else:
            return a.deplacement(s.pointattaquant2)
Beispiel #7
0
    def compute_strategy(self, state, id_team, id_player):

        s = Strategies(state, id_team, id_player)
        v = SuperState(state, id_team, id_player)
        a = Actions(state, id_team, id_player)

        if v.player.distance(v.ball) < PLAYER_RADIUS + BALL_RADIUS:
            if id_team == 1:
                if v.player.x < GAME_WIDTH * 2 / 8:
                    shoot = Vector2D(GAME_WIDTH * 4 / 8, GAME_HEIGHT / 2)
                    return SoccerAction(shoot=shoot.normalize() * 3)
                else:
                    if v.playeradverse.y < GAME_HEIGHT / 2:
                        shoot = Vector2D(GAME_WIDTH * 7.5 / 8,
                                         GAME_HEIGHT * 3.5 / 4) - v.player
                        return SoccerAction(shoot=shoot.normalize() * 100)
                    else:
                        shoot = Vector2D(GAME_WIDTH * 7.5 / 8,
                                         GAME_HEIGHT * 0.5 / 4) - v.player
                        return SoccerAction(shoot=shoot.normalize() * 100)
            else:
                if v.player.x > GAME_WIDTH * 6 / 8:
                    shoot = Vector2D(GAME_WIDTH * 4 / 8, GAME_HEIGHT / 2)
                    return SoccerAction(shoot=shoot.normalize() * 3)
                else:
                    if v.playeradverse.y > GAME_HEIGHT / 2:
                        shoot = Vector2D(GAME_WIDTH * 0.5 / 8,
                                         GAME_HEIGHT * 0.5 / 4) - v.player
                        return SoccerAction(shoot=shoot.normalize() * 100)
                    else:
                        shoot = Vector2D(GAME_WIDTH * 0.5 / 8,
                                         GAME_HEIGHT * 3.5 / 4) - v.player
                        return SoccerAction(shoot=shoot.normalize() * 100)
        else:
            if v.ballecampadverse == 0:
                if id_team == 1:
                    return a.deplacement(
                        Vector2D(GAME_WIDTH * 2 / 8, GAME_HEIGHT / 2))
                else:
                    return a.deplacement(
                        Vector2D(GAME_WIDTH * 6 / 8, GAME_HEIGHT / 2))
            else:
                return a.deplacement(v.ball)
Beispiel #8
0
    def defensesolo2(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if self.id_team == 1:
            if s.position(s.ball) == 1 or s.position(
                    s.ball) == 2 or s.position(s.ball) == 7 or s.position(
                        s.ball) == 8:
                return a.deplacement(s.ball) + a.shootbut
            else:
                return a.deplacement(s.pointdefensesolo)

        if self.id_team == 2:
            if s.position(s.ball) == 5 or s.position(
                    s.ball) == 6 or s.position(s.ball) == 11 or s.position(
                        s.ball) == 12:
                return a.deplacement(s.ball) + a.shootbut
            else:
                return a.deplacement(s.pointdefensesolo)
Beispiel #9
0
    def compute_strategy(self, state, id_team, id_player):

        s = Strategies(state, id_team, id_player)
        v = SuperState(state, id_team, id_player)
        a = Actions(state, id_team, id_player)

        if v.player.distance(v.ball) < PLAYER_RADIUS + BALL_RADIUS:
            shoot = v.playeradverse - v.player
            return SoccerAction(shoot=shoot.normalize() * 3)
        else:
            return a.deplacement(v.ball)
Beispiel #10
0
    def milieu(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if s.player.distance(s.ball) < PLAYER_RADIUS * 10:
            return a.deplacement(s.ball)
        elif s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            return a.shoot(s.pointattaquantgauche)

        else:
            return a.deplacementlateralmilieu
Beispiel #11
0
    def fonceur(self):
        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)
        # id_team is 1 or 2
        # id_player starts at 0

        #SI C'EST DANS SON CAMP : FONCEUR. SINON : POSDÉFENSEDUO

        if s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            return a.tircoequippier
        else:
            return a.deplacement(s.ball)
Beispiel #12
0
    def gardien(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            return a.shootdefenseduo

        elif s.player.distance(s.ball) < PLAYER_RADIUS * 10:
            return a.deplacement(a.directionball)

        else:
            return a.deplacementlateral
Beispiel #13
0
    def attaquesolo(self, force, distance, forcedr, angledr, distadverse):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        if s.player.distance(s.ball) < PLAYER_RADIUS + BALL_RADIUS:
            if s.opposantsplusproche[1].distance(
                    s.player) < (PLAYER_RADIUS * distadverse):
                return a.dr2(forcedr, angledr)
            elif s.player.distance(s.goaladverse) < (
                    PLAYER_RADIUS * distance
            ):  #Si il est dans la surface de tir : shoot, sinon avance
                print("Surface de tir")
                return a.shootbut(force)

            else:
                return a.avanceravecballe
        else:
            return a.deplacement(a.directionball)
Beispiel #14
0
    def campgauche(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        return a.deplacement(s.pointattaquantgauche)
Beispiel #15
0
    def defensesolo(self):

        s = SuperState(self.state, self.id_team, self.id_player)
        a = Actions(self.state, self.id_team, self.id_player)

        return a.deplacement(s.pointdefensesolo)