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

Using higher Pokeballs when available #1755

Closed
Donwulff opened this issue Jul 30, 2016 · 4 comments
Closed

Using higher Pokeballs when available #1755

Donwulff opened this issue Jul 30, 2016 · 4 comments

Comments

@Donwulff
Copy link

Expected Behavior

Bot uses Great Balls and Ultra Balls as needed, and saves berries.

Actual Behavior

Bot uses RazzBerries whenever one is available, while Great Balls fill up whole inventory.

Steps to Reproduce

Run bot

Other Information

dev branch

Technically, you can just change the thresholds for using higher level balls, as they're already supported in the code. Personally, I like to set the pokeball difficulty level to same as the RazzBerries: "if catch_rate[pokeball - 1] < 0.50 and items_stock[current_type] > 0:" This makes it so the bot prefers to use higher level balls, actually using them up, and uses the berries only if out of balls or even the balls don't get probability to 50%. You may want to bring those difficulty levels even higher when you find your bag filling up with items.

However, I understand people might have different preferences, maybe they really want to save 350 Great Balls for their level 40 run and use only plain Pokeballs for the first 30 levels. Because of that, the difficulty thresholds should be at the very least exposed into config.json. Are there other Pokeball strategies that make generic enough sense to be codified? Should you always be preferring whichever item you have most of, for example?

@xc-mezcal
Copy link
Contributor

I want to trying to update the catching logic :D

@endeavor7
Copy link

endeavor7 commented Jul 30, 2016

You can swap the order for berries vs balls to make the decision tree for balls happen before berries. That way it ups the ball and if the threshold is still below the desired level, it will use a berry.

Here's how I changed mine (I also added a check for pokemon_potential. No use wasting berries on high CP low IV mons):

                    items_stock = self.bot.current_inventory()
                    while True:
                        # pick the most simple ball from stock
                        pokeball = 1  # start from 1 - PokeBalls

                        current_type = pokeball
                        # if this type's stock = 0 and not top tier yet
                        while items_stock[current_type] is 0 and current_type < 3:
                            # progress to next tier
                            current_type += 1
                            # next tier's stock > 0
                            if items_stock[current_type] > 0:
                                pokeball = current_type

                        # re-check stock again
                        if items_stock[pokeball] is 0:
                            logger.log('Out of pokeballs', 'red')
                            return PokemonCatchWorker.NO_POKEBALLS                           

                        # change ball to next tier if catch rate is too low
                        current_type = pokeball
                        while current_type < 3:
                            current_type += 1
                            if catch_rate[pokeball - 1] < 0.40 and items_stock[current_type] > 0 and pokemon_potential > 0.5:
                                # if current ball chance to catch is under 35%,
                                # and player has better ball - then use it
                                pokeball = current_type  # use better ball

                        # @TODO, use the best ball in stock to catch VIP (Very Important Pokemon: Configurable)

                        items_stock[pokeball] -= 1
                        success_percentage = '{0:.2f}'.format(catch_rate[pokeball - 1] * 100)
                        logger.log('Using {} (chance: {}%)... ({} left!)'.format(
                            self.item_list[str(pokeball)],
                            success_percentage,
                            items_stock[pokeball]
                        ))

                        # Use berry to increase success chance.
                        berry_id = 701  # @ TODO: use better berries if possible
                        berries_count = self.bot.item_inventory_count(berry_id)
                        if catch_rate[pokeball-1] < 0.3 and berries_count > 0:  # and berry is in stock
                            success_percentage = '{0:.2f}'.format(catch_rate[pokeball-1]*100)
                            logger.log(
                                'Catch Rate with normal Pokeball is low ({}%). '
                                'Throwing {}... ({} left!)'.format(
                                    success_percentage,
                                    self.item_list[str(berry_id)],berries_count-1
                                )
                            )

                            if items_stock[pokeball] is 0:
                                break

                            self.api.use_item_capture(
                                item_id=berry_id,
                                encounter_id=encounter_id,
                                spawn_point_id=self.spawn_point_guid
                            )
                            response_dict = self.api.call()
                            if response_dict and response_dict['status_code'] is 1 and 'item_capture_mult' in \
                                    response_dict['responses']['USE_ITEM_CAPTURE']:

                                for i in range(len(catch_rate)):
                                    if 'item_capture_mult' in response_dict['responses']['USE_ITEM_CAPTURE']:
                                        catch_rate[i] = catch_rate[i] * \
                                                        response_dict['responses']['USE_ITEM_CAPTURE'][
                                                            'item_capture_mult']

                                success_percentage = '{0:.2f}'.format(catch_rate[pokeball - 1] * 100)
                                logger.log('Catch Rate with normal Pokeball has increased to {}%'.format(
                                    success_percentage))
                            else:
                                if response_dict['status_code'] is 1:
                                    logger.log('Fail to use berry. Seem like you are softbanned.', 'red')
                                    self.bot.softban = True
                                else:
                                    logger.log(
                                        'Fail to use berry. Status Code: {}'.format(response_dict['status_code']),
                                        'red')

@Donwulff
Copy link
Author

Partly addressed by the already landed #1807 though it's not as configurable as I'd like; I'll give it a spin and see if my inventory will still fill up with Great Balls while always being out of Razzberries and low capture chance...

@xorinzor
Copy link

xorinzor commented Aug 1, 2016

Duplicate of #1893, #2043, #2097 and #2075

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants