Advertisement
Guest User

Average Win Time of Bolt Deck with Fetch Lands and Mulligans

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