def test_26_play_hand_simple_strategy_2(self): random.seed(5) correct_return = 2.0 deck = CardDecks(8, BlackJackCard) amount_bet, player_return = play_hand(deck, BlackJackHand.simple_strategy) self.assertTrue(is_within_epsilon(correct_return, player_return, 0.0001), 'Return from play_hand is not correct with simple strategy.')
def test_23_play_hand_peek_strategy_1(self): random.seed(3) correct_return = 0 deck = CardDecks(1, BlackJackCard) amount_bet, player_return = play_hand(deck, BlackJackHand.peek_strategy) self.assertTrue(is_within_epsilon(correct_return, player_return, 0.0001), 'Return from play_hand is not correct with peek strategy.')
def test_28_play_hand_doubledown_strategy_2(self): random.seed(7) correct_return = 0.0 #@TODO give a mock deck to see return be 4x initial bet deck = CardDecks(8, BlackJackCard) amount_bet, player_return = play_hand(deck, BlackJackHand.doubledown_strategy) self.assertTrue(is_within_epsilon(correct_return, player_return, 0.0001), 'Return from doubledown strategy actual (%f) differs from expected (%f) too much' % (player_return, correct_return))
def test_27_play_hand_doubledown_strategy_1(self): random.seed(6) correct_return = 1.0 deck = CardDecks(8, BlackJackCard) amount_bet, player_return = play_hand(deck, BlackJackHand.doubledown_strategy) self.assertTrue(is_within_epsilon(correct_return, player_return, 0.0001), 'Return from doubledown strategy actual (%f) differs from expected (%f) too much' % (player_return, correct_return))
# Processes a human player; dealer remains hidden while True: # Holds all player instances to be used as arguments for functions player_pool = [] # Gets how many players are playing number_of_players = input("How many people are playing? ") if int(number_of_players) == 0: print("Goodbye") break # Creates specified number of players and appends them to list for number in range(int(number_of_players)): player_pool.append( blackjack.Player(blackjack.deal_card(deck), blackjack.deal_card(deck))) # For loop goes through the list of players and plays game for each for i in range(len(player_pool)): print("\nNow playing player " + str(i + 1)) blackjack.play_hand(player_pool[i], deck) # Add in the dealer and play its turn player_pool.append(dealer) blackjack.dealer_turn(dealer, deck) print(blackjack.compare_scores(player_pool)) break