The Assignment:
Create a simple Blackjack game in Python with player and deck classes and a basic game loop. The class was at the point where object oriented programming had been introduced and we were to take what we had learned and apply it to making a basic functioning Blackjack game. All it really had to do was create a deck object of cards with rank and suit, two player objects that would draw cards from the deck and calculate hand values, and a while loop to manage gameplay. So the key parts were:
Deck (the build method):
def build(self, chute_depth):
for i in range(chute_depth):
for suit in ['♥', '♦', '♠', '♣',]:
for rank in [
'A', '2', '3', '4', '5', '6', '7',
'8', '9', '10', 'J', 'Q', 'K',
]:
self.cards.append((rank, suit))
Player (the calculate method):
def calculate_score(self):
score = 0
aces = 0
for card in self.hand:
rank = card[0]
if rank == 'A':
aces += 1
elif rank in ['J', 'Q', 'K',]:
score += 10
else:
score += int(rank)
for i in range(aces):
if score + 11 + aces - 1 > 21:
score += 1
else:
score += 11
return score
Basic game loop (simplified):
while True:
bet_choices = []
if wager < min_bet:
bet = input(f"Enter wager ({min_bet}-{purse}):")
wager = int(bet)
else:
increase_wager = input("Increase wager? 'y' or 'n':")
if increase_wager == 'y':
bet = input(f"Wager increase: (1-{purse - wager}):")
wager += int(bet)
choice = input("Hit or Stand? 'h' or 's':")
if choice == 'h':
player_hits()
else:
dealers_turn = True
if dealers_turn:
game_outcome()
game_over()
And really that was most of what you needed to get a basic blackjack game and all that was asked of us. But I wanted to capture the essence of a real Blackjack game a little better than that.
What I did

The first thing I wanted to do was add some authenticity to the game. What was Blackjack really? Who are these Blackjack players and how could I capture their essence and the true feel of a genuine Blackjack game. So I contacted the estate of Wild Bill Hickok to seek approval for the use of his character as my Blackjack dealer. Surely if you were playing Blackjack with the legendary lawman and gambler Wild BIll Hickock you would have a more authentic Blackjack experience. Also the use of his moniker would grab people’s interest a little more than just a plain Blackjack game. They said as long as Bill’s character was depicted accurately I could use his name and if I wasn’t planning on profiting from the game I could use it for free!
So that started my research phase into the language, the attitude, and the style of the 19th century wild west. When I was confident that I could accurately portray the man, the legend, Wild Bill Hickok, I began writing the dialog for Blackjack With Wild Bill Hickok. What I did was write a half-dozen lines for each dialog situation and saved them as lists in script.py. Then I would call the list items by index with a 0-5 random number so each hand played a little different from the last.
Finally I wanted to see actual cards instead of ‘Ace of Spades’ so I made a Card class that could take in the ranks and suits of a hand and draw them as beautiful ascii graphic cards. The trick was you had to draw a whole hand line per line, as opposed to one card at a time because once you end a line there is no going back. The way I did it was to have a display method that took in the hand as a list of tuples, like so:
Card (the display method):
def display(self, char_list):
self.top_out = ''
self.top_char = ''
self.mid_char = ''
self.bot_char = ''
self.blank_side = ''
self.top_char = ''
self.mid_char = ''
self.bot_char = ''
self.top = ' ------- '
self.side = '| |'
self.bck1 = '|XXXXXXX|'
self.bck2 = '|XOOOOOX|'
for char in char_list:
rank = char[0]
suit = char[1]
self.top_out += self.top + ' '
if char == 'back':
self.top_char += self.bck1 + ' '
self.blank_side += self.bck2 + ' '
self.mid_char += self.bck2 + ' '
self.bot_char += self.bck1 + ' '
else:
self.top_char += Card.top_char(self, rank) + ' '
self.blank_side += self.side + ' '
self.mid_char += Card.mid_char(self, suit) + ' '
self.bot_char += Card.bot_char(self, rank) + ' '
print(self.top_out)
print(self.top_char)
print(self.blank_side)
print(self.mid_char)
print(self.blank_side)
print(self.bot_char)
print(self.top_out)
The top_char, mid_char, and bot_char methods simply created strings with the rank or suit in place.
So I included a few examples of how a hand might turn out. Have a look, and feel the authenticity.
Well I put it on the student submission board and the only feedback I got was other students wanted to know how I made the graphics for the cards (which was weird because part of the submission was the code itself), and the teacher thought it was good but inappropriate. Oh well.
Finally, I got a letter from the estate of Wild Bill Hickok stating that they did not like my characterization of Wild Bill and that infact I had to issue a public apology for my depiction and say that Wild Bill was actually a kind and soft spoken man, not at all like the dealer in my game. I was also named as the defendant in a lawsuit by the estate of Wild Bill Hickok seeking monetary compensation for my blatant and unlawful defamation of Wild Bill’s character and that I had to destroy all copies of the game and never speak of it again.
After many long years of appeals my case is finally going to the supreme court. So if this page comes down and when you ask me about this game I deny that it ever existed, you are not losing your mind, I simply am bound by the ultimate authority in this land to do what I do.


