def my_get_features(state, idt, idp):
    """ extraction du vecteur de features d'un etat, ici distance a la balle, distance au but, distance balle but """
    state = StateFoot(state, idt, idp)
    f1 = state.distance(state.ball_pos)
    f2 = state.distance(state.my_goal)
    f3 = state.distance_ball(state.my_goal)
    return [f1, f2, f3]
Exemplo n.º 2
0
    def end_round(self, team1, team2, state):
        # A round ends when there is a goal
        me = StateFoot(state, 1, 1)
        #print(me.my_pos - me.ball_pos)
        self.cpt += 1  # Increment number of trials
        if self.cpt >= self.trials:
            # Save the result
            res_key = tuple()
            for i, values in zip(self.param_id, self.params.values()):
                res_key += values[i],
            self.res[res_key] = self.crit * 1. / self.trials
            #print(res_key, self.crit)

            # Reset parameters
            self.crit = 0
            self.cpt = 0

            # Go to the next parameter value to try
            key = self.param_keys[self.param_id_id]
            if self.param_id[self.param_id_id] < len(self.params[key]) - 1:
                self.param_id[self.param_id_id] += 1
            else:
                self.simu.end_match()

        for i, (key, values) in zip(self.param_id, self.params.items()):
Exemplo n.º 3
0
    def end_round(self, team1, team2, state):
        # A round ends when there is a goal
        me = StateFoot(state, 1 ,0)
        if state.goal > 0 or self.strategy.n <= 0:
            self.crit += 1  # Increment criterion

        self.cpt += 1  # Increment number of trials
        if self.cpt >= self.trials:
            # Save the result
            res_key = tuple()
            for i, values in zip(self.param_id, self.params.values()):
                res_key += values[i],
            self.res[res_key] = self.crit * 1. / self.trials
            #print(res_key, self.crit)

            # Reset parameters
            self.crit = 0
            self.cpt = 0

            # Go to the next parameter value to try
            key2 = self.param_keys[self.param_id_id]
            key1 = self.param_keys[self.param_id_id-1]
            if self.param_id[self.param_id_id] < len(self.params[key2]) - 1:
                self.param_id[self.param_id_id] += 1
            elif self.param_id[self.param_id_id-1] < len(self.params[key1]) - 1:
                self.param_id[self.param_id_id] = 0
                self.param_id[self.param_id_id-1] += 1
            else:
                self.simu.end_match()

        for i, (key, values) in zip(self.param_id, self.params.items()):
Exemplo n.º 4
0
 def update_round(self, team1, team2, state):
     me = StateFoot(state, 1, 0)
     # Stop the round if it is too long
     if state.step > self.last + self.max_round_step:
         #print(me.my_pos - me.center_point)
         self.simu.end_round()
     if me.my_pos.x >= GAME_WIDTH/2. + 15.:#15.
         #print(state.step - self.last)
         self.simu.end_round()
Exemplo n.º 5
0
    def update_round(self, team1, team2, state):
        me = StateFoot(state, 1 ,0)
        if self.strategy.n <= 0:
            self.simu.end_round()

        #if can_shoot(me):
        #    self.crit += 1
        #    self.simu.end_round()

        # Stop the round if it is too long
        if state.step > self.last + self.max_round_step:
            self.simu.end_round()