Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import random
  2.  
  3. c = [0.8, 0.4, 0.05]
  4. clicks_total = 6 * 8
  5.  
  6.  
  7. tri_hits = 0
  8. total_rounds = 0
  9. for i in range(100000):
  10.     lvl = 0
  11.     available_clicks = clicks_total
  12.     while available_clicks > 0 and lvl < 3:
  13.         if random.uniform(0, 1) < c[lvl]:
  14.             lvl = lvl + 1
  15.         else:
  16.             lvl = max(lvl - 1, 0)
  17.         available_clicks = available_clicks - 1
  18.        
  19.         if lvl == 3:
  20.             tri_hits = tri_hits + 1
  21.             break
  22.  
  23.     total_rounds = total_rounds + 1
  24.     print("rounds: %d hits: %d chance: %f" %(total_rounds, tri_hits, tri_hits / total_rounds))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement