Example #1
0
 def setUp(self):
     # ToDo : Use mock instead of actual objects
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW))
     self.game_state.set_reference(game_world)
     self.a_player = OurPlayer(TeamColor.YELLOW, A_PLAYER_ID)
Example #2
0
 def setUp(self):
     config_service = ConfigService().load_file("config/sim_standard.cfg")
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     self.game.ball = Ball()
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW_TEAM))
     self.game_state.set_reference(game_world)
     self.game_state.game.ball.set_position(Position(100, 0), 0)
Example #3
0
    def setUp(self):
        self.game = Game()
        self.referee = Referee
        self.game.set_referee(self.referee)
        self.tcsvc = TeamColorService(TeamColor.BLUE)
        self.game_world_OK = ReferenceTransferObject(self.game)
        self.game_world_OK.set_team_color_svc(self.tcsvc)

        self.GameStateManager1 = GameState()
        self.GameStateManager2 = GameState()
        self.GameStateManager1.set_reference(self.game_world_OK)
Example #4
0
 def setUp(self):
     # ToDo : Use mock instead of actual objects
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     self.game.ball = Ball()
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW_TEAM))
     self.game.set_our_team_color(TeamColor.YELLOW_TEAM)
     self.game_state.set_reference(game_world)
     self.player_id = 1  # random integer
Example #5
0
    def setUp(self):
        config_service = ConfigService().load_file("config/sim_standard.cfg")
        self.game = Game()
        self.referee = Referee
        self.game.set_referee(self.referee)
        self.tcsvc = TeamColorService(TeamColor.BLUE_TEAM)
        self.game.set_our_team_color(self.tcsvc.OUR_TEAM_COLOR)
        self.game_world_OK = ReferenceTransferObject(self.game)
        self.game_world_OK.set_team_color_svc(self.tcsvc)

        self.GameStateManager1 = GameState()
        self.GameStateManager2 = GameState()
        self.GameStateManager1.set_reference(self.game_world_OK)
Example #6
0
 def setUp(self):
     config_service = ConfigService().load_file("config/sim_standard.cfg")
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     self.game.ball = Ball()
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW_TEAM))
     self.game_state.set_reference(game_world)
     self.game_state.game.friends.players[0].update(
         Pose(Position(-4450, 0), 0))
     self.tactic1 = GoalKeeper(self.game_state, 0)
     self.tactic2 = Stop(self.game_state, 1)
     self.node1 = Node(self.tactic1)
     self.node2 = Node(self.tactic2)
     self.vertex1 = Vertex(0, foo)
     self.vertex2 = Vertex(1, foo2)
Example #7
0
    def _parse_team_info(self, frame):
        info = {}
        if TeamColorService().OUR_TEAM_COLOR is TeamColor.YELLOW:
            info['ours'] = frame.yellow
            info['theirs'] = frame.blue
        else:
            info['ours'] = frame.blue
            info['theirs'] = frame.yellow

        for key in info.keys():
            self.team_info[key]['name'] = info[key].name
            self.team_info[key]['score'] = info[key].score
            self.team_info[key]['red_cards'] = info[key].red_cards
            self.team_info[key]['yellow_cards'] = info[key].yellow_cards
            self.team_info[key]['yellow_card_times'].clear()
            for time in info[key].yellow_card_times:
                self.team_info[key]['yellow_card_times'].append(time)
            self.team_info[key]['timeouts'] = info[key].timeouts
            self.team_info[key]['timeout_time'] = info[key].timeout_time
            self.team_info[key]['goalie'] = info[key].goalie
Example #8
0
 def setUp(self):
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     self.game.ball = Ball()
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW))
     self.game_state.set_reference(game_world)
     self.game_state.game.friends.players[0].pose = Pose(
         Position(-4450, 0), 0)
     self.tactic1 = GoalKeeper(
         self.game_state,
         self.game_state.game.friends.players[A_GOAL_PLAYER_ID])
     self.tactic2 = Stop(self.game_state,
                         self.game_state.game.friends.players[A_PLAYER_ID])
     self.node1 = Node(self.tactic1)
     self.node2 = Node(self.tactic2)
     self.vertex1 = Vertex(0, foo)
     self.vertex2 = Vertex(1, foo2)
     self.a_player = OurPlayer(TeamColor.BLUE, 0)
Example #9
0
    def start_game(self, p_ia_coach_mainloop, p_ia_coach_initializer):
        """ Démarrage du moteur de l'IA initial, ajustement de l'équipe de l'ia
        et démarrage du/des thread/s"""

        # IA COUPLING
        self.ia_coach_mainloop = p_ia_coach_mainloop
        self.ia_coach_initializer = p_ia_coach_initializer

        # GAME_WORLD TEAM ADJUSTMENT
        self.team_color_service = TeamColorService()
        self.reference_transfer_object.team_color_svc = self.team_color_service
        print("Framework partie avec équipe",
              self.cfg.config_dict["GAME"]["our_color"])

        self.ia_coach_initializer(self.reference_transfer_object)

        signal.signal(signal.SIGINT, self._sigint_handler)
        self.ia_running_thread = threading.Thread(
            target=self.game_thread_main_loop)
        self.ia_running_thread.start()
        self.ia_running_thread.join()
Example #10
0
 def setUp(self):
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     self.game.ball = Ball()
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW))
     self.game_state.set_reference(game_world)
     self.game_state = GameState()
     self.empty_graph = Graph()
     self.graph1 = Graph()
     self.a_player = OurPlayer(TeamColor.YELLOW, A_PLAYER_ID)
     self.tactic1 = Stop(self.game_state, self.a_player)
     self.tactic2 = GoToPositionNoPathfinder(self.game_state, self.a_player,
                                             Pose(Position(500, 0), 0))
     self.node1 = Node(self.tactic1)
     self.node2 = Node(self.tactic2)
     self.vertex1 = Vertex(1, foo)
     self.graph1.add_node(self.node1)
     self.graph1.add_node(self.node2)
     self.graph1.add_vertex(0, 1, foo)
Example #11
0
 def setUp(self):
     config_service = ConfigService().load_file("config/sim_standard.cfg")
     self.game_state = GameState()
     self.game = Game()
     self.game.set_referee(Referee())
     self.game.ball = Ball()
     game_world = ReferenceTransferObject(self.game)
     game_world.set_team_color_svc(TeamColorService(TeamColor.YELLOW_TEAM))
     self.game_state.set_reference(game_world)
     self.game_state = GameState()
     self.empty_graph = Graph()
     self.graph1 = Graph()
     self.tactic1 = Stop(self.game_state, 1)
     self.tactic2 = GoToPositionNoPathfinder(self.game_state, 0,
                                             Pose(Position(500, 0), 0))
     self.node1 = Node(self.tactic1)
     self.node2 = Node(self.tactic2)
     self.vertex1 = Vertex(1, foo)
     self.graph1.add_node(self.node1)
     self.graph1.add_node(self.node2)
     self.graph1.add_vertex(0, 1, foo)
 def send_team_color(self):
     cmd = DebugCommand(
         1004,
         {'team_color': TeamColorService().OUR_TEAM_COLOR.name.lower()})
     self.debug_state.append(cmd)
Example #13
0
 def _is_our_team_command(self, command):
     return (self._is_yellow_command(command) and TeamColorService().OUR_TEAM_COLOR is TeamColor.YELLOW) or\
             (self._is_blue_command(command) and TeamColorService().OUR_TEAM_COLOR is TeamColor.BLUE)
Example #14
0
 def _convert_raw_to_them(self, command):
     if TeamColorService().OUR_TEAM_COLOR is TeamColor.YELLOW:
         return command + 30
     else:
         return command + 31