Blackjack Simulation
Construct and perform a simulation of the game blackjack.
The rules are as follows:
Most casinos use six or eight decks of cards. You will assume that you have an
infinite deck. There are only two
players, you and the dealer. Each player receives two cards to begin play. The
cards are worth their face value in points for 2-10 and 10 points for Jack,
Queen, and King. Typically aces are worth either 1 or 11, but you may assume
they are always worth 11. The object of the game is to obtain a total as close
to 21 as possible without going over (called busted), with your total more than
the dealerŐs.
If the first two cards total 21, this is called blackjack
and is an automatic winner (unless both you and the dealer have blackjack, in
which case it is a tie, or push.
If neither you nor the dealer has blackjack, you can take as
many cards as you want, one at a time, to try to get as close to 21 as
possible. If you go over 21, you lose and the game ends. When you are satisfied
with your score, you stand. The dealer then draws cards according to the rules:
the dealer stands on 17 and above.
The dealer must draw a card if his total is 16 or less.
If the dealer goes over 21, you win. If the dealerŐs total
exceeds your total, you lose your bet.
If the dealerŐs total equals your total, itŐs a push and you keep your
bet but donŐt win any money.
Assume that you have an unlimited amount of money
(HA!). Bet $1 on each hand. Play
10 sets of 100 games and record your performance (money ahead or in the hole)
for each set. Output your
performance for each of the ten hands and your average performance over the 10
sets. Note: donŐt restart maple
between sets---you donŐt want to reset the random number generator each time;
otherwise all 10 sets will have exactly the same results.
Good luck!