Skip to content

Commit 5db6c08

Browse files
randomize team choice (#655)
1 parent d8a9c25 commit 5db6c08

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/poke_env/player/player.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ async def accept_challenges(
443443
:packed_team: Team to use. Defaults to generating a team with the agent's teambuilder.
444444
:type packed_team: string, optional.
445445
"""
446-
if packed_team is None:
447-
packed_team = self.next_team
448-
449446
await handle_threaded_coroutines(
450447
self._accept_challenges(opponent, n_challenges, packed_team)
451448
)
@@ -465,6 +462,7 @@ async def _accept_challenges(
465462
self.logger.debug("Event logged in received in accept_challenge")
466463

467464
for _ in range(n_challenges):
465+
team = packed_team or self.next_team
468466
while True:
469467
username = to_id_str(await self._challenge_queue.get())
470468
self.logger.debug(
@@ -475,7 +473,7 @@ async def _accept_challenges(
475473
or (opponent == username)
476474
or (isinstance(opponent, list) and (username in opponent))
477475
):
478-
await self.ps_client.accept_challenge(username, packed_team)
476+
await self.ps_client.accept_challenge(username, team)
479477
await self._battle_semaphore.acquire()
480478
break
481479
await self._battle_count_queue.join()
@@ -713,9 +711,7 @@ async def _battle_against(self, opponent: "Player", n_battles: int):
713711
n_battles,
714712
to_wait=opponent.ps_client.logged_in,
715713
),
716-
opponent.accept_challenges(
717-
to_id_str(self.username), n_battles, opponent.next_team
718-
),
714+
opponent.accept_challenges(to_id_str(self.username), n_battles),
719715
)
720716

721717
async def send_challenges(

0 commit comments

Comments
 (0)