Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Putting "pass" in message when battle order is None in DoubleBattleOrder #659

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/poke_env/player/baselines.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import random
from typing import List
from typing import List, Optional

from poke_env.environment.abstract_battle import AbstractBattle
from poke_env.environment.double_battle import DoubleBattle
Expand Down Expand Up @@ -29,7 +29,7 @@ def choose_singles_move(self, battle: AbstractBattle):
return self.choose_random_move(battle)

def choose_doubles_move(self, battle: DoubleBattle):
orders: List[BattleOrder] = []
orders: List[Optional[BattleOrder]] = []
switched_in = None

if any(battle.force_switch):
Expand All @@ -51,7 +51,7 @@ def choose_doubles_move(self, battle: DoubleBattle):
switches = [s for s in switches if s != switched_in]

if not mon or mon.fainted:
orders.append(DefaultBattleOrder())
orders.append(None)
continue
elif not moves and switches:
mon_to_switch_in = random.choice(switches)
Expand Down
10 changes: 5 additions & 5 deletions src/poke_env/player/battle_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ def message(self) -> str:
+ self.second_order.message.replace("/choose ", "")
)
elif self.first_order:
return self.first_order.message + ", default"
return self.first_order.message + ", pass"
elif self.second_order:
return self.second_order.message + ", default"
return "/choose pass, " + self.second_order.message.replace("/choose ", "")
else:
return self.DEFAULT_ORDER
return "/choose pass, pass"

@staticmethod
def join_orders(first_orders: List[BattleOrder], second_orders: List[BattleOrder]):
Expand All @@ -95,9 +95,9 @@ def join_orders(first_orders: List[BattleOrder], second_orders: List[BattleOrder
if orders:
return orders
elif first_orders:
return [DoubleBattleOrder(first_order=order) for order in first_orders]
return [DoubleBattleOrder(order, None) for order in first_orders]
elif second_orders:
return [DoubleBattleOrder(first_order=order) for order in second_orders]
return [DoubleBattleOrder(None, order) for order in second_orders]
return [DefaultBattleOrder()]


Expand Down
4 changes: 1 addition & 3 deletions src/poke_env/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,7 @@ def choose_random_doubles_move(self, battle: DoubleBattle) -> BattleOrder:
second_switch_in = random.choice(available_switches)
second_order = BattleOrder(second_switch_in)

if first_order and second_order:
return DoubleBattleOrder(first_order, second_order)
return DoubleBattleOrder(first_order or second_order, None)
return DoubleBattleOrder(first_order, second_order)

for (
orders,
Expand Down
Loading