Example #1
0
 def choose(self):
     greaterCard = 0.0
     deckSize = 52.0
     while True:
         need = 21- hand.handvalue(self)
         if (need <= 0):
             break
         for x in range (1, 53):
             if (deck.deck[x] == 0):
                 deckSize = deckSize - 1.0
             elif (deck.deck[x] != 0):
                 if (hand.check(deck.deck[x], self) > need):
                     greaterCard = greaterCard + 1.0
         bustProb = greaterCard/deckSize
         if (bustProb < 0.50):
             hand.deal(self)
         else:
             break
Example #2
0
#welcome message

print ("*WELCOME TO BLACKJACK*")


exit = False

while exit == False:
    deck.fresh_deck()
    hand.clearhand(ai)
    hand.clearhand(player)
    print ("You have $%s to play with." % (mplayer.amount))

    #deals two cards to player

    print("\nYou received a: %s " % (hand.name(hand.deal(player))))
    print("You received a: %s\n" % (hand.name(hand.deal(player))))

    #deals two cards to ai

    print("AI received two cards...")
    print("AI's card shown: " + hand.name(hand.deal(ai))+"\n")
    hand.name(hand.deal(ai))

    #hit or stay? 



    offer = money.bet (player.owner)

    while True: