def from_str(cls, strg):
     l_vect = Vector2D.from_list_str(strg)
     if len(l_vect) != 4:
         raise DecodeException("Wrong format for %s : %s" % (cls, strg))
     return cls(state=MobileMixin(position=l_vect[0], vitesse=l_vect[1]),
                action=SoccerAction(acceleration=l_vect[2],
                                    shoot=l_vect[3]))
Beispiel #2
0
 def reset_state(self, nb_players_1=0, nb_players_2=0):
     if nb_players_1 == 0 and self.nb_players(1) > 0:
         nb_players_1 = self.nb_players(1)
     if nb_players_2 == 0 and self.nb_players(2) > 0:
         nb_players_2 = self.nb_players(2)
     quarters = [i * settings.GAME_HEIGHT / 4 for i in range(1, 4)]
     rows = [settings.GAME_WIDTH * 0.1, settings.GAME_WIDTH * 0.35, settings.GAME_WIDTH * (1 - 0.35),
             settings.GAME_WIDTH * (1 - 0.1)]
     if nb_players_1 == 1:
         self._configs[(1, 0)] = Configuration.from_position(rows[0], quarters[1])
     if nb_players_2 == 1:
         self._configs[(2, 0)] = Configuration.from_position(rows[3], quarters[1])
     if nb_players_1 == 2:
         self._configs[(1, 0)] = Configuration.from_position(rows[0], quarters[0])
         self._configs[(1, 1)] = Configuration.from_position(rows[0], quarters[2])
     if nb_players_2 == 2:
         self._configs[(2, 0)] = Configuration.from_position(rows[3], quarters[0])
         self._configs[(2, 1)] = Configuration.from_position(rows[3], quarters[2])
     if nb_players_1 == 4:
         self._configs[(1, 0)] = Configuration.from_position(rows[0], quarters[0])
         self._configs[(1, 1)] = Configuration.from_position(rows[0], quarters[2])
         self._configs[(1, 2)] = Configuration.from_position(rows[1], quarters[0])
         self._configs[(1, 3)] = Configuration.from_position(rows[1], quarters[2])
     if nb_players_2 == 4:
         self._configs[(2, 0)] = Configuration.from_position(rows[2], quarters[0])
         self._configs[(2, 1)] = Configuration.from_position(rows[2], quarters[2])
         self._configs[(2, 2)] = Configuration.from_position(rows[3], quarters[0])
         self._configs[(2, 3)] = Configuration.from_position(rows[3], quarters[2])
     self._ball = MobileMixin.from_position(settings.GAME_WIDTH / 2, settings.GAME_HEIGHT / 2)
     self._winning_team = 0
Beispiel #3
0
 def from_str(cls, strg):
     l_pos = strg.split("|")
     res = cls(step=int(l_pos[0]), max_steps=int(l_pos[1]), score={1: int(l_pos[2]), 2: int(l_pos[3])},
               winning_team=int(l_pos[4]))
     res._ball = MobileMixin.from_str(l_pos[5])
     for p in l_pos[6:]:
         cfg = p.split(":")
         res._configs[(int(cfg[0]), int(cfg[1]))] = Configuration.from_str(cfg[2])
     return res
 def __init__(self, **kwargs):
     """
     :param state: etat MobileMixin du joueur
     ;param action: action SoccerAction du joueur
     :return:
     """
     self._state = kwargs.pop('state', MobileMixin())
     self._action = kwargs.pop('action', SoccerAction())
     self._last_shoot = kwargs.pop('last_shoot', 0)
     self.__dict__.update(kwargs)
Beispiel #5
0
 def __init__(self, items=None):
     self.primitives = []
     self._info = MobileMixin()
     if items:
         self.add_primitives(items)
 def from_position(cls, x, y):
     return cls(state=MobileMixin(position=Vector2D(x, y)))
 def __init__(self, *args, **kwargs):
     MobileMixin.__init__(self, *args, **kwargs)
Beispiel #8
0
 def __init__(self,*args,**kwargs):
     MobileMixin.__init__(self,*args,**kwargs)