Skip to content

Instantly share code, notes, and snippets.

@TheRealNoob
Created September 23, 2018 21:34
Show Gist options
  • Save TheRealNoob/ad5f1d9a70e2c2be3bfd2a1f31731c4f to your computer and use it in GitHub Desktop.
Save TheRealNoob/ad5f1d9a70e2c2be3bfd2a1f31731c4f to your computer and use it in GitHub Desktop.
"""
Pokemon effectiveness calculator (from the perspective of the attacker)
An attack move can have only one type (ex: fire, water, ground, etc)
A pokemon itself (the enemy in this case) can have one or two types (ex: fire, fire & flying, grass & bug)
"""
normal = {"Normal": 1, "Fighting": 2, "Flying": 1, "Poison": 1, "Ground": 1, "Rock": 1, "Bug": 1, "Ghost": 0, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 1, "Ice": 1, "Dragon": 1, "Dark": 1, "Fairy": 1}
fighting = {"Normal": 1, "Fighting": 1, "Flying": 2, "Poison": 1, "Ground": 1, "Rock": 0.5, "Bug": 0.5, "Ghost": 1, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 2, "Ice": 1, "Dragon": 1, "Dark": 0.5, "Fairy": 2}
flying = {"Normal": 1, "Fighting": 0.5, "Flying": 1, "Poison": 1, "Ground": 0, "Rock": 2, "Bug": 0.5, "Ghost": 1, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 0.5, "Electric": 2, "Psychic": 1, "Ice": 2, "Dragon": 1, "Dark": 1, "Fairy": 1}
poison = {"Normal": 1, "Fighting": 0.5, "Flying": 1, "Poison": 0.5, "Ground": 2, "Rock": 1, "Bug": 0.5, "Ghost": 1, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 0.5, "Electric": 1, "Psychic": 2, "Ice": 1, "Dragon": 1, "Dark": 1, "Fairy": 0.5}
ground = {"Normal": 1, "Fighting": 1, "Flying": 1, "Poison": 0.5, "Ground": 1, "Rock": 0.5, "Bug": 1, "Ghost": 1, "Steel": 1, "Fire": 1, "Water": 2, "Grass": 2, "Electric": 0, "Psychic": 1, "Ice": 2, "Dragon": 1, "Dark": 1, "Fairy": 1}
rock = {"Normal": 0.5, "Fighting": 2, "Flying": 0.5, "Poison": 0.5, "Ground": 2, "Rock": 1, "Bug": 1, "Ghost": 1, "Steel": 2, "Fire": 0.5, "Water": 2, "Grass": 0.5, "Electric": 1, "Psychic": 1, "Ice": 1, "Dragon": 1, "Dark": 1, "Fairy": 1}
bug = {"Normal": 1, "Fighting": 0.5, "Flying": 2, "Poison": 1, "Ground": 0.5, "Rock": 2, "Bug": 1, "Ghost": 1, "Steel": 1, "Fire": 2, "Water": 1, "Grass": 0.5, "Electric": 1, "Psychic": 1, "Ice": 1, "Dragon": 1, "Dark": 1, "Fairy": 1}
ghost = {"Normal": 0, "Fighting": 0, "Flying": 1, "Poison": 0.5, "Ground": 1, "Rock": 1, "Bug": 0.5, "Ghost": 2, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 1, "Ice": 1, "Dragon": 1, "Dark": 2, "Fairy": 1}
steel = {"Normal": 0.5, "Fighting": 2, "Flying": 0.5, "Poison": 0, "Ground": 2, "Rock": 0.5, "Bug": 0.5, "Ghost": 1, "Steel": 0.5, "Fire": 2, "Water": 1, "Grass": 0.5, "Electric": 1, "Psychic": 0.5, "Ice": 0.5, "Dragon": 0.5, "Dark": 1, "Fairy": 0.5}
fire = {"Normal": 1, "Fighting": 1, "Flying": 1, "Poison": 1, "Ground": 2, "Rock": 2, "Bug": 0.5, "Ghost": 1, "Steel": 0.5, "Fire": 0.5, "Water": 2, "Grass": 0.5, "Electric": 1, "Psychic": 1, "Ice": 0.5, "Dragon": 1, "Dark": 1, "Fairy": 0.5}
water = {"Normal": 1, "Fighting": 1, "Flying": 1, "Poison": 1, "Ground": 1, "Rock": 1, "Bug": 1, "Ghost": 1, "Steel": 0.5, "Fire": 0.5, "Water": 0.5, "Grass": 2, "Electric": 2, "Psychic": 1, "Ice": 0.5, "Dragon": 1, "Dark": 1, "Fairy": 1}
grass = {"Normal": 1, "Fighting": 1, "Flying": 2, "Poison": 2, "Ground": 0.5, "Rock": 1, "Bug": 2, "Ghost": 1, "Steel": 1, "Fire": 2, "Water": 0.5, "Grass": 0.5, "Electric": 0.5, "Psychic": 1, "Ice": 2, "Dragon": 1, "Dark": 1, "Fairy": 1}
electric = {"Normal": 1, "Fighting": 1, "Flying": 0.5, "Poison": 1, "Ground": 2, "Rock": 1, "Bug": 1, "Ghost": 1, "Steel": 0.5, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 0.5, "Psychic": 1, "Ice": 1, "Dragon": 1, "Dark": 1, "Fairy": 1}
psychic = {"Normal": 1, "Fighting": 0.5, "Flying": 1, "Poison": 1, "Ground": 1, "Rock": 1, "Bug": 2, "Ghost": 2, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 0.5, "Ice": 1, "Dragon": 1, "Dark": 2, "Fairy": 1}
ice = {"Normal": 1, "Fighting": 2, "Flying": 1, "Poison": 1, "Ground": 1, "Rock": 2, "Bug": 1, "Ghost": 1, "Steel": 2, "Fire": 2, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 1, "Ice": 0.5, "Dragon": 1, "Dark": 1, "Fairy": 1}
dragon = {"Normal": 1, "Fighting": 1, "Flying": 1, "Poison": 1, "Ground": 1, "Rock": 1, "Bug": 1, "Ghost": 1, "Steel": 1, "Fire": 0.5, "Water": 0.5, "Grass": 0.5, "Electric": 0.5, "Psychic": 1, "Ice": 2, "Dragon": 2, "Dark": 1, "Fairy": 2}
dark = {"Normal": 1, "Fighting": 2, "Flying": 1, "Poison": 1, "Ground": 1, "Rock": 1, "Bug": 2, "Ghost": 0.5, "Steel": 1, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 0, "Ice": 1, "Dragon": 1, "Dark": 0.5, "Fairy": 2}
fairy = {"Normal": 1, "Fighting": 0.5, "Flying": 1, "Poison": 2, "Ground": 1, "Rock": 1, "Bug": 0.5, "Ghost": 1, "Steel": 2, "Fire": 1, "Water": 1, "Grass": 1, "Electric": 1, "Psychic": 1, "Ice": 1, "Dragon": 0, "Dark": 0.5, "Fairy": 1}
# this takes two inputs. attack_type is the type of the attacking move. this can have only one type.
# enemy_type is the type of the enmy pokemon. this can have one or two types. (ex: fire, flying & fire, bug & grass)
# example: efficiency_lookup("Fire", ["Water", "Fighting"])
def efficiency_lookup(attack_type, enemy_type):
first = enemy_type[0]
second = enemy_type[1]
if first == "Normal":
first = normal[attack_type]
elif first == "Fire":
first = fire[attack_type]
elif first == "Water":
first = water[attack_type]
elif first == "Electric":
first = electric[attack_type]
elif first == "Grass":
first = grass[attack_type]
elif first == "Ice":
first = ice[attack_type]
elif first == "Fighting":
first = fighting[attack_type]
elif first == "Poison":
first = poison[attack_type]
elif first == "Ground":
first = ground[attack_type]
elif first == "Flying":
first = flying[attack_type]
elif first == "Psychic":
first = psychic[attack_type]
elif first == "Bug":
first = bug[attack_type]
elif first == "Rock":
first = rock[attack_type]
elif first == "Ghost":
first = ghost[attack_type]
elif first == "Dragon":
first = dragon[attack_type]
elif first == "Dark":
first = dark[attack_type]
elif first == "Steel":
first = steel[attack_type]
elif first == "Fairy":
first = fairy[attack_type]
if second == '':
second = 1
elif second == "Normal":
second = normal[attack_type]
elif second == "Fire":
second = fire[attack_type]
elif second == "Water":
second = water[attack_type]
elif second == "Electric":
second = electric[attack_type]
elif second == "Grass":
second = grass[attack_type]
elif second == "Ice":
second = ice[attack_type]
elif second == "Fighting":
second = fighting[attack_type]
elif second == "Poison":
second = poison[attack_type]
elif second == "Ground":
second = ground[attack_type]
elif second == "Flying":
second = flying[attack_type]
elif second == "Psychic":
second = psychic[attack_type]
elif second == "Bug":
second = bug[attack_type]
elif second == "Rock":
second = rock[attack_type]
elif second == "Ghost":
second = ghost[attack_type]
elif second == "Dragon":
second = dragon[attack_type]
elif second == "Dark":
second = dark[attack_type]
elif second == "Steel":
second = steel[attack_type]
elif second == "Fairy":
second = fairy[attack_type]
return first * second
# find which move in our move_list is the most effective
for move in move_list:
efficiency = efficiency_lookup(attack_type=move, enemy_type=enemy)
#cut out the rest of the code, but basically test if the newest tested move has a higher efficiency than the last.
return most_effective_move
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment