Introducing the Blackjack Game


The final project for this chapter is a simplified version of the card game, black-jack. The game works like this: Players are dealt cards with point values. Each player tries to reach a total of 21 without going over. Numbered cards count as their face value. An ace counts as either 1 or 11 (whichever is best for the player) and any jack, queen, or king counts as 10.

The computer is the dealer and competes against one to seven players. At the opening of the round, the computer deals all participants (including itself) two cards. Players can see all of their cards, and the computer even displays their total. However, one of the dealer's cards is hidden for the time being.

Next, each player gets a chance to take additional cards. Each player can take one card at a time for as long as the player likes. But if the player's total goes over 21 (known as "busting"), the player loses. If all players bust, the computer reveals its first card and the round is over. Otherwise, play continues. The computer must take additional cards as long as its total is less than 17. If the computer busts, all players who have not themselves busted, win. Otherwise, each remaining player's total is compared with the computer's. If the player's total is greater, the player wins. If the player's total is less, the player loses. If the two totals are the same, the player ties the computer (also known as "pushing"). Figure 9.1 shows off the game.

click to expand
Figure 9.1: One player wins, the other is not so lucky.




Python Programming for the Absolute Beginner
Python Programming for the Absolute Beginner, 3rd Edition
ISBN: 1435455002
EAN: 2147483647
Year: 2003
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net