Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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
Beispiel #10
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))
Beispiel #11
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()