Advertisement
Hydreigon_Lord

ROFC Simulation Program

Aug 14th, 2016
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.99 KB | None | 0 0
  1. import random
  2. import time
  3. SIMS=1000000 # Number of simulations to run
  4. MINSCORE=0 # Lower cap of event scores
  5. MAXSCORE=20000 # Upper cap of event scores
  6. AVGSCORE=10000 # Average event score
  7. STDEV=2000 # Standard deviation of event scores
  8. CONTS=12 # Number of contestants
  9. top_1=list()
  10. top_3=list()
  11. top_5=list()
  12. fails=list()
  13. for i in range(CONTS):
  14.     top_1.append(0)
  15.     top_3.append(0)
  16.     top_5.append(0)
  17.     fails.append(0)
  18. for i in range(SIMS):
  19.     if i==0:
  20.         t1=time.time()
  21.     scores=[70188,66058,65043,64980,64662,63870,63614,63074,62632,60897,59874,58481] # Contestant scores
  22.     CONTS=12
  23.     assert len(scores)==CONTS, 'CONTS constant must equal length of scores list'
  24.     while CONTS>1:
  25.         lowestScore=MAXSCORE*1000000000
  26.         worstCont=-1
  27.         for cont in range(len(scores)):
  28.             if scores[cont]!=None:
  29.                 toadd=random.normalvariate(AVGSCORE,STDEV)
  30.                 if toadd>MAXSCORE:
  31.                     toadd=MAXSCORE
  32.                 elif toadd<MINSCORE:
  33.                     toadd=MINSCORE
  34.                 scores[cont]+=toadd
  35.                 if scores[cont]<lowestScore:
  36.                     lowestScore=scores[cont]
  37.                     worstCont=cont
  38.         scores[worstCont]=None
  39.         CONTS-=1
  40.         if CONTS==len(scores)-1:
  41.             fails[worstCont]+=1
  42.         elif CONTS==5:
  43.             for cont in range(len(scores)):
  44.                 if scores[cont]!=None:
  45.                     top_5[cont]+=1
  46.         elif CONTS==3:
  47.             for cont in range(len(scores)):
  48.                 if scores[cont]!=None:
  49.                     top_3[cont]+=1
  50.         elif CONTS==1:
  51.             for cont in range(len(scores)):
  52.                 if scores[cont]!=None:
  53.                     top_1[cont]+=1
  54.     if i==0:
  55.         t2=time.time()
  56.         texp=(t2-t1)*(SIMS-1)
  57.         print('This should take about %s seconds.' % texp)
  58. print('Eliminated next: %s' % fails)
  59. print('Top 5: %s' % top_5)
  60. print('Top 3: %s' % top_3)
  61. print('Top 1: %s' % top_1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement