Advertisement
Guest User

Average Win Time of Bolt Deck with Fetch Lands

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