JDBumgardner / stone_ground_hearth_battles

Apache License 2.0
20 stars 2 forks source link

Trying to pull a type of card from deck that contains no examples of that card results in exception #38

Open JDBumgardner opened 4 years ago

JDBumgardner commented 4 years ago

TessGreymane and StasisElemental seem to be throwing exceptions when the the deck has no appropriate cards. Do we know what it's supposed to do in this situation?

Traceback (most recent call last): File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/training/pytorch/ppo.py", line 403, in main() File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/training/pytorch/ppo.py", line 399, in main ppo_learner.run() File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/training/pytorch/ppo.py", line 334, in run worker.play_game() File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/training/pytorch/worker.py", line 44, in play_game host.play_game() File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/host/round_robin_host.py", line 61, in play_game self.play_round() File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/host/round_robin_host.py", line 52, in playround for in self.play_round_generator(): File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/host/round_robin_host.py", line 35, in play_round_generator self._apply_and_record(player_name, action, agent_annotation) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/host/host.py", line 41, in _apply_and_record action.apply(self.tavern.players[player_name]) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/agent.py", line 105, in apply player.summon_from_hand(self.index, self.targets) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/core/player.py", line 143, in summon_from_hand self.broadcast_buy_phase_event(events.SummonBuyEvent(card, target_cards)) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/core/player.py", line 304, in broadcast_buy_phase_event card.handle_event(event, BuyPhaseContext(self, randomizer or self.tavern.randomizer)) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/core/cards.py", line 168, in handle_event self.battlecry(event.targets, context) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/core/card_pool.py", line 2127, in base_battlecry random_elemental = context.randomizer.select_add_to_store(available_elementals) File "/home/jacob/PycharmProjects/hearthstone_battlegrounds/hearthstone/simulator/core/randomizer.py", line 97, in select_add_to_store return self.rand.choice(cards) File "/usr/lib/python3.7/random.py", line 261, in choice raise IndexError('Cannot choose from an empty sequence') from None IndexError: Cannot choose from an empty sequence

Process finished with exit code 1

jeremysalwen commented 4 years ago

Sort of related to #9. I think that on the basis of these bugs, those two cards probably don't actually remove anything from the deck.

JDBumgardner commented 4 years ago

That's an easy fix and makes the most sense I think

JDBumgardner commented 4 years ago

Ok, Jeremy made it so these functions just don't remove cards from the deck. It seems like they probably wouldn't, based on this error. I'm gonna call this closed.

ethansaxenian commented 4 years ago

Just got this after 1800 steps of 8v8 training. Looks like this is from the Primalfin Lookout discover.

Traceback (most recent call last): File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/training/pytorch/ppo.py", line 422, in main() File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/training/pytorch/ppo.py", line 418, in main ppo_learner.run() File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/training/pytorch/ppo.py", line 346, in run worker.play_game() File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/training/pytorch/worker/worker.py", line 45, in play_game host.play_game() File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/host/round_robin_host.py", line 61, in play_game self.play_round() File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/host/round_robin_host.py", line 52, in playround for in self.play_round_generator(): File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/host/round_robin_host.py", line 35, in play_round_generator self._apply_and_record(player_name, action, agent_annotation) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/host/host.py", line 41, in _apply_and_record action.apply(self.tavern.players[player_name]) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/agent.py", line 105, in apply player.summon_from_hand(self.index, self.targets) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/core/player.py", line 143, in summon_from_hand self.broadcast_buy_phase_event(events.SummonBuyEvent(card, target_cards)) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/core/player.py", line 305, in broadcast_buy_phase_event card.handle_event(event, BuyPhaseContext(self, randomizer or self.tavern.randomizer)) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/core/cards.py", line 172, in handle_event self.battlecry(event.targets, context) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/core/card_pool.py", line 1960, in base_battlecry context.owner.draw_discover(lambda card: card.check_type(MONSTER_TYPES.MURLOC) and card.tier <= context.owner.tavern_tier and type(card) != type(self)) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/core/player.py", line 190, in draw_discover discovered_cards.append(self.tavern.randomizer.select_discover_card(discoverables)) File "/Users/ethansaxenian/Documents/GitHub/stone_ground_hearth_battles/hearthstone/simulator/core/randomizer.py", line 82, in select_discover_card return self.rand.choice(discoverables) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/random.py", line 290, in choice raise IndexError('Cannot choose from an empty sequence') from None IndexError: Cannot choose from an empty sequence

Process finished with exit code 1

jeremysalwen commented 4 years ago

We should really run an experiment for this, but for now so that training completes you can hardcode it to not crash.