Advertisement
Guest User

Average Win Time of Bolt Deck

a guest
Jul 4th, 2013
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. import random
  2.  
  3. LIFE_TOTAL = 20
  4. LAND_COUNT = 18
  5.  
  6. def playAGame():
  7.  
  8.     deck = ["land"] * LAND_COUNT + ["bolt"] * (60 - LAND_COUNT)
  9.  
  10.     hand = []
  11.    
  12.     landCounter = 0
  13.  
  14.     damageDealt = 0
  15.    
  16.     turnCounter = 0
  17.    
  18. # Opening hand 7 cards
  19.     for a in range(7):
  20.         drawPhase(deck, hand)
  21.    
  22.     while damageDealt < LIFE_TOTAL:
  23.        
  24.         turnCounter += 1
  25.         print "Turn", turnCounter
  26.         print "My hand", hand
  27.         drawPhase(deck, hand)
  28.         landCounter = landPhase(hand, landCounter)
  29.         damageDealt = boltPhase(hand, landCounter, damageDealt)
  30.    
  31.     print "I win on turn", turnCounter
  32.     return turnCounter
  33.        
  34. def drawPhase(deck, hand):
  35.     myDraw = random.choice(deck)
  36.     print "I drew", myDraw
  37.     deck.remove(myDraw)
  38.     hand.append(myDraw)
  39.    
  40. def landPhase(hand, landCounter):
  41.     if "land" in hand:
  42.         print "I play a land"
  43.        
  44.         hand.remove("land")
  45.         return landCounter + 1
  46.    
  47.     else:
  48.         return landCounter
  49.        
  50. def boltPhase(hand, landCounter, damageDealt):
  51.     damageDealtThisPhase = 0
  52.     for a in range(landCounter):
  53.         if "bolt" in hand:
  54.             print "I play a bolt"
  55.             hand.remove("bolt")
  56.             damageDealtThisPhase += 3
  57.            
  58.     return damageDealt + damageDealtThisPhase
  59.    
  60. totalTurns = 0;
  61. for a in range(100000):
  62.     totalTurns += playAGame();
  63.  
  64. print totalTurns / 100000.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement