Skip to content
2 changes: 1 addition & 1 deletion examples/reinforcement_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_single_agent_env(cls, config: Dict[str, Any]) -> SingleAgentWrapper:
open_timeout=None,
strict=False,
)
opponent = RandomPlayer()
opponent = RandomPlayer(start_listening=False)
return SingleAgentWrapper(env, opponent)

def calc_reward(self, battle) -> float:
Expand Down
6 changes: 3 additions & 3 deletions src/poke_env/environment/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from poke_env.concurrency import POKE_LOOP, create_in_poke_loop
from poke_env.player.battle_order import (
BattleOrder,
DefaultBattleOrder,
ForfeitBattleOrder,
_EmptyBattleOrder,
)
from poke_env.player.player import Player
from poke_env.ps_client import AccountConfiguration
Expand Down Expand Up @@ -313,7 +313,7 @@ def reset(
self.agent1.order_queue.put(ForfeitBattleOrder())
if self.agent2_to_move:
self.agent2_to_move = False
self.agent2.order_queue.put(DefaultBattleOrder())
self.agent2.order_queue.put(_EmptyBattleOrder())
else:
assert self.agent2_to_move
self.agent2_to_move = False
Expand Down Expand Up @@ -384,7 +384,7 @@ def close(self, force: bool = True, wait: bool = True):
self.agent1.order_queue.put(ForfeitBattleOrder())
if self.agent2_to_move:
self.agent2_to_move = False
self.agent2.order_queue.put(DefaultBattleOrder())
self.agent2.order_queue.put(_EmptyBattleOrder())
else:
assert self.agent2_to_move
self.agent2_to_move = False
Expand Down
6 changes: 6 additions & 0 deletions src/poke_env/player/battle_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def message(self) -> str:
return "/forfeit"


class _EmptyBattleOrder(BattleOrder):
@property
def message(self) -> str:
return ""


@dataclass
class SingleBattleOrder(BattleOrder):
order: Union[Move, Pokemon, str]
Expand Down
3 changes: 2 additions & 1 deletion src/poke_env/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ async def _handle_battle_request(
if isinstance(choice, Awaitable):
choice = await choice
message = choice.message
await self.ps_client.send_message(message, battle.battle_tag)
if message:
await self.ps_client.send_message(message, battle.battle_tag)

async def _handle_challenge_request(self, split_message: List[str]):
"""Handles an individual challenge."""
Expand Down
Loading