def __init__(self, species): self.species = species self.name = _vdex.species_name(species) self.details = details = _vdex.species_details(species) self.generation = _vdex.generation_name(details.generation) self.egg_groups = [_vdex.egg_group_name(details.egg_group1)] if details.has_egg_group2: self.egg_groups.append(_vdex.egg_group_name(details.egg_group2)) self.evolves_from = None if details.evolved: self.evolves_from = EvolvesFrom(details.evolves_from) self.pokemon = [] for index in range(_vdex.pokemon_count(species)): self.pokemon.append(Pokemon(_vdex.pokemon(species, index)))
def score_combinations(pokemon, size, cutoff): combs = list(combinations(pokemon, size)) scores = [] for i, team in enumerate(combs): if i % 1000 == 0: print("{}/{}".format(i, len(combs)), file=sys.stderr) score = score_team(*team) if score[0] >= cutoff: scores.append(score) print("Sorting...", file=sys.stderr) scores.sort() for mt, mc, ft, team in scores: print("TEAM: {}".format(" ".join( _vdex.species_name(species) for species in team))) print_team(*team) print("MINIMUM: {} {}s; FULL TOTAL: {}".format(-mc, mt, ft)) print()
def score_team(*team): ratings = [] for species in team: name = _vdex.species_name(species) pokemon = _vdex.pokemon(species, 0) details = _vdex.pokemon_details(pokemon) types = get_types(details) resistance = rate_resistance(types, get_immunity(details)) offense = rate_offense(types) ratings.append([ resistance[typ] + (5 * offense[typ]) for typ in range(_vdex.TYPE_COUNT) ]) totals = [sum(a) for a in zip(*ratings)] mintotal = min(totals) mincount = totals.count(mintotal) fulltotal = sum(totals) return (mintotal, -mincount, fulltotal, team)
def rank_all(generations=None, final=False): if not generations: generations = list(range(5)) evolves = set(gen_evolves(generations)) all_rated = [] for species in range(_vdex.SPECIES_COUNT): species_details = _vdex.species_details(species) if species_details.generation not in generations: continue if final and species in evolves: continue name = _vdex.species_name(species) pokemon = _vdex.pokemon(species, 0) details = _vdex.pokemon_details(pokemon) rating = sum(details.stats) - 400 types = get_types(details) rating += 6 * sum(rate_resistance(types, get_immunity(details))) # TODO: Make offense less simplistic rating += 30 * sum(rate_offense(types)) all_rated.append((rating, name)) all_rated.sort(reverse=True) return all_rated
def print_team(*team): print( "Nrm Fit Fly Psn Gnd Rck Bug Gst Stl Fir Wtr Grs Elc Psy Ice Dgn Drk Pokemon" ) ratings = [] for species in team: name = _vdex.species_name(species) pokemon = _vdex.pokemon(species, 0) details = _vdex.pokemon_details(pokemon) types = get_types(details) resistance = rate_resistance(types, get_immunity(details)) print(" ".join([("({})" if r < 0 else " {} ").format(abs(r)) for r in resistance] + [name])) offense = rate_offense(types) print(" ".join([(" +" if h else " ") for h in offense])) ratings.append([ resistance[typ] + (5 * offense[typ]) for typ in range(_vdex.TYPE_COUNT) ]) totals = [sum(a) for a in zip(*ratings)] print(" ".join(["{:3d}".format(t) for t in totals] + ["TOTAL", str(sum(totals))]))
return [EFFICACY_RATING[efficacies[damage]] for damage in range(count)] def gen_evolves(generations): for species in range(_vdex.SPECIES_COUNT): species_details = _vdex.species_details(species) if species_details.generation not in generations: continue from_id = species_details.evolves_from.from_id from_details = _vdex.species_details(from_id) if from_details.generation not in generations: continue yield from_id SPECIES = dict([(_vdex.species_name(i), i) for i in range(_vdex.SPECIES_COUNT)]) def rate(name): species = SPECIES[name] species_details = _vdex.species_details(species) pokemon = _vdex.pokemon(species, 0) details = _vdex.pokemon_details(pokemon) types = get_types(details) offense = rate_offense(types) resistance = rate_resistance(types, get_immunity(details)) stats = list(details.stats) rating = 30 * sum(offense) + 6 * sum(resistance) + sum(stats) - 400 r = { "offense": offense,