Last active
December 17, 2020 19:01
-
-
Save keithstellyes/b6a08532b05244aa0fb8ac0c404c0ca2 to your computer and use it in GitHub Desktop.
Generates all possible rock-paper-scissors type combinations for pokemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Author: Keith Stellyes | |
A script that computes all possible rock-paper-scissors combinations of types | |
''' | |
type_source = ''' | |
Bug Grass, Dark, Psychic Fire, Flying, Rock | |
Dark Ghost, Psychic Bug, Fairy, Fighting | |
Dragon Dragon Dragon, Fairy, Ice | |
Electric Flying, Water Ground | |
Fairy Fighting, Dark, Dragon Poison, Steel | |
Fighting Dark, Ice, Normal, Rock, Steel Fairy, Flying, Psychic | |
Fire Bug, Grass, Ice, Steel Ground, Rock, Water | |
Flying Bug, Fighting, Grass Electric, Ice, Rock | |
Ghost Ghost, Psychic Dark, Ghost | |
Grass Ground, Rock, Water Bug, Fire, Flying, Ice, Poison | |
Ground Electric, Fire, Poison, Rock, Steel Grass, Ice, Water | |
Ice Dragon, Flying, Grass, Ground Fighting, Fire, Rock, Steel | |
Normal Fighting | |
Poison Fairy, Grass Ground, Psychic | |
Psychic Fighting, Poison Bug, Dark, Ghost | |
Rock Bug, Fire, Flying, Ice Fighting, Grass, Ground, Steel, Water | |
Steel Fairy, Ice, Rock Fighting, Fire, Ground | |
Water Fire, Ground, Rock Electric, Grass''' | |
def types_from_col(col): | |
types = col.replace(' ', '') | |
types = types.split(',') | |
types = [t for t in types if t != ''] | |
return set(types) | |
type_source = type_source.strip() | |
table = {} | |
for row in type_source.split('\n'): | |
t, sup, wek = row.split('\t') | |
sup = types_from_col(sup) | |
wek = types_from_col(wek) | |
table[t] = {'+':sup, '-':wek} | |
trios = set() | |
for t0 in table.keys(): | |
for t1 in table[t0]['+']: | |
for t2 in table[t1]['+']: | |
if t2 in table[t0]['-']: | |
s = frozenset((t0, t1, t2)) | |
if len(s) == 3: | |
trios.add(s) | |
for trio in trios: | |
print(' '.join([t for t in trio])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment