Project 2: Baccarat

Due: Monday, October 17th

 

 

Introduction

 

Baccarat is a card game that resembles Blackjack.  Two players, referred to as the player and the banker get dealt two cards each. The player that comes closest to having a hand total of 9 wins. Before the hands are dealt, bets may be placed on the banker hand, on the player hand, or on a tie. No matter how many players there are, there is only one hand representing all of them dealt.

 

Hand Value

 

All Tens and face cards (jack, queen, and king) are worth zero. The ace is worth "1" and the Two through Nine are worth their face value.

 

Card suits have no meaning in Baccarat.

 

The total of the hand, regardless if it consists of two or three card, is determined by summing up the values of the cards in the hand.

 

If the total of the hand is 10 or more, 10 must be subtracted. The remaining total is the card count.

 

Drawing Rules

 

The dealer gives two cards each to the player and the banker.

1.      If either the player or the banker has a total of an 8 or a 9 they both stand. There are no exceptions and this rule overrides all other rules.

2.      If the player has total of 6 or 7, the player stands.

3.      If the player stands, the banker hits on a total of 5 or less.

4.      If the player has total of 5 or less, the player automatically hits and the banker gives the player a third card.

 

If the player gets a third card because of rule 4, the following table summarizes the action of the banker:

 

 


 

Banker's
Total

Player's Third Card

0

1

2

3

4

5

6

7

8

9

7

S

S

S

S

S

S

S

S

S

S

6

S

S

S

S

S

S

H

H

S

S

5

S

S

S

S

H

H

H

H

S

S

4

S

S

H

H

H

H

H

H

S

S

3

H

H

H

H

H

H

H

H

S

H

2

H

H

H

H

H

H

H

H

H

H

1

H

H

H

H

H

H

H

H

H

H

0

H

H

H

H

H

H

H

H

H

H

 

What you need to do

 

Write a program that plays the game of Baccarat according to the rules above.

1.      Ask the player his or her name

2.      Then ask them if they would like to bet on the player winning, the banker winning, or there being a tie. 

3.      Next, deal 2 cards and calculate the hand total as described above.

4.      Then follow the rules above to determine whether to give each player a third card.

5.      Tally the two or three cards for each hand, and determine a winner.

6.      Finally, display whether the bet placed at the beginning was correct, and ask if the player would like to play again.

 

You may consider there to be an infinite deck of cards, however the probability of getting a face card must be correct.

 

Submission

 

Submission will be the same as in project 1, create a directory, tar it, and then copy it to ~jrmst106/submit

 

Additional Work (not required, carries no credit)

 

If you would like to attempt to do more on this project, here are some ideas: