Skip to content

Instantly share code, notes, and snippets.

@rmkane

rmkane/calculator.py

Created Feb 15, 2017
Embed
What would you like to do?
Pokémon GO CP Calculator
#!/usr/bin/env python3
'''
Pokemon GO CP Calculator
Formula: https://reddit.com/r/TheSilphRoad/comments/4t7r4d/exact_pokemon_cp_formula/
Calculator: https://pokemongohub.net/pokemon-go-evolution-calculator/
'''
import numpy as np
from itertools import product
cp_multiplier = [
0.09400000, 0.16639787, 0.21573247, 0.25572005, 0.29024988,
0.32108760, 0.34921268, 0.37523559, 0.39956728, 0.42250001,
0.44310755, 0.46279839, 0.48168495, 0.49985844, 0.51739395,
0.53435433, 0.55079269, 0.56675452, 0.58227891, 0.59740001,
0.61215729, 0.62656713, 0.64065295, 0.65443563, 0.66793400,
0.68116492, 0.69414365, 0.70688421, 0.71939909, 0.73170000,
0.73776948, 0.74378943, 0.74976104, 0.75568551, 0.76156384,
0.76739717, 0.77318650, 0.77893275, 0.78463697, 0.79030001
]
def compute_cp(base_atk, base_def, base_sta, iv_sta, iv_atk, iv_def):
result = {}
for lvl in range(1, 41):
m = cp_multiplier[lvl - 1]
attack = (base_atk + iv_atk) * m
defense = (base_def + iv_def) * m
stamina = (base_sta + iv_sta) * m
cp = int(max(10, np.floor(np.sqrt(attack * attack * defense * stamina) / 10)))
result[cp] = lvl
return result
if __name__ == '_main_':
possible_stats = product(range(1, 16), repeat=3)
for stats in possible_stats:
data = compute_cp(*stats)
if 1555 in data and 1633 in data and 1711 in data:
print max(data), stats
atk_ = 186
def_ = 168
sta_ = 260
print max(compute_cp(atk_, def_, sta_, 0, 0, 0))
print max(compute_cp(atk_, def_, sta_, 15, 15, 15))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment