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

First basic features of the pokemon optimizer #2956

Merged
merged 36 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
204ad0e
catching every single pokemon nearby
douglascamata Aug 7, 2016
c9b25d6
catch lured pokemon in all forts nearby
douglascamata Aug 7, 2016
081d90d
adding run_interval to some tasks to avoid running all the time and m…
douglascamata Aug 7, 2016
4f3a744
added config to ignore item count for Spin and MoveToFort
douglascamata Aug 7, 2016
235f6bf
spinning all pokestops in range
douglascamata Aug 7, 2016
ec83d2b
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into faetur…
douglascamata Aug 7, 2016
1fd60e7
fixing loop in spin fort task
douglascamata Aug 7, 2016
1cc011c
First basic features of the pokemon optimizer
julienlavergne Aug 7, 2016
a894a32
For now, dry run only
julienlavergne Aug 8, 2016
7490bf8
Add cygwin to supported platform and improved log readability (#2948)
villish Aug 8, 2016
2a7a6cd
- Add dry_run and use_lucky_egg in config
julienlavergne Aug 8, 2016
e2e71f1
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 8, 2016
4b0faaa
Add lucky egg support when enough pokemon to evolve
julienlavergne Aug 8, 2016
a205de8
fixing returns
douglascamata Aug 8, 2016
8de542a
Merge branch 'faeture/xp-improvements' of github.com:PokemonGoF/Pokem…
douglascamata Aug 8, 2016
bb931f4
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into faetur…
douglascamata Aug 8, 2016
ef2bb53
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into faetur…
douglascamata Aug 8, 2016
e8fd901
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 8, 2016
ff1f5e4
Merge remote-tracking branch 'origin/faeture/xp-improvements' into po…
julienlavergne Aug 8, 2016
0514a94
- Support Eevee evolution scheme
julienlavergne Aug 9, 2016
d34f74c
Revert "Merge remote-tracking branch 'origin/faeture/xp-improvements'…
julienlavergne Aug 9, 2016
afcbf59
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 9, 2016
4d9375f
- Fix an issue in evolve_pokemon task
julienlavergne Aug 9, 2016
86fe6bb
Add missing inventory refresh at the end of the process
julienlavergne Aug 9, 2016
7d6a24b
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 9, 2016
0552e95
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 10, 2016
49f83e6
Add missing inventory refresh after catching a pokemon
julienlavergne Aug 10, 2016
15fb493
Add parameters "transfer" and "evolve" to activate/deactivate corresp…
julienlavergne Aug 10, 2016
45905e5
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 10, 2016
f30cbf2
Move some functions around
julienlavergne Aug 10, 2016
ae6c278
Default lucky egg to false + had again parameter "evolve_only_with_lu…
julienlavergne Aug 11, 2016
0530d80
Fix qn issue with egg counting
julienlavergne Aug 11, 2016
3714221
Update configuration example
julienlavergne Aug 11, 2016
b880f58
Merge remote-tracking branch 'origin/dev' into pokemon_optimizer
julienlavergne Aug 11, 2016
4b02024
Upgrade to latest inventory
julienlavergne Aug 11, 2016
cbb54d8
Fix bug
julienlavergne Aug 12, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Copy link
Member

Choose a reason for hiding this comment

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

@anakin5 you added a required parameter (no optional parameter logic available yet) to pokemon_evolved event here, but the EvolvePokemon task doesn't send it, so an error will happen. You need to make EvolvePokemon send it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

)
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)
Copy link
Member

Choose a reason for hiding this comment

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

Refreshing is a bad behaviour. It would be great if we could make PokemonCatchWorker update the candy account using the inventory variable when pokemon is captured is avoid this refresh here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The refresh is not for the candy, but for the Pokemon. If this refresh is not done, there is nobody in the loop accounting for the -1 space in the Pokemon bag. It leads to inventory full.
I agree that we should be able to do that without a refresh but we have to be careful since it would mean desynchronizing the space left in the bag with the actually list of Pokemons return by inventory.pokemons.
I propose we create a counter in Pokemons inventory class, that we can increase/decrease just like candies.
But if someone call inventory.pokemons() and the size of that list is different from the counter, then we should immediately refresh.

Copy link
Member

Choose a reason for hiding this comment

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

So we need to modify the pokemon list itself then, not just a counter. The list is cached, so we remove an element from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be adding a Pokemon. Do we have all the info required to fake insert the new Pokemon ?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but I think we do.

self.emit_event(
'gained_candy',
formatted='You now have {quantity} {type} candy!',
Expand Down
Loading