OpenPoGoBot icon indicating copy to clipboard operation
OpenPoGoBot copied to clipboard

Use catch probability from encounter_data to select ball

Open xasdf opened this issue 8 years ago • 0 comments

I propose using catch probability to select ball instead of relying on combat_power.

Example plugins/catch_pokemon/init.py modifications:

        probability = encounter_data.probability[0]
        ...
        # TODO: This should probably be cleaned up
        for catch_attempt in range(20):
            if total_pokeballs == 0:
                log("No Pokeballs in inventory; cannot catch.", color="red")
                return

            pokeball = 0

            if balls_stock[1] > 0:
                pokeball = 1

            if balls_stock[2] > 0:
                if probability < 0.25 or pokemon_potential > 0.82 or combat_power > 1000 or (pokeball is 0 and balls_stock[2] > 9):
                    pokeball = 2

            if balls_stock[3] > 0:
                if probability < 0.15 or pokemon_potential > 0.92 or combat_power > 1200 or (pokeball is 0 and balls_stock[3] > 9):
                    pokeball = 3

            if pokeball == 0:
                log("No ball selected as all balls are low in stock. Saving for better Pokemon.", color="red")
                break

            log("Using {}... ({} left!)".format(bot.item_list[pokeball], balls_stock[pokeball]-1))

            probability -= 0.05
            balls_stock[pokeball] -= 1
            ...

Probability is decreased each time so that better balls can be selected as throws miss. This probably should be enhanced to use master balls too but I don't know their id (is it 4?).

Sorry this is not PR, maybe someone can pick it up and create a proper PR.

xasdf avatar Aug 15 '16 21:08 xasdf