Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c programming A deck of poker cards are used. For simplicity, we have unlimited number of cards, so we can generate a random card without

c programming

image text in transcribed

image text in transcribed

image text in transcribed

A deck of poker cards are used. For simplicity, we have unlimited number of cards, so we can generate a random card without considering which cards have already dealt, The game here is to play as a player against the computer the dealer). The aim of the game is to accumulate a higher total of points than the dealer's, but without going over 21. The cards 2 to 10 have their face values as points. 1, 2, and Kare 10 points each, and the Ace is either I point or 11 points (player's choice). To simplify the matter, we consider that the Ace is 11 points and we don't have card J, Q, or K unless you like to implement the option anyway. a) Betting The player first places a bet. Lets assume the minimum bet is S10 and maximum - is S1000. b) Each play will result in one of the following events for the player Lose -- the player's bet is taken by the dealer. Win -- the player wins as much as the bet. It's/he bet S= 10, she wins $10 from the dealer. Blackjack - the player wins 1.5 times the bet. With a bet of S10, she wins Sis from the dealer. To simplify the matter, you can ignore Blackjack. Push - the hand is a draw. The player keeps his/her bet, neither winning nor losing money. c) The start of the game At the start, the player and the dealer receive two cards each. The player's cards are normally dealt face up (displayed), while the dealer has one face down (called the hole card) and one face up. The best possible blackjack hand is an opening deal of an Ace with any of the ten-point cards. This is called a "blackjack", or a natural 21, and the player holding this automatically wins unless the dealer also has a blackjack. If a player and the dealer cach have a blackjack, the result is a push. d) The player's turn The player can keep his hand as it is (stand) or take more cards from the deck (hit), one at a time, until either the player judges that the hand is strong enough to go up against the dealer's hand and stands, or until it goes over 21, in which case the player immediately loses (busted). e) The dealer's turn The dealer turns over the hidden hole card. The dealer hits (takes more cards) or stands depending on the value of the hand. The dealer must hit if the value of the hand lower than 17, otherwise the dealer stands. If the dealer is busted, the player wins. Otherwise the player wins if she has a higher scorc, loses if she has a lower scorc, or pushes if she has the same scorc as the dealer. Blackjack consideration is not required, unless you like to implement the option anyway. By the way, a blackjack hand beats any other hand, also those with a total value of 21 but with more cards (which is not a natural blackjack). f) The program towards the end If the player won or lost, s/he must decide whether to quit or to play another game unless the player runs out of moncy. Your program should give the player an initial betting amount of $1000.00. 2. The specific design of this project a) The main program and its variables You will need to decide on appropriate variables in which to store the player's bankroll (in order to keep track of how much money or how many points the player has), the bct at a game, and other information, Let's use an integer array gamcrecord[] to store how many times the player won, lost, hit a blackjack, and got busted. (Again, blackjack is optional) The bankroll, bct, and gamcrccord[] should be kept up to date on the player's current status. (Thc program calls playing to play a game, as discussed below.) After each game, the program must report the result of the game: the amount of money won or lost, the current value of the bankroll, how many times the player won and lost, and how many times the player hit a blackjack and got busted. (You may want to record and report how many times the dealer got busted as well as an option.) After each game (by calling playing), the program should allow the player to continue playing until she chooses to quit, or until s/he runs out of money. This central program control may be done within maino, in a do- while loup: 1) call playing to play a game; 2) check whether to play again. We will add some more components later. b) "Dealing" the card: the dealing function A separate dealing() function will be used to generate a card number. You may want to implement and double check this function first. You will use a random number generator. The random number generator needs to be seeded with the current time at the beginning of the main program. The possible random values generated are 1 to 10 (or 13 if J. Q, and K are considered), representing the cards' face values. This function will return the number generated. The return value 1 represent the Ace's face value (and the return value 11, 12, and 13 are J. Q. and K's face value, respectively.) A large random number n can be converted to a value between 1 to 13 by: (1 + %13), c) "Playing" the game: playing function A second function playing will be used to play a single game until the player either wins or loses a bet, based upon the rules given above. This function should get a bet, modify the current amount of the player's bank roll according to the game result, modify the garnierecord array values of the player won or lost, and the player hit the blackjack or got busted. These values are related through Cunction paratieters by address passing in playing(). Within the function, the player is asked to place a bet (10 to 1000 within the bankroll amount), so the corresponding value is read from the keyboard. The system (dealer) then "deals the cards" (simulated by calling the function dealing, one card at a time). After each dealing, this function should report the card values, except the dealer's hole card. The function should have two variables to store the player and the dealer's scores. Remember face value 1 represents score 11 (or 1 if you want to be more complete as an option, and 11, 12, or 13 represents scorc 10). The player can keep his hand as it is (stand) or take more cards from the deck (hit), one at a time, until cither the player judges that the hand is strong enough to go up against the dealer's hand and stands, or until it goes over 21, in which casc thc player immediately loses the bct. The dealer turns over his hidden hole card by displaying the hold card face valuc, and starts the game process automatically until the dealer wins or loses. d) "Ending" and "Beginning" of the game This part is implemented after you have done your programming as described above already. You need a separate function ending to do the following: you should report the current value of the bank roll, how many times the player won, lost, hit a blackjack, and went busted. You need information into a text file as well. save the above You need a separate function beginning to do the following at the beginning of your program in main(): the function will open the text file you used to save the game information for reading if it exists, so that your game can continue from previous played results. If the file does not exist or the bank roll has a balance below the minimum bet, you start the game from scratch as usual, and report "new game" or "continual game". So, main() includes 1) beginningO; 2) a loop: playing(); 3) ending()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

Show that var(Y 1 ) = 1 .

Answered: 1 week ago

Question

(d) Verify that Var() = 2 /ss * xx and Cov(Y i ., ) = 0.

Answered: 1 week ago