Exemple #1
0
def test_highCard():
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣5', '♡J'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [1, 13, 12, 11, 8, 5]
    i = 0
    while i < 6:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣5', '♢J', '♣6', '♡T'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [1, 13, 12, 11, 10, 8]
    i = 0
    while i < 6:
        assert v[i] == compared[i]
        i += 1
Exemple #2
0
def test_trips():
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣K', '♡K', "♢2"])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [4, 13, 12, 8]
    i = 0
    while i < 4:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣K', '♡K', '♡3', '♢2'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [4, 13, 12, 8]
    i = 0
    while i < 4:
        assert v[i] == compared[i]
        i += 1
Exemple #3
0
def test_pair():
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣K', '♡J'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [2, 13, 12, 11, 8]
    i = 0
    while i < 5:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣K', '♡J', '♣A', '♡2'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [2, 13, 14, 12, 11]
    i = 0
    while i < 5:
        assert v[i] == compared[i]
        i += 1
Exemple #4
0
def test_twoPair():
    communityCards = np.array(['♢Q', '♢K', '♢8', '♣K', '♡Q'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [3, 13, 12, 8]
    i = 0
    while i < 4:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♢Q', '♢K', '♢2', '♣2', '♡9', '♡K', '♡Q'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [3, 13, 12, 9]
    i = 0
    while i < 4:
        assert v[i] == compared[i]
        i += 1
Exemple #5
0
def test_quads():
    communityCards = np.array(['♢Q', '♢K', '♠K', '♣K', '♡K'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [8, 13, 12]
    i = 0
    while i < 3:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♢A', '♢K', '♠K', '♣K', '♡K', '♣A', '♠A'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [8, 13, 14]
    i = 0
    while i < 3:
        assert v[i] == compared[i]
        i += 1
Exemple #6
0
def test_fullhouse():
    communityCards = np.array(["♣A", "♣T", "♣K", "♣Q", "♢K", "♢Q", "♡K"])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [7, 13, 12]
    i = 0
    while i < 3:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♢K', '♠A', '♢A', '♠Q', '♣Q', '♠K', '♣K'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [7, 13, 14]
    i = 0
    while i < 3:
        assert v[i] == compared[i]
        i += 1
Exemple #7
0
def two_hands_theoretical_by_pickle(name1,name2): ## Takes in pickled files
    h1wins=0
    h2wins=0
    ties=0
    h1= "D:\AllValuesByHand\AllRunoutsByHandPickle\\" + name1 + 'Values.pickle'
    h2= "D:\AllValuesByHand\AllRunoutsByHandPickle\\" + name2 + 'Values.pickle'
    h1file=open(h1, "rb")
    h2file=open(h2, "rb")
    h1Hands= pickle.load(h1file)
    h2Hands= pickle.load(h2file)
    h2file.close()
    h1file.close()
    i=0
    while i < 2598960:
        currH1=h1Hands[i]
        currH2=h2Hands[i]
        if currH1[0] != 0 and currH2[0] != 0:
            v = HandValueChecker.returnBetterHand(currH1, currH2)
            if v == 0:
                ties += 1
            if v == 1:
                h1wins += 1
            if v == 2:
                h2wins += 1
        i+=1
    return np.array([(h1wins/ (h1wins+ties+h2wins)),(h2wins/ ((h1wins+ties+h2wins))),(ties/(h1wins+ties+h2wins))])
Exemple #8
0
def test_flush():
    communityCards = np.array(['♢Q', '♢K', '♢A', '♢J', '♢8', '♣8', '♣T'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [6, 14, 13, 12, 11, 8]
    i = 0
    while i < 6:
        assert v[i] == compared[i]
        i += 1
Exemple #9
0
def test_striaghtflush():
    communityCards = np.array(['♢A', '♢K', '♢Q', '♢J', '♢T', '♢9'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [9, 14]
    i = 0
    while i < 2:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♡A', '♣J', '♡2', '♡3', '♡4', '♡5', '♣J'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [9, 5]
    i = 0
    while i < 2:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♡6', '♣J', '♡2', '♡3', '♡4', '♡5', '♣J'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [9, 6]
    i = 0
    while i < 2:
        assert v[i] == compared[i]
        i += 1
Exemple #10
0
def test_straight():  ## Needs to have ace be 1 or 14
    communityCards = np.array(['♢Q', '♢K', '♠A', '♣J', '♡T', '♡2'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [5, 14]
    i = 0
    while i < 2:
        assert v[i] == compared[i]
        i += 1
    communityCards = np.array(['♠A', '♣3', '♡2', '♡3', '♡5', '♡4', '♣5'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [5, 5]
    i = 0
    while i < 2:
        assert v[i] == compared[i]
        i += 1

    communityCards = np.array(['♠6', '♣3', '♡2', '♡3', '♡5', '♡4', '♣5'])
    v = HandValueChecker.returnHandValueNew(communityCards)
    compared = [5, 6]
    i = 0
    while i < 2:
        assert v[i] == compared[i]
        i += 1
Exemple #11
0
def testWinPercentage(k):  ## Seems to Be working +/- 0.001
    hand1Cards = np.array(["♡A", '♣2'])
    hand2Cards = np.array(['♡K', '♡9'])
    deck = PokerWidgets.deckOfCards()
    deck = np.delete(deck, np.argwhere(deck == hand1Cards[0]))
    deck = np.delete(deck, np.argwhere(deck == hand1Cards[1]))
    deck = np.delete(deck, np.argwhere(deck == hand2Cards[0]))
    deck = np.delete(deck, np.argwhere(deck == hand2Cards[1]))
    hand1 = 0
    hand2 = 0
    ties = 0
    i = 0
    while i < k:  # v should be 61
        print(i)
        np.random.shuffle(deck)
        handOne = np.array([
            hand1Cards[0], hand1Cards[1], deck[0], deck[1], deck[2], deck[3],
            deck[4]
        ])
        hand1Value = HandValueChecker.returnHandValueNew(handOne)
        handTwo = np.array([
            hand2Cards[0], hand2Cards[1], deck[0], deck[1], deck[2], deck[3],
            deck[4]
        ])
        hand2Value = HandValueChecker.returnHandValueNew(handTwo)
        v = HandValueChecker.returnBetterHand(hand1Value, hand2Value)
        if v == 0:
            ties += 1
        if v == 1:
            hand1 += 1
        if v == 2:
            hand2 += 1
        i += 1
    v = hand1 / (hand1 + hand2 + ties)
    print(v)
    print(hand2 / (hand1 + hand2 + ties))
    print(ties / (hand1 + hand2 + ties))
Exemple #12
0
def allRunoutsByHandToPickle(name): ## Pickle of the array which contains the value of every single runout for a hand
    array = np.full((2598960,6),0)
    h2file = open("allCombinatiosOfRunouts.pickle", "rb")
    allHands = pickle.load(h2file)
    h2file.close()
    i=0
    while i < 2598960:
            cards= np.array([name[0:2],name[2:4],allHands[i][0],allHands[i][1],allHands[i][2],allHands[i][3],allHands[i][4]])
            if PokerWidgets.are_not_duplicates(cards)== True:
                cardValue = HandValueChecker.returnHandValueNew(cards)
                j=0
                while j < len(cardValue):
                    array[i][j]= cardValue[j]
                    j+=1
            i+=1
    v="D:\AllValuesByHand\AllRunoutsByHandPickle\\"
    file1_pickle = open(v+name+"Values.pickle", "wb")
    pickle.dump(array,file1_pickle,pickle.HIGHEST_PROTOCOL)
    file1_pickle.close()
Exemple #13
0
def two_hands_theoretical_by_pickle_test(name1,name2): ## Takes in pickled files
    h1wins=0
    h2wins=0
    ties=0
    h1= "D:\AllValuesByHand\AllRunoutsByHandPickle\\" + name1 + 'Values.pickle'
    h2= "D:\AllValuesByHand\AllRunoutsByHandPickle\\" + name2 + 'Values.pickle'
    h1file=open(h1, "rb")
    h2file=open(h2, "rb")
    h3file=open("allCombinationsOfRunouts.txt","r", encoding='utf-8')
    h1Hands= pickle.load(h1file)
    h2Hands= pickle.load(h2file)
    h2file.close()
    h1file.close()
    high = 0
    pair = 0
    twoPair = 0
    threeOfAKind = 0
    straight = 0
    flush = 0
    fullHouse = 0
    Quads = 0
    straightFlush = 0
    i=0
    while i < 2598960:
        readline=h3file.readline()
        currH1=h1Hands[i]
        currH2=h2Hands[i]
        if currH1[0] != 0 and currH2[0] != 0:
            v = HandValueChecker.returnBetterHand(currH1, currH2)
            if v == 0:
                h1Hand=currH1[0]
                if h1Hand == 1:
                    high += 1
                if h1Hand == 2:
                    pair += 1
                if h1Hand == 3:
                    twoPair += 1
                if h1Hand == 4:
                    threeOfAKind += 1
                if h1Hand == 5:
                    straight += 1
                if h1Hand == 6:
                    flush += 1
                if h1Hand == 7:
                    print(name1 + readline[0:10])
                    print(currH1)
                    print(name2 + readline[0:10])
                    print(currH2)
                    fullHouse += 1
                if h1Hand == 8:
                    Quads += 1
                if h1Hand == 9:
                    straightFlush += 1
                ties += 1
            if v == 1:
                h1wins += 1
            if v == 2:
                h2wins += 1
        i+=1
    h3file.close()
    total=high+pair+twoPair+threeOfAKind+straight+flush+fullHouse+Quads+straightFlush
    print("high card" + str(high / total))
    print("pair" + str(pair / total))
    print("two pair" + str(twoPair / total))
    print("trips" + str(threeOfAKind / total))
    print("straight " + str(straight / total))
    print("flush" + str(flush / total))
    print("full house" + str(fullHouse / total))
    print(" quads" + str(Quads / total))
    print(" straight flush" + str(straightFlush / total))
    print(ties)
    print(str(ties+h1wins+h2wins))
    return np.array([((h1wins+(ties/2))/ (h1wins+ties+h2wins)),(h2wins+(ties/2))/ ((h1wins+ties+h2wins)),(ties/(h1wins+ties+h2wins))])