Computing Systems And Assembly Language
             
             
             
             
 

Extra Credit: Blackjack

Due date

Due in the locker Tuesday, August 25 by 10pm -- but you must show it to your TA in lab.

Lab Objective

Blackjack is a card game played with a standard 52-card deck with four suits, 13 cards in each suit numbered 2 through 10, J, Q, K, A. Each card is assigned a numeric value; i.e., 2 through 9 have their face value and 10, J, Q, K are valued 10. A always has worth 11.

The object of the game is to beat the dealer by accumulating cards, starting with two, one at a time, for a sum not exceeding 21 (see Figure 1).

See also the Wikipedia Blackjack entry for detailed rules.

This lab is extra credit, and is graded as follows.

You bet the 30 possible points on the lab. If your program works (i.e., we verify that we can play a couple hands of Blackjack), you receive full credit, up to the maximum that you bet. If your program does not work, you receive 0. A write-up is not required.

blackjack
Figure 1: You win automatically (Blackjack) if the sum of your cards is 21.

Requirements for Blackjack

The Blackjack program must meet at least the following criteria. It must ...

  • Simulate being the Blackjack dealer
  • Select pseudorandom numbers as necessary using the clock and the interrupt button
  • Generate unique, distinct cards per game
  • Have real-time user interaction, accepting user input
  • Spend minimal time in an interrupt service routine
  • Display the user's cards in a timely manner
  • Display the dealer's hand at the end of the turn
  • Notify the user of loss or win
  • Ask the user to play again, and loop as necessary

Our Blackjack rules

We will use simplified Blackjack rules as listed below.

  • The dealer chooses two cards for the player and two cards for himself.
    Note: Technically, one card is dealt to the player, and then one card for the dealer; then another for the player and another for the dealer, but this is not required.
  • The player's cards are displayed. One of the dealer's cards is displayed; the other is hidden.
  • The dealer calculates the player's and dealer's sums.
    Note: If the player's sum is equal to 21 at this point, that's called a Blackjack and the player wins automatically. If the dealer's sum is equal to 21 at this point, the dealer has a Blackjack and wins automatically. If both the player and the dealer have a Blackjack, neither the player nor the dealer win; the game is restarted.
  • The player may choose to hit or to stay. If the player chooses to hit, the dealer selects and displays another card for the player. This step is repeated until one of the following conditions are met.
    • The player chooses to stay, not taking any more cards.
    • The player busts, or the sum of her cards exceeds 21. The dealer then wins.
  • The dealer may choose to hit or to stay. The dealer must follow the following rules.
    • The dealer must hit while the sum of his cards does not exceed 16 (hit on 16 or under).
    • The dealer must stay while the sum of his cards exceeds 16 (stay on 17 or more).
    • The dealer busts if the sum of his cards exceeds 21.
  • If the sum of the player's cards exceeds that of the dealer's, yet does not exceed 21, the player wins.
  • If the sum of the player's cards is less than that of the dealer's, yet does not exceed 21, the dealer wins.
  • If the sum of the player's cards is equal to that of the dealer's, the dealer wins.

References and other useful things

As before, this section will be populated as references become available.

A good way to define functionality with the switches is using bitmasks. For example:

  • 7th bit on: play again (keep looping while this bit is on)
  • 0th bit on: hit (off to stay)

Grading template

Coding requirements

A check-off is required to receive extra credit in this lab. You must make an appointment with your lab tutor to show your lab to him or her.

Lab write-up requirements

The write-up is not required. In addition to the basic things expected in a lab write-up, describe your algorithms in detail, including but not limited to the following.

  • How you generate random cards
  • Any alogithmic or programming problems you encountered
  • Anything really clever you came up with

impact-silly