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
#!/usr/bin/python import sys from common import readTable old,nold = readTable(sys.argv[1]) new,nnew = readTable(sys.argv[2]) diff = {} for poke in new.keys(): if poke not in old.keys(): old[poke]=0.0 diff[poke]=new[poke]-old[poke] pokes=[] for i in diff.keys(): pokes.append([i,diff[i]]) pokes=sorted(pokes, key=lambda pokes:-pokes[1]) if (nold != nnew): if (nold < nnew): printme = " Up %5.2f%%" % (100*float(nnew-nold)/nold) else: printme = " Down %5.2f%%" % (100*float(nold-nnew)/nold) print printme print " + ------------------ + --------- + " print " | Pokemon | Diff (%) | " print " + ------------------ + --------- + " for i in range(0,len(pokes)): if abs(pokes[i][1]) > 0.001:
specs += '{:.0f}'.format(cutoff) file = open('Raw/moveset/'+str(sys.argv[1])+'/teammate'+specs+'.pickle') teammateMatrix = pickle.load(file) file.close() file = open('Raw/moveset/'+str(sys.argv[1])+'/encounterMatrix'+specs+'.pickle') encounterMatrix = pickle.load(file) file.close() filename = 'Stats/'+str(sys.argv[1])+specs+'.txt' file = open(filename) table=file.readlines() file.close() usage,nBattles = readTable('Stats/'+str(sys.argv[1])+specs+'.txt') pokes = [] for poke in usage.keys(): pokes.append([poke,usage[poke]]) if sys.argv[1] in ['randombattle','challengecup','challengecup1v1','seasonal']: pokes=sorted(pokes) else: pokes=sorted(pokes, key=lambda pokes:-pokes[1]) chaos = {'info': {'metagame': str(sys.argv[1]), 'cutoff': cutoff, 'cutoff deviation': cutoffdeviation, 'team type': teamtype, 'number of battles': nBattles},'data':{}} for poke in pokes: if poke[1] < 0.0001: #1/100th of a percent break stuff = movesetCounter('Raw/moveset/'+str(sys.argv[1])+'/'+keyify(poke[0]),cutoff,teamtype,usage) stuff['usage']=poke[1]
def main(months): file = open('keylookup.pickle') keyLookup = pickle.load(file) file.close() rise = [0.06696700846,0.04515839608,0.03406367107][len(months)-1] drop = [0.01717940145,0.02284003156,0.03406367107][len(months)-1] formatsData = getBattleFormatsData() curTiers = {} NFE=[] for poke in formatsData: if poke in ['pichuspikyeared', 'unownb', 'unownc', 'unownd', 'unowne', 'unownf', 'unowng', 'unownh', 'unowni', 'unownj', 'unownk', 'unownl', 'unownm', 'unownn', 'unowno', 'unownp', 'unownq', 'unownr', 'unowns', 'unownt', 'unownu', 'unownv', 'unownw', 'unownx', 'unowny', 'unownz', 'unownem', 'unownqm', 'burmysandy', 'burmytrash', 'cherrimsunshine', 'shelloseast', 'gastrodoneast', 'deerlingsummer', 'deerlingautumn', 'deerlingwinter', 'sawsbucksummer', 'sawsbuckautumn', 'sawsbuckwinter', 'keldeoresolution', 'genesectdouse', 'genesectburn', 'genesectshock', 'genesectchill', 'basculinbluestriped', 'darmanitanzen','keldeoresolute','pikachucosplay']: continue if 'isNonstandard' in formatsData[poke]: if formatsData[poke]['isNonstandard']: continue #if 'requiredItem' in formatsData[poke]: # continue #if poke == 'rayquazamega': # continue if 'tier' not in formatsData[poke].keys(): continue old = formatsData[poke]['tier'] if old[0] == '(': old = old[1:-1] if old in ['NFE','LC']: NFE.append(poke) if old == 'Illegal' or old == 'Unreleased': continue elif old not in tiers: old = 'PU' curTiers[poke]=old usage = {} #track usage across all relevant tiers [OU,UU,RU,NU] remaining=24.0 for i in xrange(len(months)): weight = remaining if i + 1 < len(months): if i == 0: weight = 20.0 if i == 1: weight = 3.0 remaining -= weight usageTiers = ['ou','uu','ru','nu','pu'] for j in xrange(len(usageTiers)): nRegular = nSuspect = 0 baseline = "1630" if usageTiers[j] in ['ou']: baseline = "1695" try: usageRegular, nRegular = readTable(months[i]+"/Stats/"+usageTiers[j]+"-"+baseline+".txt") except IOError: pass try: usageSuspect, nSuspect = readTable(months[i]+"/Stats/"+usageTiers[j]+"suspecttest-"+baseline+".txt") except IOError: pass if nRegular > 0: for poke in usageRegular: if keyify(poke) not in usage: usage[keyify(poke)]=[0]*len(usageTiers) if poke != 'empty': usage[keyify(poke)][j] += weight*nRegular/(nRegular+nSuspect)*usageRegular[poke]/24 if nSuspect > 0: for poke in usageSuspect: if keyify(poke) not in usage: usage[keyify(poke)]=[0]*len(usageTiers) if poke != 'empty': usage[keyify(poke)][j] += weight*nSuspect/(nRegular+nSuspect)*usageSuspect[poke]/24 #generate three-month tables and start working on that new tier list OU = [] UU = [] RU = [] NU = [] PU = [] 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]]) if usage[i][2] > 0.0: RU.append([i,usage[i][2]]) if usage[i][3] > 0.0: NU.append([i,usage[i][3]]) if usage[i][4] > 0.0: PU.append([i,usage[i][4]]) OU = sorted(OU, key=lambda OU:-OU[1]) UU = sorted(UU, key=lambda UU:-UU[1]) RU = sorted(RU, key=lambda RU:-RU[1]) NU = sorted(NU, key=lambda NU:-NU[1]) PU = sorted(PU, key=lambda PU:-PU[1]) makeTable(OU,"OU",keyLookup) makeTable(UU,"UU",keyLookup) makeTable(RU,"RU",keyLookup) makeTable(NU,"NU",keyLookup) newTiers={} #start with Ubers for poke in curTiers.keys(): if curTiers[poke] == 'Uber': newTiers[poke] = 'Uber' #next do the OU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][0] > rise and poke not in newTiers.keys(): newTiers[poke] = 'OU' #next do the UU drops for poke in curTiers.keys(): if curTiers[poke] == 'OU' and poke not in newTiers.keys(): if usage[poke][0] < drop: newTiers[poke] = 'UU' else: newTiers[poke] = 'OU' #next do BL for poke in curTiers.keys(): if curTiers[poke] == 'BL' and poke not in newTiers.keys(): newTiers[poke] = 'BL' #next do the UU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][1] > rise and poke not in newTiers.keys(): newTiers[poke] = 'UU' #next do the RU drops for poke in curTiers.keys(): if curTiers[poke] == 'UU' and poke not in newTiers.keys(): if usage[poke][1] < drop: newTiers[poke] = 'RU' else: newTiers[poke] = 'UU' #next do BL2 for poke in curTiers.keys(): if curTiers[poke] == 'BL2' and poke not in newTiers.keys(): newTiers[poke] = 'BL2' #next do the RU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][2] > rise and poke not in newTiers.keys(): newTiers[poke] = 'RU' #next do the NU drops for poke in curTiers.keys(): if curTiers[poke] == 'RU' and poke not in newTiers.keys(): if usage[poke][2] < drop: newTiers[poke] = 'NU' else: newTiers[poke] = 'RU' #next do BL3 for poke in curTiers.keys(): if curTiers[poke] == 'BL3' and poke not in newTiers.keys(): newTiers[poke] = 'BL3' #next do the NU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][3] > rise and poke not in newTiers.keys(): newTiers[poke] = 'NU' #next do the PU drops for poke in curTiers.keys(): if curTiers[poke] == 'NU' and poke not in newTiers.keys(): if usage[poke][3] < drop: newTiers[poke] = 'PU' else: newTiers[poke] = 'NU' #next do BL4 for poke in curTiers.keys(): if curTiers[poke] == 'BL4' and poke not in newTiers.keys(): newTiers[poke] = 'BL4' #the rest are PU for poke in curTiers.keys(): if poke not in newTiers.keys(): newTiers[poke] = 'PU' print "" for poke in curTiers: if curTiers[poke] != newTiers[poke]: species = keyLookup[poke] if species.endswith('-Mega') or species.endswith('-Mega-X') or species.endswith('-Mega-Y') or species.endswith('-Primal'): base = keyify(species[:species.index('-')]) #none of the megas have hyphenated names if tiers.index(newTiers[base]) < tiers.index(newTiers[poke]): #if the base is in a higher tier newTiers[poke] = newTiers[base] continue print species+" moved from "+curTiers[poke]+" to "+newTiers[poke] print "" print "" print "[size=5][b]FU[/b][/size]" print "FU is an unofficial tier. It is not currently supported on any simulator, but since [url=http://www.smogon.com/forums/forums/pu.327/?prefix_id=282]people have expressed interest in such a metagame[/url], here is a proper banlist:" makeTable(PU,"PU",keyLookup) fuBanlist = [] for poke in usage.keys(): if poke in curTiers: if newTiers[poke] == 'PU' and (usage[poke][4] >= drop or curTiers[poke] == 'NU'): fuBanlist.append(poke) fuBanlist = sorted(fuBanlist) printme = "[b]Banlist:[/b] " for poke in fuBanlist: printme += keyLookup[poke]+', ' printme = printme[:-2] print printme
def main(months): file = open('baseStats.json') baseStats = json.loads(file.readline()) file.close() validPokemon=baseStats.keys() formats = json.load(open('formats.json')) banlists={} for format in ('lc','lcuu','doublesou', 'doublesuu'): banlist=[] for entry in formats[format]['banlist']: keyified=keyify(entry) if keyified in validPokemon: banlist.append(keyified) banlists[formats[format]['name']]=banlist curTiers= {} curTiers['LC']={} curTiers['Doubles']={} for poke in banlists['LC']: curTiers['LC'][poke]='Uber' for poke in banlists['LC UU']: if poke not in curTiers['LC'].keys(): curTiers['LC'][poke]='OU' for poke in banlists['Doubles OU']: curTiers['Doubles'][poke]='Uber' for poke in banlists['Doubles UU']: if poke not in curTiers['Doubles'].keys(): curTiers['Doubles'][poke]='OU' rise = [0.06696700846,0.04515839608,0.03406367107][len(months)-1] drop = [0.01717940145,0.02284003156,0.03406367107][len(months)-1] usageLC = {} usageDoubles = {} remaining=24.0 for i in xrange(len(months)): weight = remaining if i + 1 < len(months): if i == 0: weight = 20.0 if i == 1: weight = 3.0 remaining -= weight nRegular = nSuspect = 0 try: usageRegular, nRegular = readTable(months[i]+"/Stats/lc-1630.txt") except IOError: pass try: usageSuspect, nSuspect = readTable(months[i]+"/Stats/lcsuspecttest-1630.txt") except IOError: pass if nRegular > 0: for poke in usageRegular: if keyify(poke) not in usageLC: usageLC[keyify(poke)]=[0,0] if poke != 'empty': usageLC[keyify(poke)][0] += weight*nRegular/(nRegular+nSuspect)*usageRegular[poke]/24 if nSuspect > 0: for poke in usageSuspect: if keyify(poke) not in usageLC: usageLC[keyify(poke)]=[0,0] if poke != 'empty': usageLC[keyify(poke)][0] += weight*nSuspect/(nRegular+nSuspect)*usageSuspect[poke]/24 usageTiers = ['doublesou','doublesuu'] for j in xrange(len(usageTiers)): nRegular = nSuspect = 0 baseline = "1630" if usageTiers[j] in ['doublesou']: baseline = "1695" try: usageRegular, nRegular = readTable(months[i]+"/Stats/"+usageTiers[j]+"-"+baseline+".txt") except IOError: pass try: usageSuspect, nSuspect = readTable(months[i]+"/Stats/"+usageTiers[j]+"suspecttest-"+baseline+".txt") except IOError: pass if nRegular > 0: for poke in usageRegular: if keyify(poke) not in usageDoubles: usageDoubles[keyify(poke)]=[0]*len(usageTiers) if poke != 'empty': usageDoubles[keyify(poke)][j] += weight*nRegular/(nRegular+nSuspect)*usageRegular[poke]/24 if nSuspect > 0: for poke in usageSuspect: if keyify(poke) not in usageDoubles: usageDoubles[keyify(poke)]=[0]*len(usageTiers) if poke != 'empty': usageDoubles[keyify(poke)][j] += weight*nSuspect/(nRegular+nSuspect)*usageSuspect[poke]/24 #generate three-month tables and start working on that new tier list newTiers={} print "[size=5][b]Little Cup[/b][/size]" (LCOU,LCUU) = usageToTiers(usageLC) makeTable(LCOU,"LC OU",keyLookup) #makeTable(LCUU,"LC UU",keyLookup) newTiers['LC']=raiseAndDrop(curTiers['LC'],usageLC,'UU',rise,drop) print "" for poke in curTiers['LC']: if curTiers['LC'][poke] != newTiers['LC'][poke]: if newTiers['LC'][poke] != 'NU': print keyLookup[poke]+" moved from LC "+curTiers['LC'][poke]+" to LC "+newTiers['LC'][poke] print "" print "" print "[size=5][b]Doubles[/b][/size]" (doublesOU,doublesUU) = usageToTiers(usageDoubles) makeTable(doublesOU,"Doubles OU",keyLookup) newTiers['Doubles']=raiseAndDrop(curTiers['Doubles'],usageDoubles,'UU',rise,drop) print "" newUU = [] for poke in curTiers['Doubles']: if curTiers['Doubles'][poke] != newTiers['Doubles'][poke]: species = keyLookup[poke] if species.endswith('-Mega') or species.endswith('-Mega-X') or species.endswith('-Mega-Y') or species.endswith('-Primal'): base = keyify(species[:species.index('-')]) #none of the megas have hyphenated names if tiers.index(newTiers['Doubles'][base]) < tiers.index(newTiers['Doubles'][poke]): #if the base is in a higher tier newTiers['Doubles'][poke] = newTiers['Doubles'][base] continue if newTiers['Doubles'][poke] != 'NU': print keyLookup[poke]+" moved from Doubles "+curTiers['Doubles'][poke]+" to Doubles "+newTiers['Doubles'][poke] print "" print "" print "[size=5][b]Doubles NU[/b][/size]" print "Doubles NU is an unofficial metagame that's apparently so unpopular there's not even enough interest to support a challenge-only format. Still, it's conceivable that someone will want to play it, and that person should have an unofficial banlist to refer to. So..." makeTable(doublesUU,"Doubles UU",keyLookup) dnuBanlist = [] for poke in usageDoubles.keys(): if poke in curTiers['Doubles']: if newTiers['Doubles'][poke] == 'UU' and (usageDoubles[poke][1] >= drop or curTiers['Doubles'][poke] == 'OU'): dnuBanlist.append(poke) dnuBanlist = sorted(dnuBanlist) printme = "[b]Banlist:[/b] " for poke in dnuBanlist: printme += keyLookup[poke]+', ' printme = printme[:-2] print printme
file = open('Raw/moveset/' + str(sys.argv[1]) + '/teammate' + specs + '.pickle') teammateMatrix = pickle.load(file) file.close() file = open('Raw/moveset/' + str(sys.argv[1]) + '/encounterMatrix' + specs + '.pickle') encounterMatrix = pickle.load(file) file.close() filename = 'Stats/' + str(sys.argv[1]) + specs + '.txt' file = open(filename) table = file.readlines() file.close() usage, nBattles = readTable('Stats/' + str(sys.argv[1]) + specs + '.txt') pokes = [] for poke in usage.keys(): pokes.append([poke, usage[poke]]) if sys.argv[1] in [ 'randombattle', 'challengecup', 'challengecup1v1', 'seasonal' ]: pokes = sorted(pokes) else: pokes = sorted(pokes, key=lambda pokes: -pokes[1]) chaos = { 'info': { 'metagame': str(sys.argv[1]), 'cutoff': cutoff,
#!/usr/bin/python import sys from common import readTable old, nold = readTable(sys.argv[1]) new, nnew = readTable(sys.argv[2]) diff = {} for poke in new.keys(): if poke not in old.keys(): old[poke] = 0.0 diff[poke] = new[poke] - old[poke] pokes = [] for i in diff.keys(): pokes.append([i, diff[i]]) pokes = sorted(pokes, key=lambda pokes: -pokes[1]) if nold != nnew: if nold < nnew: printme = " Up %5.2f%%" % (100 * float(nnew - nold) / nold) else: printme = " Down %5.2f%%" % (100 * float(nold - nnew) / nold) print printme print " + ------------------ + --------- + " print " | Pokemon | Diff (%) | " print " + ------------------ + --------- + " for i in range(0, len(pokes)): if abs(pokes[i][1]) > 0.001:
def main(months): file = open('keylookup.pickle') keyLookup = pickle.load(file) file.close() rise = [0.06696700846,0.04515839608,0.03406367107][len(months)-1] drop = [0.01717940145,0.02284003156,0.03406367107][len(months)-1] formatsData = getBattleFormatsData() curTiers = {} NFE=[] for poke in formatsData: if poke in ['pichuspikyeared', 'unownb', 'unownc', 'unownd', 'unowne', 'unownf', 'unowng', 'unownh', 'unowni', 'unownj', 'unownk', 'unownl', 'unownm', 'unownn', 'unowno', 'unownp', 'unownq', 'unownr', 'unowns', 'unownt', 'unownu', 'unownv', 'unownw', 'unownx', 'unowny', 'unownz', 'unownem', 'unownqm', 'burmysandy', 'burmytrash', 'cherrimsunshine', 'shelloseast', 'gastrodoneast', 'deerlingsummer', 'deerlingautumn', 'deerlingwinter', 'sawsbucksummer', 'sawsbuckautumn', 'sawsbuckwinter', 'keldeoresolution', 'genesectdouse', 'genesectburn', 'genesectshock', 'genesectchill', 'basculinbluestriped', 'darmanitanzen','keldeoresolute','pikachucosplay']: continue if 'isNonstandard' in formatsData[poke]: if formatsData[poke]['isNonstandard']: continue #if 'requiredItem' in formatsData[poke]: # continue #if poke == 'rayquazamega': # continue if 'tier' not in formatsData[poke].keys(): continue old = formatsData[poke]['tier'] if old[0] == '(': old = old[1:-1] if old in ['NFE','LC']: NFE.append(poke) if old == 'Illegal' or old == 'Unreleased': continue elif old not in tiers: old = tiers[-1] curTiers[poke]=old usage = {} #track usage across all relevant tiers [OU,UU,RU,NU] remaining=24.0 for i in xrange(len(months)): weight = remaining if i + 1 < len(months): if i == 0: weight = 20.0 if i == 1: weight = 3.0 remaining -= weight for j in xrange(len(usageTiers)): n = {} u = {} baseline = "1630" if usageTiers[j] in ['ou']: baseline = "1695" for k in ('', 'suspecttest', 'alpha', 'beta'): try: u[k], n[k] = readTable(months[i]+"/Stats/gen7"+usageTiers[j]+k+"-"+baseline+".txt") except IOError: pass ntot = sum(n.values()) for k in u: for poke in u[k]: if keyify(poke) not in usage: usage[keyify(poke)]=[0]*len(usageTiers) if poke != 'empty': usage[keyify(poke)][j] += weight*n[k]/ntot*u[k][poke]/24 #generate three-month tables and start working on that new tier list OU = [] UU = [] RU = [] ''' NU = [] PU = [] ''' 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]]) if usage[i][2] > 0.0: RU.append([i,usage[i][2]]) ''' if usage[i][3] > 0.0: NU.append([i,usage[i][3]]) if usage[i][4] > 0.0: PU.append([i,usage[i][4]]) ''' OU = sorted(OU, key=lambda OU:-OU[1]) UU = sorted(UU, key=lambda UU:-UU[1]) RU = sorted(RU, key=lambda RU:-RU[1]) ''' NU = sorted(NU, key=lambda NU:-NU[1]) PU = sorted(PU, key=lambda PU:-PU[1]) ''' makeTable(OU,"OU",keyLookup) makeTable(UU,"UU",keyLookup) makeTable(RU,"RU",keyLookup) ''' makeTable(NU,"NU",keyLookup) ''' newTiers={} #start with Ubers for poke in curTiers.keys(): if curTiers[poke] == 'Uber': newTiers[poke] = 'Uber' for poke in curTiers.keys(): if poke not in usage: newTiers[poke] = curTiers[poke] #next do the OU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][0] > rise and poke not in newTiers.keys(): newTiers[poke] = 'OU' #next do the UU drops for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'OU' and poke not in newTiers.keys(): if usage[poke][0] < drop: newTiers[poke] = 'UU' else: newTiers[poke] = 'OU' #next do BL for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'BL' and poke not in newTiers.keys(): newTiers[poke] = 'BL' #next do the UU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][1] > rise and poke not in newTiers.keys(): newTiers[poke] = 'UU' #next do the RU drops for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'UU' and poke not in newTiers.keys(): if usage[poke][1] < drop: newTiers[poke] = 'RU' else: newTiers[poke] = 'UU' #next do BL2 for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'BL2' and poke not in newTiers.keys(): newTiers[poke] = 'BL2' #next do the RU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][2] > rise and poke not in newTiers.keys(): newTiers[poke] = 'RU' #next do the NU drops for poke in curTiers.keys(): if curTiers[poke] == 'RU' and poke not in newTiers.keys(): if usage[poke][2] < drop: newTiers[poke] = 'NU' else: newTiers[poke] = 'RU' #next do BL3 for poke in curTiers.keys(): if curTiers[poke] == 'BL3' and poke not in newTiers.keys(): newTiers[poke] = 'BL3' ''' #next do the NU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][3] > rise and poke not in newTiers.keys(): newTiers[poke] = 'NU' #next do the PU drops for poke in curTiers.keys(): if curTiers[poke] == 'NU' and poke not in newTiers.keys(): if usage[poke][3] < drop: newTiers[poke] = 'PU' else: newTiers[poke] = 'NU' #next do BL4 for poke in curTiers.keys(): if curTiers[poke] == 'BL4' and poke not in newTiers.keys(): newTiers[poke] = 'BL4' ''' #the rest go in the lowest tier for poke in curTiers.keys(): if poke not in newTiers.keys(): newTiers[poke] = tiers[-1] print "" for poke in curTiers: if curTiers[poke] != newTiers[poke]: species = keyLookup[poke] if species.endswith('-Mega') or species.endswith('-Mega-X') or species.endswith('-Mega-Y') or species.endswith('-Primal'): base = keyify(species[:species.index('-')]) #none of the megas have hyphenated names if tiers.index(newTiers[base]) < tiers.index(newTiers[poke]): #if the base is in a higher tier newTiers[poke] = newTiers[base] continue print species+" moved from "+curTiers[poke]+" to "+newTiers[poke]
def main(months): file = open('keylookup.pickle') keyLookup = pickle.load(file) file.close() rise = [0.06696700846,0.04515839608,0.03406367107][len(months)-1] drop = [0.01717940145,0.02284003156,0.03406367107][len(months)-1] formatsData = getBattleFormatsData() curTiers = {} NFE=[] for poke in formatsData: if poke in ['pichuspikyeared', 'unownb', 'unownc', 'unownd', 'unowne', 'unownf', 'unowng', 'unownh', 'unowni', 'unownj', 'unownk', 'unownl', 'unownm', 'unownn', 'unowno', 'unownp', 'unownq', 'unownr', 'unowns', 'unownt', 'unownu', 'unownv', 'unownw', 'unownx', 'unowny', 'unownz', 'unownem', 'unownqm', 'burmysandy', 'burmytrash', 'cherrimsunshine', 'shelloseast', 'gastrodoneast', 'deerlingsummer', 'deerlingautumn', 'deerlingwinter', 'sawsbucksummer', 'sawsbuckautumn', 'sawsbuckwinter', 'keldeoresolution', 'genesectdouse', 'genesectburn', 'genesectshock', 'genesectchill', 'basculinbluestriped', 'darmanitanzen','keldeoresolute','pikachucosplay']: continue if 'isNonstandard' in formatsData[poke]: if formatsData[poke]['isNonstandard']: continue #if 'requiredItem' in formatsData[poke]: # continue #if poke == 'rayquazamega': # continue if 'tier' not in formatsData[poke].keys(): continue old = formatsData[poke]['tier'] if old[0] == '(': old = old[1:-1] if old in ['NFE','LC']: NFE.append(poke) if old == 'Illegal' or old == 'Unreleased': continue elif old not in tiers: old = tiers[-1] curTiers[poke]=old usage = {} #track usage across all relevant tiers [OU,UU,RU,NU] remaining=24.0 for i in xrange(len(months)): weight = remaining if i + 1 < len(months): if i == 0: weight = 20.0 if i == 1: weight = 3.0 remaining -= weight for j in xrange(len(usageTiers)): n = {} u = {} baseline = "1630" if usageTiers[j] in ['ou']: baseline = "1695" for k in ('', 'suspecttest', 'alpha', 'beta'): try: u[k], n[k] = readTable(months[i]+"/Stats/gen7"+usageTiers[j]+k+"-"+baseline+".txt") except IOError: pass ntot = sum(n.values()) for k in u: for poke in u[k]: if keyify(poke) not in usage: usage[keyify(poke)]=[0]*len(usageTiers) if poke != 'empty': usage[keyify(poke)][j] += weight*n[k]/ntot*u[k][poke]/24 #generate three-month tables and start working on that new tier list OU = [] UU = [] RU = [] NU = [] PU = [] 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]]) if usage[i][2] > 0.0: RU.append([i,usage[i][2]]) if usage[i][3] > 0.0: NU.append([i,usage[i][3]]) if usage[i][4] > 0.0: PU.append([i,usage[i][4]]) OU = sorted(OU, key=lambda OU:-OU[1]) UU = sorted(UU, key=lambda UU:-UU[1]) RU = sorted(RU, key=lambda RU:-RU[1]) NU = sorted(NU, key=lambda NU:-NU[1]) PU = sorted(PU, key=lambda PU:-PU[1]) makeTable(OU,"OU",keyLookup) makeTable(UU,"UU",keyLookup) makeTable(RU,"RU",keyLookup) makeTable(NU,"NU",keyLookup) makeTable(PU,"PU",keyLookup) newTiers={} #start with Ubers for poke in curTiers.keys(): if curTiers[poke] == 'Uber': newTiers[poke] = 'Uber' for poke in curTiers.keys(): if poke not in usage: newTiers[poke] = curTiers[poke] #next do the OU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][0] > rise and poke not in newTiers.keys(): newTiers[poke] = 'OU' #next do the UU drops for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'OU' and poke not in newTiers.keys(): if usage[poke][0] < drop: newTiers[poke] = 'UU' else: newTiers[poke] = 'OU' #next do BL for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'BL' and poke not in newTiers.keys(): newTiers[poke] = 'BL' #next do the UU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][1] > rise and poke not in newTiers.keys(): newTiers[poke] = 'UU' #next do the RU drops for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'UU' and poke not in newTiers.keys(): if usage[poke][1] < drop: newTiers[poke] = 'RU' else: newTiers[poke] = 'UU' #next do BL2 for poke in curTiers.keys(): if poke not in usage: continue if curTiers[poke] == 'BL2' and poke not in newTiers.keys(): newTiers[poke] = 'BL2' #next do the RU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][2] > rise and poke not in newTiers.keys(): newTiers[poke] = 'RU' #next do the NU drops for poke in curTiers.keys(): if curTiers[poke] == 'RU' and poke not in newTiers.keys(): if usage[poke][2] < drop: newTiers[poke] = 'NU' else: newTiers[poke] = 'RU' #next do BL3 for poke in curTiers.keys(): if curTiers[poke] == 'BL3' and poke not in newTiers.keys(): newTiers[poke] = 'BL3' #next do the NU rises for poke in curTiers.keys(): if poke not in usage: continue if usage[poke][3] > rise and poke not in newTiers.keys(): newTiers[poke] = 'NU' #next do the PU drops for poke in curTiers.keys(): if curTiers[poke] == 'NU' and poke not in newTiers.keys(): if usage[poke][3] < drop: newTiers[poke] = 'PU' else: newTiers[poke] = 'NU' #next do BL4 for poke in curTiers.keys(): if curTiers[poke] == 'BL4' and poke not in newTiers.keys(): newTiers[poke] = 'BL4' #the rest go in the lowest tier for poke in curTiers.keys(): if poke not in newTiers.keys(): newTiers[poke] = tiers[-1] print "" for poke in curTiers: if curTiers[poke] != newTiers[poke]: species = keyLookup[poke] if species.endswith('-Mega') or species.endswith('-Mega-X') or species.endswith('-Mega-Y') or species.endswith('-Primal'): base = keyify(species[:species.index('-')]) #none of the megas have hyphenated names if tiers.index(newTiers[base]) < tiers.index(newTiers[poke]): #if the base is in a higher tier newTiers[poke] = newTiers[base] continue print species+" moved from "+curTiers[poke]+" to "+newTiers[poke]