Beispiel #1
0
 def __init__(self, team_name: str):
     super().__init__()
     self._stop_event = threading.Event()
     self.world_view = WorldViewCoach(0, team_name)
     self.team = team_name
     # Connection with the server
     self.connection: client_connection.Connection = None
     # Non processed inputs from server
     self.input_queue = queue.Queue()
Beispiel #2
0
 def __init__(self):
     super().__init__()
     self._stop_event = threading.Event()
     self.team = "TRAINER"
     self.world_view = WorldViewCoach(0, self.team)
     # Connection with the server
     self.connection: client_connection.Connection = None
     # Non processed inputs from server
     self.input_queue = queue.Queue()
     self.is_scenario_set = False
     self.scenario_commands: [] = []
Beispiel #3
0
    def test_get_closest_ordered_opponents(self):
        wv = WorldViewCoach(0, "Team1")
        wv.ball = BallOnlineCoach(Coordinate(0, 0), 0, 0)
        for team in ["Team1", "Team2"]:
            for num in range(0, 11):
                wv.players.append(
                    PlayerViewCoach(team, str(num), False,
                                    Coordinate(num, num), 0, 0, 0, 0, False))

        closest_team_members = wv.get_closest_team_players_to_ball(5)
        closest_opponents = wv.get_closest_opponents(closest_team_members, 5)

        for i in range(0, 5):
            self.assertEqual(i, closest_opponents[i].num)
Beispiel #4
0
    def test_get_closest_team_players_to_ball_00(self):
        wv = WorldViewCoach(0, "Team1")
        player1 = PlayerViewCoach("Team1", 1, False, Coordinate(10, 10), 0, 0,
                                  0, 0, False)
        player2 = PlayerViewCoach("Team1", 2, False, Coordinate(5, 5), 0, 0, 0,
                                  0, False)
        player3 = PlayerViewCoach("Team1", 3, False, Coordinate(0, 0), 0, 0, 0,
                                  0, False)
        wv.players.append(player1)
        wv.players.append(player3)
        wv.players.append(player2)
        wv.ball = BallOnlineCoach(Coordinate(0, 0), 0, 0)

        result: [PlayerViewCoach] = wv.get_closest_team_players_to_ball(3)
        self.assertEqual(len(result), 3,
                         "Amount of results should fit the argument.")
        self.assertEqual(result[0].num, 3, "Player 3 should be the closest")
        self.assertEqual(result[1].num, 2, "Player 2 should be second closest")
        self.assertEqual(result[2].num, 1, "Player 1 should be furthest away")
Beispiel #5
0
    def test_get_closest_team_players_to_ball_03(self):
        wv = WorldViewCoach(0, "Team2")
        player1 = PlayerViewCoach("Team1", 1, False, Coordinate(10, 10), 0, 0,
                                  0, 0, False)
        player2 = PlayerViewCoach("Team1", 2, False, Coordinate(5, 5), 0, 0, 0,
                                  0, False)
        player3 = PlayerViewCoach("Team2", 3, False, Coordinate(100, 100), 0,
                                  0, 0, 0, False)

        wv.players.append(player1)
        wv.players.append(player3)
        wv.players.append(player2)
        wv.ball = BallOnlineCoach(Coordinate(0, 0), 0, 0)

        # take only closest player
        result: [PlayerViewCoach] = wv.get_closest_team_players_to_ball(1)
        # Player 3 is team 2, the rest should not be included
        self.assertEqual(len(result), 1,
                         "Amount of results should fit the argument")
        self.assertEqual(result[0].num, 3, "Player 3 should be the closest")
Beispiel #6
0
game_number_path = stat_dir / "game_number.txt"
game_number = 1

try:
    # Run multiple games sequentially
    if MORE_SCENARIOS_TRAINER_MODE:
        random.seed(123456237890)
        for sim in range(NUM_SIMULATIONS):
            # Generate passing strat
            if configurations.USING_PASS_CHAIN_STRAT:
                generate_success = False
                while not generate_success:
                    try:
                        commands, coach_msgs = scenarios.generate_commands_coachmsg_passing_strat(
                            random.randint(0, 1000000000),
                            wv=WorldViewCoach(0, TEAM_1_NAME))
                        generate_success = True
                    except Exception:
                        print("Generating...")
                        continue
            else:
                # For coach positioning strategy
                commands, coach_msgs = scenarios.generate_commands_coachmsg_goalie_positioning(
                    random.randint(0, 1000000000),
                    wv=WorldViewCoach(0, TEAM_1_NAME))

            soccersim: SoccerSim = SoccerSim(team_names=team_names,
                                             num_players=num_players,
                                             trainer_mode=True,
                                             coaches_enabled=COACHES_ENABLED,
                                             udp_player=UDP_PORT_PLAYER,