from numpy import *
possible_IVs = arange(32)
possible_EVs = arange(64)
combo_matrix = add.outer(possible_IVs, possible_EVs)
stat_names = ["HP", "Attack", "Defense", "SpAtk", "SpDef", "Speed"]
def CalcIVsFromStats(stats, base_stats, level, nature):
# HP, Atk, Def, Spa, Spd, Spe
# Nature: tuple (up_idx, dn_idx)
for stat_idx, stat_value in enumerate(stats):
cur_stat = (base_stats[stat_idx] * 2 + combo_matrix) * level / 100
if not stat_idx:
cur_stat += level + 10
else:
cur_stat += 5
if stat_idx == nature[0]:
cur_stat *= 11
cur_stat /= 10
elif stat_idx == nature[1]:
cur_stat *= 9
cur_stat /= 10
putative_IVs, putative_EVs = where(cur_stat == stat_value)
print "Possible IV/EV combos for %s" % stat_names[stat_idx]
for EV_idx, IV_val in enumerate(putative_IVs):
cur_EV = 4 * putative_EVs[EV_idx]
print "IV: {:>2d}, EV: {:>3d} - {:>3d}".format(
IV_val, cur_EV, cur_EV + 3
)
print "-------------------------------------------"
Comments