Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. import os
  2.  
  3. replaypath = 'C:/Program Files (x86)/Steam/steamapps/common/Crypt of the NecroDancer/replays'
  4.  
  5. # Store first floor replay data to remove duplicates
  6. firstfloors = set()
  7.  
  8. # Death counts from 1-1 to 4-4
  9. deaths = [0]*16
  10.  
  11. for filename in os.listdir(replaypath):
  12.   namesplits = filename.split('_')
  13.   if int(namesplits[0]) <= 75 and namesplits[9][0] == '6': # If Pre-DLC All Zones
  14.     file = open(replaypath + '/' + filename, 'r')
  15.     lines = file.read().split('\\n')
  16.     file.close()
  17.  
  18.     if lines[15][0] == '7' and int(lines[11]) == 1: # If solo Coda
  19.       firstfloor = lines[10] + lines[15] # Seed + Play data
  20.       if firstfloor in firstfloors: continue # Filter out duplicate replays
  21.       firstfloors.add(firstfloor)
  22.  
  23.       # Manually count number of songs played. lines[9] isn't reliable due to the stacking replay bug
  24.       seedindex = 10
  25.       prevseed = int(lines[seedindex])
  26.       numsongs = 1
  27.  
  28.       seedindex += 11
  29.       while lines[seedindex]:
  30.         seed = int(lines[seedindex])
  31.         if seed - prevseed not in [1, 2]: break # Stacking replay bug
  32.         prevseed = seed
  33.         numsongs += 1
  34.         seedindex += 11
  35.  
  36.       deaths[numsongs - 1] += 1
  37.  
  38. total = sum(deaths)
  39.  
  40. print 'Total runs: %d' % total
  41. print
  42.  
  43. def percent(n, d):
  44.   if d != 0:
  45.     return '%.1f%%' % (100. * n / d)
  46.   else:
  47.     return 'N/A'
  48.  
  49. for i in range(16):
  50.   zone = i / 4 + 1
  51.   floor = i % 4 + 1
  52.   visits = sum(deaths[i:])
  53.   survives = sum(deaths[i+1:])
  54.   print 'Deaths in %d-%d: %d\tVisited: %s\tSurvived: %s' % (zone, floor, deaths[i], percent(visits, total), percent(survives, visits))
  55.  
  56. print
  57.  
  58. for i in range(4):
  59.   zone = i + 1
  60.   zonedeaths = sum(deaths[i * 4:][:4])
  61.   visits = sum(deaths[i * 4:])
  62.   survives = sum(deaths[(i + 1) * 4:])
  63.   print 'Deaths in Zone %d: %d\tVisited: %s\t Survived: %s' % (zone, zonedeaths, percent(visits, total), percent(survives, visits))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement