Beispiel #1
0
    def setUp(self):
        self.my_side = self.bc.build_my_side(MY_TEAM)

        self.original_foe_side = self.bc.build_my_side(FOE_TEAM)
        foe_team = [UnrevealedPokemon() for _ in range(6)]
        foe_team[: self.revealed_foes] = self.original_foe_side.team[: self.revealed_foes]

        self.foe_side = FoeBattleSide(foe_team, 1, "test-foe")

        self.battlefield = BattleField(self.my_side, self.foe_side)
        # pass empty tuples to cause error if the battle tries to make its own rollout decisions
        self.battle = BreakpointBattle.from_battlefield(self.battlefield, (), ())

        with self.assertRaises(BreakNewTurn) as ex:
            self.battle.run_new_battle()
        self.breakpoint = ex.exception
        self.root = new_node(ex.exception.state)(self.battle, depth=0, breakpoint=ex.exception)
Beispiel #2
0
    def select_action(self, battlefield, moves, switches, can_mega):
        root_field = deepcopy(battlefield)
        self.fill_in_unrevealed(root_field, max_fill=1)
        sanitize_battle_state(root_field)

        if moves is None: # force-switch
            if self.my_side(battlefield).active_pokemon.is_fainted():
                if self.foe_side(battlefield).active_pokemon.is_fainted():
                    breakpoint = BreakDoublePostFaintSwitch
                    log.i('Requesting switch action for a double-switch-in')
                else:
                    breakpoint = BreakPostFaintSwitch(self.my_player)
                    log.i('Requesting switch action for a single switch-in after a faint')
            else:
                breakpoint = BreakMustSwitch(self.my_player)
                log.i('Requesting switch action after a switch move/item took effect')
        else:
            breakpoint = BreakNewTurn
            log.i('Action requested for turn %d', battlefield.turns)

        battle = BreakpointBattle.from_battlefield(root_field, (), ())
        # pylint: disable=unused-variable
        root_node = new_node(breakpoint.state)(battle, depth=0, breakpoint=breakpoint)