Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- SIMS=1000000 # Number of simulations to run
- MINSCORE=0 # Lower cap of event scores
- MAXSCORE=20000 # Upper cap of event scores
- AVGSCORE=10000 # Average event score
- STDEV=2000 # Standard deviation of event scores
- CONTS=12 # Number of contestants
- top_1=list()
- top_3=list()
- top_5=list()
- fails=list()
- for i in range(CONTS):
- top_1.append(0)
- top_3.append(0)
- top_5.append(0)
- fails.append(0)
- for i in range(SIMS):
- if i==0:
- t1=time.time()
- scores=[70188,66058,65043,64980,64662,63870,63614,63074,62632,60897,59874,58481] # Contestant scores
- CONTS=12
- assert len(scores)==CONTS, 'CONTS constant must equal length of scores list'
- while CONTS>1:
- lowestScore=MAXSCORE*1000000000
- worstCont=-1
- for cont in range(len(scores)):
- if scores[cont]!=None:
- toadd=random.normalvariate(AVGSCORE,STDEV)
- if toadd>MAXSCORE:
- toadd=MAXSCORE
- elif toadd<MINSCORE:
- toadd=MINSCORE
- scores[cont]+=toadd
- if scores[cont]<lowestScore:
- lowestScore=scores[cont]
- worstCont=cont
- scores[worstCont]=None
- CONTS-=1
- if CONTS==len(scores)-1:
- fails[worstCont]+=1
- elif CONTS==5:
- for cont in range(len(scores)):
- if scores[cont]!=None:
- top_5[cont]+=1
- elif CONTS==3:
- for cont in range(len(scores)):
- if scores[cont]!=None:
- top_3[cont]+=1
- elif CONTS==1:
- for cont in range(len(scores)):
- if scores[cont]!=None:
- top_1[cont]+=1
- if i==0:
- t2=time.time()
- texp=(t2-t1)*(SIMS-1)
- print('This should take about %s seconds.' % texp)
- print('Eliminated next: %s' % fails)
- print('Top 5: %s' % top_5)
- print('Top 3: %s' % top_3)
- print('Top 1: %s' % top_1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement