'CP perfect percent is more accurate than IV perfect
We know attack plays an important role in CP, and different
pokemons have different base value, that\'s means 15/14/15 is
better than 14/15/15 for lot of pokemons, and if one pokemon\'s
base def is more than base sta, 15/15/14 is better than 15/14/15.
See https://github.com/jabbink/PokemonGoBot/issues/469
So calculate CP perfection at final level for the best of the final
evolutions of the pokemon.'

def _compute_cp_perfection(self):

    variants = []
    iv_attack = self.iv_attack
    iv_defense = self.iv_defense
    iv_stamina = self.iv_stamina
    cp_m = LevelToCPm.MAX_CPM
    last_evolution_ids = self.last_evolution_ids
    for pokemon_id in last_evolution_ids:
        poke_info = Pokemons.data_for(pokemon_id)
        base_attack = poke_info.base_attack
        base_defense = poke_info.base_defense
        base_stamina = poke_info.base_stamina
        worst_cp = _calc_cp(base_attack, base_defense, base_stamina, 0, 0, 0, cp_m)
        perfect_cp = _calc_cp(base_attack, base_defense, base_stamina, cp_multiplier=cp_m)
        current_cp = _calc_cp(base_attack, base_defense, base_stamina, iv_attack, iv_defense, iv_stamina, cp_m)
        cp_perfection = ((current_cp - worst_cp) / (perfect_cp - worst_cp))
        variants.append(cp_perfection)
    cp_perfection = max(variants)
    return cp_perfection
