Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- LIFE_TOTAL = 20
- LAND_COUNT = 18
- def playAGame():
- deck = ["land"] * LAND_COUNT + ["bolt"] * (60 - LAND_COUNT)
- hand = []
- landCounter = 0
- damageDealt = 0
- turnCounter = 0
- # Opening hand 7 cards
- for a in range(7):
- drawPhase(deck, hand)
- while damageDealt < LIFE_TOTAL:
- turnCounter += 1
- print "Turn", turnCounter
- print "My hand", hand
- drawPhase(deck, hand)
- landCounter = landPhase(hand, landCounter)
- damageDealt = boltPhase(hand, landCounter, damageDealt)
- print "I win on turn", turnCounter
- return turnCounter
- def drawPhase(deck, hand):
- myDraw = random.choice(deck)
- print "I drew", myDraw
- deck.remove(myDraw)
- hand.append(myDraw)
- def landPhase(hand, landCounter):
- if "land" in hand:
- print "I play a land"
- hand.remove("land")
- return landCounter + 1
- else:
- return landCounter
- def boltPhase(hand, landCounter, damageDealt):
- damageDealtThisPhase = 0
- for a in range(landCounter):
- if "bolt" in hand:
- print "I play a bolt"
- hand.remove("bolt")
- damageDealtThisPhase += 3
- return damageDealt + damageDealtThisPhase
- totalTurns = 0;
- for a in range(100000):
- totalTurns += playAGame();
- print totalTurns / 100000.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement