Advertisement
Guest User

Anonymous Tip in Combo Decks

a guest
Jun 24th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # A cheap python script to calculate the cummulative probabilities of drawing a particular card with or without Anonymous Tip.
  3. import collections
  4. import random
  5.  
  6. NADA = 0
  7. DINO_DNA = 1 # Bingo
  8. ANONYMOUS_TIP = 2
  9.  
  10. DECK_SIZE = 49
  11. USE_ANONYMOUS_TIP = False
  12.  
  13. NUM_TRIALS = 1000000
  14. counts = collections.Counter()
  15.  
  16. for _ in xrange(NUM_TRIALS):
  17.   deck = [NADA] * DECK_SIZE
  18.   deck[0:2] = [DINO_DNA]*2
  19.  
  20.   if USE_ANONYMOUS_TIP:
  21.     deck[2:5] = [ANONYMOUS_TIP] * 3
  22.   else:
  23.     deck[2] = DINO_DNA
  24.  
  25.   # Do I remember how indexing works?
  26.   assert len(deck) == DECK_SIZE
  27.  
  28.   random.shuffle(deck)
  29.   draws = 0
  30.   free_draws = 5 # Starting hand is free to draw.
  31.   anonymous_tips = 0
  32.  
  33.   while True:
  34.     if free_draws:
  35.       free_draws -= 1
  36.     else:
  37.       draws += 1
  38.       if anonymous_tips:
  39.         anonymous_tips -= 1
  40.         # The card says draw 3 but you could have drawn with the click you used to play it.
  41.         free_draws += 2
  42.  
  43.     card = deck.pop(0)
  44.     if card == DINO_DNA:
  45.       break
  46.     if card == ANONYMOUS_TIP:
  47.       anonymous_tips += 1
  48.  
  49.   assert draws >= 0
  50.   counts[draws] += 1
  51.  
  52. cum_count = 0
  53. for i in range(DECK_SIZE):
  54.   count = counts[i]
  55.   cum_count += count
  56.   print "%s\t%.2f" % (i, 100.0 * cum_count / NUM_TRIALS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement