Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- colors = ['R', 'U', 'W', 'G']
- # 35 avg turns
- crystalPicks = ['G']*5
- cardPicks = ['W']*5
- # 32 avg turns
- #crystalPicks = ['R']*5
- #cardPicks = ['R']*5
- turns = 0
- roundTurns = [0]*6
- trials = 10000
- for test in range(0, trials):
- cards = []
- for l in colors:
- cards.extend([l]*4)
- random.shuffle(cards)
- crystals = ['R', 'R', 'U']
- newCrystals = []
- newCards = []
- newCrystals.extend(crystalPicks)
- newCards.extend(cardPicks)
- # fill in rest randomly
- for i in range(len(newCrystals),5):
- newCrystals.append(random.choice(colors))
- for i in range(len(newCards),5):
- newCards.append(random.choice(colors))
- discard = []
- for round in range(0, 6):
- while len(cards):
- roundTurns[round] += 1
- turns += 1
- c = None
- # draw 3
- for i in range(0,3):
- if not len(cards):
- break
- c = cards.pop()
- discard.append(c)
- # draw more if color matches
- for cry in crystals:
- if c and c == cry and len(cards):
- discard.append(cards.pop())
- turns += 1 # player's last turn
- roundTurns[round] += 1
- if round == 5: # last round
- break
- # give dummy a card&crystal and shuffle
- crystals.append(newCrystals.pop(0))
- discard.append(newCards.pop(0))
- cards = discard
- random.shuffle(cards)
- discard = []
- print turns/float(trials), 'avg turns per game'
- for r in range(0,6):
- print r, roundTurns[r]/float(trials)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement