Skip to content

Commit

Permalink
First basic features of the pokemon optimizer (#2956)
Browse files Browse the repository at this point in the history
* catching every single pokemon nearby

* catch lured pokemon in all forts nearby

* adding run_interval to some tasks to avoid running all the time and minimum tick time of 5 seconds

Tasks inheriting from BaseTask should use `self._update_last_ran` and
`_time_to_run` if they want to implement the time based running. The
config to set a custom timer is named `run_interval`.

* added config to ignore item count for Spin and MoveToFort

this works good with the `run_interval` configuration added to
TransferPokemon and RecycleItem

* spinning all pokestops in range

* fixing loop in spin fort task

* First basic features of the pokemon optimizer

* For now, dry run only

* Add cygwin to supported platform and improved log readability (#2948)

* Add cygwin to supported platform and improved log readability

* fixed formatting

* - Add dry_run and use_lucky_egg in config
- Evolve all pokemons together and only if enough for a full lucky egg (90).
- Keep enough candies for consecutive evolutions of best pokemons
- Only evolve the lowest rank of a family

* Add lucky egg support when enough pokemon to evolve

* fixing returns

* - Support Eevee evolution scheme
- Rename "use_lucky_egg" parameter in the more accurate "evolve_only_with_lucky_egg"

* Revert "Merge remote-tracking branch 'origin/faeture/xp-improvements' into pokemon_optimizer"

This reverts commit ff1f5e4, reversing
changes made to e8fd901.

* - Fix an issue in evolve_pokemon task
- Use common inventory
- Add configuration example

* Add missing inventory refresh at the end of the process

* Add missing inventory refresh after catching a pokemon

* Add parameters "transfer" and "evolve" to activate/deactivate corresponding action. If both false, this is equivalent to a dry_run.
Add parameters "use_lucky_egg" to allow task to use a lucky egg before evolve.
Add parameter "minimum_evolve_for_lucky_egg" to add a requirement on the number of evolution before using a lucky egg.

* Move some functions around

* Default lucky egg to false + had again parameter "evolve_only_with_lucky_egg"

* Fix qn issue with egg counting
Add configuration parameter to allow customization of how pokemons are ranked in a family

* Update configuration example

* Upgrade to latest inventory

* Fix bug
  • Loading branch information
julienlavergne authored and elicwhite committed Aug 12, 2016
1 parent f83e767 commit b8ea368
Show file tree
Hide file tree
Showing 7 changed files with 396 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ configs/*
!configs/config.json.map.example
!configs/path.example.json
!config.json.cluster.example
!config.json.optimizer.example

# Virtualenv folders
bin/
Expand Down
105 changes: 105 additions & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"tasks": [
{
"type": "HandleSoftBan"
},
{
"type": "CollectLevelUpReward"
},
{
"type": "IncubateEggs",
"config": {
"longer_eggs_first": true
}
},
{
"type": "PokemonOptimizer",
"config": {
"transfer": true,
"evolve": true,
"use_lucky_egg": true,
"evolve_only_with_lucky_egg": true,
"minimum_evolve_for_lucky_egg": 90,
"keep": [
{
"top": 1,
"evolve": true,
"// Available sorting keys are:": true,
"// iv, cp, ncp, ivcp, max_cp, iv_attack, iv_defense, iv_stamina, hp_max, level": true,
"sort": ["iv"]
},
{
"top": 1,
"evolve": true,
"sort": ["ncp"]
},
{
"top": 1,
"evolve": false,
"sort": ["cp"]
}
]
}
},
{
"type": "RecycleItems",
"config": {
"min_empty_space": 15,
"item_filter": {
"Pokeball": { "keep": 100 },
"Potion": { "keep": 10 },
"Super Potion": { "keep": 20 },
"Hyper Potion": { "keep": 30 },
"Revive": { "keep": 30 },
"Razz Berry": { "keep": 100 }
}
}
},
{
"type": "CatchVisiblePokemon"
},
{
"type": "CatchLuredPokemon"
},
{
"type": "SpinFort",
"config": {
"ignore_item_count": true
}
},
{
"type": "MoveToFort",
"config": {
"lure_attraction": false,
"lure_max_distance": 2000,
"ignore_item_count": true
}
}
],
"map_object_cache_time": 5,
"forts": {
"avoid_circles": true,
"max_circle_size": 50
},
"websocket_server": true,
"walk": 4.16,
"action_wait_min": 1,
"action_wait_max": 4,
"debug": false,
"test": false,
"health_record": false,
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"catch": {
"any": {
"always_catch": true
}
}
}
2 changes: 1 addition & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def _register_events(self):
)
self.event_manager.register_event(
'pokemon_evolved',
parameters=('pokemon', 'iv', 'cp')
parameters=('pokemon', 'iv', 'cp', 'xp')
)
self.event_manager.register_event('skip_evolve')
self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))
Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/cell_workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from move_to_map_pokemon import MoveToMapPokemon
from nickname_pokemon import NicknamePokemon
from pokemon_catch_worker import PokemonCatchWorker
from pokemon_optimizer import PokemonOptimizer
from transfer_pokemon import TransferPokemon
from recycle_items import RecycleItems
from spin_fort import SpinFort
Expand Down
3 changes: 2 additions & 1 deletion pokemongo_bot/cell_workers/evolve_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def _execute_pokemon_evolve(self, pokemon, cache):
data={
'pokemon': pokemon.name,
'iv': pokemon.iv,
'cp': pokemon.cp
'cp': pokemon.cp,
'xp': 0
}
)
inventory.candies().get(pokemon.pokemon_id).consume(pokemon.evolution_cost)
Expand Down
3 changes: 1 addition & 2 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
)

# We could refresh here too, but adding 3 saves a inventory request
candy = inventory.candies().get(pokemon.num)
candy.add(3)
candy = inventory.candies(True).get(pokemon.num)
self.emit_event(
'gained_candy',
formatted='You now have {quantity} {type} candy!',
Expand Down
Loading

1 comment on commit b8ea368

@balpoint
Copy link

@balpoint balpoint commented on b8ea368 Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this idea, but what do the following things mean:

"top": 1 ??
ncp ?

i would use it like this if its possible:

       "type": "PokemonOptimizer",
        "config": {
            "transfer": true,
            "evolve": true,
            "use_lucky_egg": true,
            "evolve_only_with_lucky_egg": true,
            "minimum_evolve_for_lucky_egg": 20,
            "keep": [
                {
                    "weedle": 45,
                    "evolve": true,
                    "sort": ["iv"]
                },
                {
                    "pidgey": 45,
                    "evolve": true,
                    "sort": ["iv"]
                },
                {

//below to keep every other pokemon than defined above based on IV CP, like the old release config did >//like this: "Slowbro": { "keep_best_cp": 1, "keep_best_iv": 1 },

                  "top": 2,
                    "evolve": false,
                    "sort": ["ivcp"]
                }
            ]
        }
    },

Please sign in to comment.