Blackjack Your task is to develop a C program that plays a game of 21. In partic
ID: 3768408 • Letter: B
Question
Blackjack Your task is to develop a C program that plays a game of 21. In particular, your program should satisfy the following requirements:
Playing cards are represented as variables of the following type:
typedef struct card_s {
char suit[9];
int value;
struct card_s *pt;
} card;
You are allowed to add attributes to this definition, but not to remove any.
The game is played using two decks of cards.
At the beginning load a predefined sequence of cards from a file. The card values should be at a separate file containing only integers. Then shuffle the deck
The deck is represented as a dynamic list of cards. The cards drawn from the deck are deleted from the list.
The player's hand is represented as a dynamic list of cards. The list is populated with the cards drawn by the player.
The dealer's hand is represented as a dynamic list of cards. The list is populated with the cards drawn by the dealer.
The player starts the game with $1,000. The game terminates if the player loses all his money.
The minimum bet is $20 and the maximum bet is $200. The system shall not allow the player to bet more than he has available.
The game rules are as follows:
The game proceeds in rounds.
Face cards (Kings, Queens, and Jacks) count as 10 points.
Aces count as 1 point or 11 points.
The player places his/her bet at the beginning of every round and before any cards are dealt.
Initially, the dealer and the player are dealt one card each, in the following order: player-dealer.
The card of the dealer is dealt face up
After the two cards are dealt, the player goes first. The player has the option of ‘“hit" (being dealt additional an card) or “stay" (terminate his turn). The player's objective is to bring his/her hand as close to 21 points as possible. The player's turn ends when the player stays, hits 21, or the player goes “bust” (goes over 21).
If the player hits 14, he is given the option to ”stay”. The dealer has to hit 21 to win a hand for which a player has chosen to stand at 14.
The dealer takes hits until his hand totals 17 or more points. The dealer cannot take a hit beyond 17.
In case the player has hit 14, the dealer continues to draw cards until he hits 21 or goes bust.
If the player does not go bust and his hand total is higher than the dealer's total or the dealer goes ”bust”, he/she wins the bet. If the dealer and the player have the same hand total, the bet is “pushed” (no win or loss). If the dealer has a higher hand than the player's hand, the player loses the bet.
Exceptions are made if 14 is hit by one of the parties. If player hits 14 and dealer hits 21, the dealer wins. If dealer hits 14, he wins. If dealer hits 14, while the player has also hit 14, the dealer has to continuously draw to hit 21, in order to win.
The deck is shuffled when less than 30 cards are left. The dealer's and the player's lists are deleted at the end of each round (memory is freed back to the system).
Explanation / Answer
program :
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.