def deal_and_evaluate():
    d = Deck()
    d.shuffle()
    hands = d.deal_hands(2)
    winning_hand = -1
    hand_text = [repr(h) for h in hands]
    if hands[0] > hands[1]:
        winning_hand = 0
    elif hands[0] < hands[1]:
        winning_hand = 1
    return jsonify({'winner': winning_hand, 'hands': hand_text})
Beispiel #2
0
        hold_all = [True, True, True, True, True]
        # 1.) Four of a kind, straight flush, royal flush
        if self.is_straight_flush() or self.is_royal_flush():
            return hold_all
        elif self.is_four_of_a_kind():
            return self.hold_four_of_a_kind()
        # 2.) 4 to a royal flush
        hold = self.hold_four_for_royal_flush()
        if hold:
            return hold
        # 3.) Three of a kind, straight, flush, full house
        elif self.is_straight() or self.is_flush() or self.is_full_house():
            return hold_all
        # Note that we know that full house is already excluded so
        hold = self.hold_three_of_a_kind()
        if hold:
            return hold
        # TODO finish this


class JacksOrBetter(VideoPoker):
    def __init__(self):
        VideoPoker.__init__(self)


if __name__ == "__main__":
    d = Deck()
    d.shuffle()
    jackscalc = JackOrBetterHandSimpleStrategy(d.deal_hand(5))
    print [card.basic for card in jackscalc.hand]
Beispiel #3
0
 print("                           $")
 print("                        $$$$$$$")
 print("                      $$   $   $$")
 print("                      $    $    $")
 print("                      $    $    ")
 print("                       $$  $  ")
 print("                         $$$$$")
 print("                           $  $$")
 print("                           $    $")
 print("                      $    $    $")
 print("                      $$   $   $$")
 print("                        $$$$$$$")
 print("                           $")
 print()
 myDeck = Deck()
 myDeck.shuffle()
 dealer = Player()
 player = Player()
 myDeck.deal(dealer, 2)
 myDeck.deal(player, 2)
 print("Here are the dealer's cards: " + dealer.__str__())
 dealer_sum = dealer.get_value()
 print("They add to " + str(dealer_sum))
 print()
 print("Here are your cards: " + player.__str__())
 player_sum = player.get_value()
 print("They add to " + str(player_sum))
 print()
 hitting = True
 while hitting:
     answer = input("Hit or Stay?")
Beispiel #4
0
player8 = Hand('Timur', table, 'SklanskySys2')

deck = Deck()

status = 'play'

#for i in range (0,2):

while status == 'play':

    #increment the table hand#

    #shuffle the deck

    deck.populate()
    deck.shuffle()

    #create pot for this hand
    pots = []
    pot = Pot(table, 'main')

    for player in table.players:
        pot.players.append(player)
        pot.active_players.append(player)

    pots.append(pot)

    #allocate blinds and ante up

    pot.set_blinds()
Beispiel #5
0
from poker import Player, Card, Deck

playing = True

while playing:
    my_deck = Deck()
    my_deck.shuffle()
    opponent = Player()
    player = Player()
    my_deck.deal(opponent, 5)
    my_deck.deal(player, 5)
    print(opponent)
    print(player)
    playing = False
Beispiel #6
0
for result in results:
    result_dict[result] = 0

# for i in range(10000):
#     new_deck = Deck()
#     new_deck.shuffle()
#     for j in range(10):
#         hand = Hand(new_deck)
#         if hand.is_full_house():
#             print("Full House: ", hand)

for i in range(100000):
    #while result_dict[results[0]] == 0:

    new_deck = Deck()
    new_deck.shuffle()
    # 10 hands per deck, right?
    #for j in range(10):
    hand = Hand(new_deck)
    result_dict[hand.check_ranking()] += 1

print(result_dict)

# checking that all hands get assigned a result
total = 0
for i in result_dict:
    total += result_dict[i]

print(total)
new_deck = Deck()
print(len(new_deck.cards))