def create_hole_cards(raw_hole_cards): # Checking that there are an even number of hole cards if (raw_hole_cards is None or len(raw_hole_cards) < 2 or len(raw_hole_cards) % 2): print("You must provide a non-zero even number of hole cards") exit() # Create two-tuples out of hole cards hole_cards, current_hole_cards = [], [] for hole_card in raw_hole_cards: if hole_card != "?": current_card = holdem_functions.Card(hole_card) current_hole_cards.append(current_card) else: current_hole_cards.append(None) if len(current_hole_cards) == 2: if None in current_hole_cards: if (current_hole_cards[0] is not None or current_hole_cards[1] is not None): print("Unknown hole cards must come in pairs") exit() hole_cards.append((current_hole_cards[0], current_hole_cards[1])) current_hole_cards = [] if hole_cards.count((None, None)) > 1: print("Can only have one set of unknown hole cards") return tuple(hole_cards)
def create_cards(card_strings): return [holdem_functions.Card(arg) for arg in card_strings]
# -*- coding: utf-8 -*- """ Created on Fri Nov 3 17:43:30 2017 @author: SrivatsanPC """ import holdem_calc as hc import holdem_functions as hf import time #Example for calculating hand strength for a pair of cards without any board. For instance, #let us calculate it for 3s 4h. #start_time = time.time() card_1 = hf.Card('Td') card_2 = hf.Card('Qs') combo = (card_1, card_2) out = hc.run((tuple(combo), ), int(1e4), False, None, None, False) print(out) #print("Time diff is", end_time-start_time) #Example for calculating hand strength including the board cards. #card_1 = hf.Card('Qh') #card_2 = hf.Card('Kd') #combo = (card_1,card_2) ##board=None #board = [hf.Card('7c'), hf.Card('9d'), hf.Card('Ks'),hf.Card('Qc')] #start_time = time.time() #out = hc.run((tuple(combo),),int(2500),True, board,None,False) #end_time = time.time()
from os import chdir, getcwd import holdem_calc as hc import holdem_functions as hf import itertools import pdb import time from copy import deepcopy import random, math # chdir("E:\\CS281AdvancedML\\cs281-final-project\Programs\odds\pickledir") symbols = ['2','3','4','5','6','7','8','9','T','J','Q','K','A'] suits = ['h','s','c','d'] poss_cards = [] for sy in symbols: for su in suits: poss_cards.append(hf.Card(sy+su)) assert(len(poss_cards) == 52) def ncr(n,r): return math.factorial(n)/(math.factorial(r)*math.factorial(n-r)) def combination_util(poss_cards, n, r,index, data, i, tot_out): if index == r: tot_out.append(data) return if i >= n: return data[index] = poss_cards[i];