" The implementation was successful and passed all the required tests … playing the game helps one prepare for the real thing at the Bellagio in Vegas. "

Project Portfolio:
  Blackjack Project

Challenge

Blackjack, also known as twenty-one, is the most widely played casino banking game in the world.  During a round of Blackjack, players play against a dealer with the goal of building a hand whose cards have a total value that is higher than the value of the dealer's hand, but not over 21.  The challenge of this project was to build a working replica of Blackjack using Python.  This project was a project for the Rice University Computer Science class “Introduction to Interactive Programing in Python”, offered through Coursera, an online education site.  The class is part of a series of classes designed to develop an understanding of computing fundamentals.

Solution

I have not posted the Python code solution online.  To take this class and do the project I signed an agreement that stated the actual code would not be shared publicly.  A foundation framework was already in place that took care of the environment to display the graphics and the window on which the game would be played.


Some of the solutions developed to implement Blackjack in Python successfully included:

  • Examples of implemented methods for an object class that represents the deck of cards:
    • Randomizing the deck of cards.
    • Dealing the cards and then storing the cards dealt and storing the cards left in the deck.
    • Modeling a deck of cards as list of cards, generating this list using a pair of nested for loops.
       
  • Examples of implemented methods for an object class that represents the hand:
    • Used provided VALUE dictionary to look up the value of a single card in conjunction with the logic to compute the value of a hand.
    • Created methods to draw the sequence of cards in the hands.
       
  • Implemented three buttons, “Deal”, “Hit” and “Stand” and gave the buttons’ the appropriate Blackjack game behaviors that the buttons’ name imply:
    •  “Deal" button that shuffles the deck and deals the two cards to both the dealer and the player.
    • “Hit" button that if the value of the hand is less than or equal to 21, clicking this button adds an extra card to player's hand. If the value exceeds 21 after being hit, the message "You have busted" is printed.
    • “Stand" button reminds the player is he/she has busted, otherwise, repeatedly hits the dealer until his hand has value 17 or more (using a while loop) and plays game to logical conclusion.
       
  • Created drawing methods that showed messages related to the game such as “Hit or Stand?” or “New deal?”
  • Added score counter that kept track of wins and losses for the player’s Blackjack session.

Results

The Python based project was challenging to develop.  The implementation was successful and passed all the required tests.  The Blackjack game is enjoyable to play and playing it helps one prepare for the real thing at the Bellagio in Vegas.