def equity(card1,card2,card3,card4,simulations=1000000): '''Equates the equity of one specified hand, versus another specified hand. Monte Carlo style.''' one = 0.0 two = 0.0 tie = 0.0 # create a dictionary of flops to use randomly # This seems effecient, but I've pondered about using instead # random.choice(deck) for each of the remaining 5 cards # I think, though, that dictionary lookup may prove to be faster flops = createboards(card1,card2,card3,card4) # How many times you want to run the hand versus the other hand # Default value is 30000 for i in range(simulations): # choose a flop to use, randomly flop = random.choice(flops) # evaluate the two hands against eachother x = evaluate(card1,card2,card3,card4,flop) if x == 1: one+=1.0 elif x == 2: two+=1.0 else: tie+=1.0 total = one+two+tie print total print("One is winning ",float(one/total)) print("Two is winning ",float(two/total)) print("And they are tying ",float(tie/total))
def equity(card1, card2, card3, card4, simulations=1000000): '''Equates the equity of one specified hand, versus another specified hand. Monte Carlo style.''' one = 0.0 two = 0.0 tie = 0.0 # create a dictionary of flops to use randomly # This seems effecient, but I've pondered about using instead # random.choice(deck) for each of the remaining 5 cards # I think, though, that dictionary lookup may prove to be faster flops = createboards(card1, card2, card3, card4) # How many times you want to run the hand versus the other hand # Default value is 30000 for i in range(simulations): # choose a flop to use, randomly flop = random.choice(flops) # evaluate the two hands against eachother x = evaluate(card1, card2, card3, card4, flop) if x == 1: one += 1.0 elif x == 2: two += 1.0 else: tie += 1.0 total = one + two + tie print total print("One is winning ", float(one / total)) print("Two is winning ", float(two / total)) print("And they are tying ", float(tie / total))
def equityVsrandom(card1, card2, flop=None, simulations=10000): '''Equates the equity of one specified hand, versus another Random Hand.''' ranrange = randomrange(card1, card2) one = 0.0 two = 0.0 tie = 0.0 if flop == None: flops = createboards(card1, card2) for i in range(simulations): flop = random.choice(flops) card3, card4 = random.choice(ranrange) x = evaluate(card1, card2, card3, card4, flop) if x == 1: one += 1.0 elif x == 2: two += 1.0 else: tie += 1.0 else: flops = createboards(card1, card2, card3=None, card4=None, flop1=flop[0], flop2=flop[1], flop3=flop[2]) for i in range(simulations): card3, card4 = random.choice(ranrange) x = random.choice(flops) x = evaluate(card1, card2, card3, card4, random.choice(flops) + flop) if x == 1: one += 1.0 elif x == 2: two += 1.0 else: tie += 1.0 total = one + two + tie results = (one / total * 100), (two / total * 100), (tie / total * 100) return results
def equityVsrandom(card1,card2,flop=None,simulations=10000): '''Equates the equity of one specified hand, versus another Random Hand.''' ranrange = randomrange(card1,card2) one = 0.0 two = 0.0 tie = 0.0 if flop == None: flops = createboards(card1,card2) for i in range(simulations): flop = random.choice(flops) card3,card4 = random.choice(ranrange) x = evaluate(card1,card2,card3,card4,flop) if x == 1: one+=1.0 elif x == 2: two+=1.0 else: tie+=1.0 else: flops = createboards(card1,card2,card3=None,card4=None,flop1=flop[0], flop2=flop[1],flop3=flop[2]) for i in range(simulations): card3,card4 = random.choice(ranrange) x = random.choice(flops) x = evaluate(card1,card2,card3,card4,random.choice(flops)+flop) if x == 1: one+=1.0 elif x == 2: two+=1.0 else: tie+=1.0 total = one+two+tie results = (one/total*100),(two/total*100),(tie/total*100) return results