Program 2: Poker Hand Evaluation

Logistics

Learning Outcomes

Poker Hand Representation

Poker Hand Evaluation - From Best to Worst

Note: Cards can appear in any order.

Assignment

Grading - 100 points

Note: Your program will be tested on a different set of poker hands than the ones that appear in the main() function of poker.py. Thus, it is important that you test your program on different inputs and identify the different types of poker hands in a general fashion.

Program 2 Test Data

    hand1 = [[10, "clubs"], [14, "clubs"], [12, "clubs"], [13, "clubs"], [11, "clubs"]]         # royal flush
    hand2 = [[13, "clubs"], [12, "clubs"], [11, "clubs"], [10, "clubs"], [9, "clubs"]]          # straight flush
    hand3 = [[9, "diamonds"], [9, "clubs"], [9, "hearts"], [2, "clubs"], [9, "spades"]]         # 4 of a kind
    hand4 = [[8, "diamonds"], [7, "clubs"], [8, "hearts"], [8, "clubs"], [7, "spades"]]         # full house
    hand5 = [[13, "hearts"], [7, "hearts"], [2, "hearts"], [8, "hearts"], [10, "hearts"]]       # flush
    hand6 = [[13, "clubs"], [11, "clubs"], [10, "clubs"], [12, "clubs"], [14, "spades"]]        # straight
    hand7 = [[13, "diamonds"], [14, "clubs"], [14, "hearts"], [8, "clubs"], [14, "spades"]]     # 3 of a kind
    hand8 = [[10, "spades"], [10, "clubs"], [6, "diamonds"], [2, "diamonds"], [2, "hearts"]]    # 2 pair
    hand9 = [[10, "spades"], [12, "clubs"], [11, "diamonds"], [9, "diamonds"], [11, "hearts"]]  # 1 pair
    hand10 =[[14, "diamonds"], [12, "diamonds"], [6, "diamonds"], [8, "diamonds"], [10, "hearts"]]  # nothing
    hands = [hand1, hand2, hand3, hand4, hand5, hand6, hand7, hand8, hand9, hand10]

    for hand in hands:
        print(hand, "-->", evaluate(hand))

Honor's Lab