forked from MasterChenb0x/blackjack-trainer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·57 lines (49 loc) · 1.92 KB
/
test.py
File metadata and controls
executable file
·57 lines (49 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
# Import the universe, or at least what is needed
import sys
import random
from card_functions import *
from blk_jak_functions import *
# Function to restart game if bust, out of deck, or just something happens
def game_over(player_total, fulldeck):
if player_total > 21:
print("You busted, would you like to play again?")
elif len(fulldeck) == 0:
print("The deck ran out of cards, would you like to play again")
else:
print("I am not sure what happened, would you like to play again though?")
q = input("(Y)es or (N)o?:")
if q.upper() == "Y":
fulldeck, player_hand, ph_total, dealer_hand, dh_total = new_game(deck_size)
eleven = 0
count = 0
return fulldeck, player_hand, ph_total, dealer_hand, dh_total, eleven, count
else:
print("Thank you for playing")
sys.exit()
# Basic Flow, to test all functions
print("Welcome to the BlackJack Card Counting Testing Suite")
deck_size = deck_count()
fulldeck = Deck(deck_size)
print("")
print("")
while True:
# Deals out a card, and updates player_hand, ph_total, and count correctly
fulldeck, card = deal(fulldeck)
player_hand.append(card)
ph_total, elevens = faceSum(card, ph_total, elevens)
count = hilo_counter(card, count)
if len(player_hand) < 2:
continue # using this to get starting hand
print("")
# Checks if player hand is over 21, checks to see if any aces are 11
if ph_total > 21:
ph_total, elevens = ace_bust_check(ph_total, elevens)
if ph_total > 21:
gui(player_hand, ph_total, count)
fulldeck, player_hand, ph_total, dealer_hand, dh_total, eleven, count = game_over(ph_total, elevens)
if ph_total == 0:
continue
gui(player_hand, ph_total, count)
# Asks if you want to hit or stand
player_hand, ph_total, elevens = player_action(player_hand, ph_total, elevens)