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

Upgrade improvements #4982

Merged
merged 1 commit into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"evolve_count_for_lucky_egg": 80,
"may_use_lucky_egg": true,
"upgrade": true,
"upgrade_level": 60,
"groups": {
"gym": ["Dragonite", "Snorlax", "Lapras", "Arcanine"]
},
Expand Down
2 changes: 1 addition & 1 deletion data/pokemon_upgrade_cost.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
[3, 3000],
[3, 3000],
[3, 3000],
[3, 3000],
[3, 3500],
[3, 3500],
[3, 3500],
[3, 3500],
Expand Down
32 changes: 31 additions & 1 deletion docs/pokemon_optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [evolve_count_for_lucky_egg](#evolve_count_for_lucky_egg)
- [may_use_lucky_egg](#may_use_lucky_egg)
- [upgrade](#upgrade)
- [upgrade_level](#upgrade_level)
- [groups](#groups)
- [keep](#keep)
- [mode](#keep-mode)
Expand Down Expand Up @@ -50,6 +51,7 @@ The Pokemon Optimizer manage transfer and evolution of your Pokemon.
"evolve_count_for_lucky_egg": 80,
"may_use_lucky_egg": true,
"upgrade": true,
"upgrade_level": 60,
"groups": {
"gym": ["Dragonite", "Snorlax", "Lapras", "Arcanine"]
},
Expand Down Expand Up @@ -180,7 +182,7 @@ Better quality Pokemon have priority for evolution and the Pokemon Optimizer wil

The below 2% rule help the Pokemon Optimizer to disregard rare Pokemon and focus on common Pokemon to evolve for xp.

#### 2% rule
###### 2% rule
For each family of Pokemon, if, after evolving your best Pokemon, you have enough candies left to evolve 2% of your total bag capacity, the first rank of the family are eligible for xp evolution.
<br>If you do not have enough candies or Pokemon to evolve these 2%, they will be transfered.

Expand Down Expand Up @@ -245,6 +247,32 @@ It can help you rectify your configuration or guide you during manual power-up.

[[back to top](#pokemon-optimizer)]

### upgrade_level
| Parameter | Possible values | Default |
|-----------------|-----------------|---------|
| `upgrade_level` | `[1-80]` | `60` |

This the maximum level at which you want the Pokemon Optimizer to upgrade your Pokemon.
<br>Pokemon upgrade level cannot be higher than 2 times player level. The parameter value will be majored by `2 * player level`.

Pokemon are either fully upgraded to the maximum possible level or not upgraded at all.
The higher the level is, the more costly in candies and stardust it becomes to upgrade a Pokemon.

###### Cumulative upgrade cost (candy, stardust)

| From - To | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 |
|-----------|:---------:|:-----------:|:-----------:|:-----------:|:-----------:|:-------------:|:-------------:|:-------------:|
| 1 | 9<br>3000 | 19<br>11000 | 38<br>25500 | 58<br>47500 | 87<br>80000 | 126<br>125000 | 196<br>190000 | 319<br>280000 |
| 10 | | 10<br>8000 | 29<br>22500 | 49<br>44500 | 78<br>77000 | 117<br>122000 | 187<br>187000 | 310<br>277000 |
| 20 | | | 19<br>14500 | 39<br>36500 | 68<br>69000 | 107<br>114000 | 177<br>179000 | 300<br>269000 |
| 30 | | | | 20<br>22000 | 49<br>54500 | 88<br>99500 | 158<br>164500 | 281<br>254500 |
| 40 | | | | | 29<br>32500 | 68<br>77500 | 138<br>142500 | 261<br>232500 |
| 50 | | | | | | 39<br>45000 | 109<br>110000 | 232<br>200000 |
| 60 | | | | | | | 70<br>65000 | 193<br>155000 |
| 70 | | | | | | | | 123<br>90000 |

[[back to top](#pokemon-optimizer)]

### groups
| Parameter | Possible values | Default |
|-----------|-----------------|---------|
Expand Down Expand Up @@ -368,6 +396,8 @@ Define according to which criteria you want to sort your Pokemon.
| `iv_defense` | defense component of iv between 0 and 15 |
| `iv_stamina` | stamina component of iv between 0 and 15 |
| `dps` | raw dps based on the moves of the pokemon |
| `dps1` | raw dps of the fast attack |
| `dps2` | raw dps of the charge attack |
| `dps_attack` | estimated average dps when attacking |
| `attack_perfection` | ratio `dps_attack` / `best_dps_attack`. Return same order as `dps_attack` |
| `dps_defense` | estimated average dps when defending |
Expand Down
14 changes: 9 additions & 5 deletions pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def initialize(self):
self.config_evolve_count_for_lucky_egg = self.config.get("evolve_count_for_lucky_egg", 80)
self.config_may_use_lucky_egg = self.config.get("may_use_lucky_egg", False)
self.config_upgrade = self.config.get("upgrade", False)
self.config_upgrade_level = self.config.get("upgrade_level", 60)
self.config_groups = self.config.get("groups", {"gym": ["Dragonite", "Snorlax", "Lapras", "Arcanine"]})
self.config_keep = self.config.get("keep", [{"mode": "by_family", "top": 1, "sort": [{"iv": 0.9}], "evolve": True, "upgrade": False},
{"mode": "by_family", "top": 1, "sort": [{"ncp": 0.9}], "evolve": True, "upgrade": False},
Expand Down Expand Up @@ -154,14 +155,15 @@ def work(self):
xp_all += xp

self.apply_optimization(transfer_all, evolve_all, upgrade_all, xp_all)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this deleted by merge issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it is just not needed. Web inventory is saved at next loop.

inventory.update_web_inventory()

return WorkerResult.SUCCESS

def open_inventory(self):
for pokemon in inventory.pokemons().all():
setattr(pokemon, "ncp", pokemon.cp_percent)
setattr(pokemon, "dps", pokemon.moveset.dps)
setattr(pokemon, "dps1", pokemon.fast_attack.dps)
setattr(pokemon, "dps2", pokemon.charged_attack.dps)
setattr(pokemon, "dps_attack", pokemon.moveset.dps_attack)
setattr(pokemon, "dps_defense", pokemon.moveset.dps_defense)

Expand Down Expand Up @@ -241,7 +243,7 @@ def get_best_pokemon_for_rule(self, pokemon_list, rule):
if len(sorted_pokemon) == 0:
return ([], [], [])

top = max(rule.get("top", 1), 0)
top = max(rule.get("top", 0), 0)
index = int(math.ceil(top)) - 1

if 0 < top < 1:
Expand Down Expand Up @@ -368,17 +370,18 @@ def get_evolution_plan(self, family_id, family_list, try_evolve, try_upgrade, ke
evolve.append(pokemon)

upgrade = []
upgrade_level = min(self.config_upgrade_level, inventory.player().level * 2)

for pokemon in try_upgrade:
level = int(pokemon.level * 2) - 1

if level >= 80:
if level >= upgrade_level:
continue

full_upgrade_candy_cost = 0
full_upgrade_stardust_cost = 0

for i in range(level, 80):
for i in range(level, upgrade_level):
upgrade_cost = self.pokemon_upgrade_cost[i - 1]
full_upgrade_candy_cost += upgrade_cost[0]
full_upgrade_stardust_cost += upgrade_cost[1]
Expand Down Expand Up @@ -586,9 +589,10 @@ def evolve_pokemon(self, pokemon):

def upgrade_pokemon(self, pokemon):
level = int(pokemon.level * 2) - 1
upgrade_level = min(self.config_upgrade_level, inventory.player().level * 2)
candy = inventory.candies().get(pokemon.pokemon_id)

for i in range(level, 80):
for i in range(level, upgrade_level):
upgrade_cost = self.pokemon_upgrade_cost[i - 1]
upgrade_candy_cost = upgrade_cost[0]
upgrade_stardust_cost = upgrade_cost[1]
Expand Down
13 changes: 5 additions & 8 deletions pokemongo_bot/cell_workers/update_web_inventory.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import json
import os
from pokemongo_bot.base_task import BaseTask
from pokemongo_bot import inventory
from pokemongo_bot.base_dir import _base_dir
from pokemongo_bot.base_task import BaseTask
from pokemongo_bot.worker_result import WorkerResult


class UpdateWebInventory(BaseTask):
SUPPORTED_TASK_API_VERSION = 1

def initialize(self):
pass

def work(self):
inventory.update_web_inventory()
inventory.update_web_inventory()

return WorkerResult.SUCCESS