-
Notifications
You must be signed in to change notification settings - Fork 3
/
TierUpdate9LC.py
107 lines (84 loc) · 2.75 KB
/
TierUpdate9LC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import string
import sys
import json
import cPickle as pickle
from common import keyify,readTable,getBattleFormatsData
reload(sys)
sys.setdefaultencoding('utf8')
def getUsage(filename,col,weight,usage):
tempUsage, nBattles = readTable(filename)
for i in tempUsage:
if keyify(i) not in usage:
usage[keyify(i)]=[0,0,0,0,0]
if i != 'empty':
usage[keyify(i)][col] = usage[keyify(i)][col]+weight*6.0*tempUsage[i]/sum(tempUsage.values())/24
def usageToTiers(usage):
OU = []
UU = []
for i in usage:
if usage[i][0] > 0.0:
OU.append([i,usage[i][0]])
if usage[i][1] > 0.0:
UU.append([i,usage[i][1]])
OU = sorted(OU, key=lambda OU:-OU[1])
UU = sorted(UU, key=lambda UU:-UU[1])
return (OU,UU)
def makeTable(table,name,keyLookup):
print "[HIDE="+name+"][CODE]"
print "Combined usage for "+name
print " + ---- + ------------------ + ------- + "
print " | Rank | Pokemon | Percent | "
print " + ---- + ------------------ + ------- + "
print ' | %-4d | %-18s | %6.3f%% |' % (1,keyLookup[table[0][0]],table[0][1]*100)
for i in range(1,len(table)):
if table[i][1] < 0.001:
break
print ' | %-4d | %-18s | %6.3f%% |' % (i+1,keyLookup[table[i][0]],100.0*table[i][1])
print " + ---- + ------------------ + ------- + "
print "[/CODE][/HIDE]"
def main(months):
file = open('keylookup.json', 'rb')
keyLookup = json.load(file)
file.close()
rise = [0.99999999999,0.99515839608,0.04515839608][len(months)-1]
drop = [0.01528524706,0.02284003156,0.04515839608][len(months)-1]
rise = [0.04515839608,0.04515839608,0.04515839608][len(months)-1]
#rise = [0.99515839608,0.99515839608,0.99515839608][len(months)-1]
drop = [0.04515839608,0.04515839608,0.04515839608][len(months)-1]
#drop = [0.02,0.02284003156,0.04515839608][len(months)-1]
formatsData = getBattleFormatsData()
usageBH = {}
remaining=24.0
for i in xrange(len(months)):
tiername = 'lc'
#bh
n = {}
u = {}
baseline = "1630"
for k in ('', 'suspecttest', 'alpha', 'beta'):
try:
u[k], n[k] = readTable(months[i]+"/Stats/gen9"+tiername+k+"-"+baseline+".txt")
except IOError:
pass
ntot = sum(n.values())
for k in u:
for poke in u[k]:
if keyify(poke) not in usageBH:
usageBH[keyify(poke)]=[0,0]
if poke != 'empty':
usageBH[keyify(poke)][0] += n[k]/ntot*u[k][poke]/len(months)
#generate three-month tables and start working on that new tier list
(BHOU,BHUU) = usageToTiers(usageBH)
makeTable(BHOU,"LC (1630 stats)",keyLookup)
dnuBanlist = []
for poke in usageBH.keys():
if usageBH[poke][0] >= drop:
dnuBanlist.append(poke)
dnuBanlist = sorted(dnuBanlist)
printme = "[b]LC UU Banlist:[/b] "
for poke in dnuBanlist:
printme += keyLookup[poke]+', '
printme = printme[:-2]
print printme
if __name__ == "__main__":
main(sys.argv[1:])