Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # A cheap python script to calculate the cummulative probabilities of drawing a particular card with or without Anonymous Tip.
- import collections
- import random
- NADA = 0
- DINO_DNA = 1 # Bingo
- ANONYMOUS_TIP = 2
- DECK_SIZE = 49
- USE_ANONYMOUS_TIP = False
- NUM_TRIALS = 1000000
- counts = collections.Counter()
- for _ in xrange(NUM_TRIALS):
- deck = [NADA] * DECK_SIZE
- deck[0:2] = [DINO_DNA]*2
- if USE_ANONYMOUS_TIP:
- deck[2:5] = [ANONYMOUS_TIP] * 3
- else:
- deck[2] = DINO_DNA
- # Do I remember how indexing works?
- assert len(deck) == DECK_SIZE
- random.shuffle(deck)
- draws = 0
- free_draws = 5 # Starting hand is free to draw.
- anonymous_tips = 0
- while True:
- if free_draws:
- free_draws -= 1
- else:
- draws += 1
- if anonymous_tips:
- anonymous_tips -= 1
- # The card says draw 3 but you could have drawn with the click you used to play it.
- free_draws += 2
- card = deck.pop(0)
- if card == DINO_DNA:
- break
- if card == ANONYMOUS_TIP:
- anonymous_tips += 1
- assert draws >= 0
- counts[draws] += 1
- cum_count = 0
- for i in range(DECK_SIZE):
- count = counts[i]
- cum_count += count
- print "%s\t%.2f" % (i, 100.0 * cum_count / NUM_TRIALS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement