Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- c = [0.8, 0.4, 0.05]
- clicks_total = 6 * 8
- tri_hits = 0
- total_rounds = 0
- for i in range(100000):
- lvl = 0
- available_clicks = clicks_total
- while available_clicks > 0 and lvl < 3:
- if random.uniform(0, 1) < c[lvl]:
- lvl = lvl + 1
- else:
- lvl = max(lvl - 1, 0)
- available_clicks = available_clicks - 1
- if lvl == 3:
- tri_hits = tri_hits + 1
- break
- total_rounds = total_rounds + 1
- 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