Skip to content

Commit

Permalink
randomize team choice (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronangliss authored Dec 10, 2024
1 parent d8a9c25 commit 5db6c08
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/poke_env/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,6 @@ async def accept_challenges(
:packed_team: Team to use. Defaults to generating a team with the agent's teambuilder.
:type packed_team: string, optional.
"""
if packed_team is None:
packed_team = self.next_team

await handle_threaded_coroutines(
self._accept_challenges(opponent, n_challenges, packed_team)
)
Expand All @@ -465,6 +462,7 @@ async def _accept_challenges(
self.logger.debug("Event logged in received in accept_challenge")

for _ in range(n_challenges):
team = packed_team or self.next_team
while True:
username = to_id_str(await self._challenge_queue.get())
self.logger.debug(
Expand All @@ -475,7 +473,7 @@ async def _accept_challenges(
or (opponent == username)
or (isinstance(opponent, list) and (username in opponent))
):
await self.ps_client.accept_challenge(username, packed_team)
await self.ps_client.accept_challenge(username, team)
await self._battle_semaphore.acquire()
break
await self._battle_count_queue.join()
Expand Down Expand Up @@ -713,9 +711,7 @@ async def _battle_against(self, opponent: "Player", n_battles: int):
n_battles,
to_wait=opponent.ps_client.logged_in,
),
opponent.accept_challenges(
to_id_str(self.username), n_battles, opponent.next_team
),
opponent.accept_challenges(to_id_str(self.username), n_battles),
)

async def send_challenges(
Expand Down

0 comments on commit 5db6c08

Please sign in to comment.