Beispiel #1
0
    def compute_strategy(self, state, id_team, id_player):
        act = Action(state, id_team, id_player)
        mystate = MyState(state, id_team, id_player)
        qui = Qui_a_la_balle(state, id_team, id_player)
        distance = mystate.distance_ball_player
        #distance entre la balle et le but
        distance_but = mystate.distance_but_ball

        if distance > 20:
            if (mystate.adv() == 2):
                position = Vector2D(
                    (0.5 / 5) * GAME_WIDTH,
                    state.ball.position.y) - mystate.my_position
            else:
                position = Vector2D(
                    (3.5 / 5) * GAME_WIDTH,
                    state.ball.position.y) - mystate.my_position
        else:
            position = state.ball.position - mystate.my_position
            #return SoccerAction(position,V-mystate.my_position)


#            if qui.mon_equipe_a_la_b():
#                return mystate.en_attente
#            else:
        return SoccerAction(state.ball.position-state.player_state(id_team,id_player).position,\
                    Vector2D((2-id_team)*settings.GAME_WIDTH,settings.GAME_HEIGHT/2.)-state.ball.position)
	def compute_strategy(self, state, idteam, idplayer):
		mstate = MyState(state, idteam, idplayer)
		
		for p in mstate.co_players:
	#if un autre joueur proche de la balle et la balle au dela de la moitie du terrainaller de lavant
			if  mstate.p_near_ball(p) and mstate.ball_position.distance(mstate.but_adv) < 50:
				#print mstate.state.player_state(p[0], p[1]).name
				return Vector2D(1,0)
			elif mstate.can_shoot :
				return mstate.shoot(mstate.but_adv)
Beispiel #3
0
 def compute_strategy(self, state, id_team, id_player):
     m = MyState(state, id_team, id_player)
     act = Action(state, id_team, id_player)
     p = m.ball_position
     pos = Position(state, id_team, id_player)
     qui = Qui_a_la_balle(state, id_team, id_player)
     if qui.j_ai_la_balle:
         return m.aller(p) + SoccerAction(Vector2D(
             3.14, 0), pos.joueur_le_plus_proche(1)) + act.passe_test(
                 state, id_team, id_player)
     if qui.mon_equipe_a_la_b:
         return m.en_attente
     else:
         return Vector2D(20, 45) - m.my_position
Beispiel #4
0
 def compute_strategy(self, state, id_team, id_player):
     qui = Qui_a_la_balle(state, id_team, id_player)
     m = MyState(state, id_team, id_player)
     p = Position(state, id_team, id_player)
     act = Action(state, id_team, id_player)
     if m.distance_ball_player <= m.PR_BR:
         return SoccerAction(
             Vector2D(0, 0), shoot
         )  #+ SoccerAction(state.ball.position-state.player_state(id_team,id_player).position ,\
	def compute_strategy(self, state, idteam, idplayer):
		mstate = MyState(state,idteam,idplayer)
	
		#si defenseur plus proche de la ball que de l'adv va vers la balle et tir dedans sinon va vers l'adv
		if mstate.my_position.distance(mstate.ball_position) < mstate.my_position.distance(mstate.adv_nearby().position):
			return mstate.aller(mstate.ball_position) + mstate.shoot(mstate.but_adv)

		#
		return mstate.aller(mstate.adv_nearby().position - Vector2D(0,0))
	def compute_strategy(self, state, idteam, idplayer):
		mstate = MyState(state,idteam,idplayer)
	
		#si defenseur plus proche de la ball que de l'adv va vers la balle et tir dedans sinon va vers l'adv
		p = mstate.adv_nearby()
		if mstate.my_position.distance(mstate.ball_position) < mstate.my_position.distance(mstate.state.player_state(p[0], p[1]).position):
			p = mstate.coeq_nearby()
			return mstate.aller(mstate.ball_position) + mstate.shoot(mstate.state.player_state(p[0], p[1]))

		return mstate.aller(mstate.state.player_state(p[0], p[1]).position)
Beispiel #7
0
 def compute_strategy(self, state, id_team, id_player):
     p = state.player_state(id_team, id_player)
     mystate = MyState(state, id_team, id_player)
     if state.ball.position.x < 20 and mystate.est_team1():
         return SoccerAction(
             state.ball.position - p.position,
             Vector2D(GAME_WIDTH - state.ball.position.x,
                      GAME_HEIGHT / 2 - state.ball.position.y))
     if state.ball.position.x > 110 and not mystate.est_team1():
         return SoccerAction(
             state.ball.position - p.position,
             Vector2D(0 - state.ball.position.x,
                      GAME_HEIGHT / 2 - state.ball.position.y))
     if not mystate.est_team1():
         p.position = Vector2D(0, GAME_HEIGHT / 2)
         p = state.player_state(id_team, id_player)
         if ((p.position.x > 5) and
             (p.position.y > GAME_HEIGHT / 2 + GAME_GOAL_HEIGHT)
                 or (p.position.y < GAME_HEIGHT / 2 - GAME_GOAL_HEIGHT)):
             p.position = Vector2D(0, GAME_HEIGHT / 2)
             return p.position
     if mystate.est_team1():
         p.position = Vector2D(GAME_WIDTH, GAME_HEIGHT / 2)
         p = state.player_state(id_team, id_player)
         if ((p.position.x < 30) and
             (p.position.y > GAME_HEIGHT / 2 + GAME_GOAL_HEIGHT)
                 or (p.position.y < GAME_HEIGHT / 2 - GAME_GOAL_HEIGHT)):
             p.position = Vector2D(GAME_WIDTH, GAME_HEIGHT / 2)
             return p.position
Beispiel #8
0
 def compute_strategy(self, state, id_team, id_player):
     mystate = MyState(state, id_team, id_player)
     act = Action(state, id_team, id_player)
     pos = Position(state, id_team, id_player)
     angle = versOu(state, id_team, id_player)
     #distance avec la balle
     distance = mystate.distance_ball_player
     #distance entre la balle et le but
     distance_but = mystate.distance_but_ball
     V = angle.vers_les_but_adv
     if distance > 20:
         if (mystate.adv() == 2):
             position = V + Vector2D(
                 (0.5 / 5) * GAME_WIDTH,
                 state.ball.position.y) - mystate.my_position
         else:
             position = V + Vector2D(
                 (3.5 / 5) * GAME_WIDTH,
                 state.ball.position.y) - mystate.my_position
     else:
         position = state.ball.position - mystate.my_position
     return SoccerAction(position, V - mystate.my_position)
	def compute_strategy(self, state, idteam, idplayer):
		mstate = MyState(state, idteam, idplayer)
	def compute_strategy(self, state, idteam, idplayer):
		#on cree un objet qui sera notre joueur et sur lequel on agira
		mstate = MyState(state,idteam,idplayer)
		#return mstate.adv_nearby()
		return mstate.aller(mstate.ball_position) + mstate.shoot(mstate.but_adv)