Skip to content

Instantly share code, notes, and snippets.

@phenomist
Created August 16, 2016 02:19
Show Gist options
  • Save phenomist/694d5f3214990771bd52d1bd2c9ab475 to your computer and use it in GitHub Desktop.
Save phenomist/694d5f3214990771bd52d1bd2c9ab475 to your computer and use it in GitHub Desktop.
Composes stats for the game Elemental 3. Requires @-formatted CSV.
import string
import operator
printable = set(string.printable)
f = open("5020.neat.csv", "rt", encoding='utf8')
g = open("elem3stats.txt", "w", encoding='utf8')
ff = f.read()
st = [i.split("@") for i in ff.split('\n')][0:4997]
def colors():
cdict = {"Air": "Sky", "Earth": "Brown", "Fire": "Orange", "Water": "Blue"}
for e in st:
cdict[e[1]] = e[2]
return cdict
def complexity():
cdict = {"Air": 0, "Earth": 0, "Fire": 0, "Water": 0}
for e in st:
if e[3] == e[5]:
cdict[e[1]] = cdict[e[3]]+1
else:
cdict[e[1]] = cdict[e[3]]+cdict[e[5]]+1
return cdict
def generation():
cdict = {"Air": 0, "Earth": 0, "Fire": 0, "Water": 0}
for e in st:
cdict[e[1]] = max(cdict[e[3]],cdict[e[5]])+1
return cdict
def constituents():
cdict = {"Air": [1,0,0,0], "Earth": [0,1,0,0], "Fire": [0,0,1,0], "Water": [0,0,0,1]}
for e in st:
cdict[e[1]] = [cdict[e[3]][i]+cdict[e[5]][i] for i in range(4)]
return cdict
def unique():
udict = {"Air": set(["Air"]), "Earth": set(["Earth"]), "Fire": set(["Fire"]), "Water": set(["Water"])}
for e in st:
udict[e[1]] = udict[e[3]] | udict[e[5]] | set([e[1]])
return udict
coldict = colors()
cmpdict = complexity()
gendict = generation()
condict = constituents()
unqdict = unique()
uqldict = dict([[i, len(unqdict[i])] for i in unqdict])
for e in st:
g.write(e[0]+'\t'+e[1]+'\t'+e[2]+'\t'+
e[4]+'\t'+e[3]+'\t'+coldict[e[3]]+'\t'+
e[6]+'\t'+e[5]+'\t'+coldict[e[5]]+'\t'+
str(cmpdict[e[1]])+'\t'+str(gendict[e[1]])+'\t'+str(uqldict[e[1]])+'\t'+
str(condict[e[1]][0])+'\t'+str(condict[e[1]][1])+'\t'+
str(condict[e[1]][2])+'\t'+str(condict[e[1]][3])+'\t'+str(sum(condict[e[1]]))+
'\n')
f.close()
g.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment