Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a coding question last time the answer I was given was wrong this is C++ coding question I want the source code from

This is a coding question last time the answer I was given was wrong this is C++ coding question I want the source code from CodeBlocks please
image text in transcribed
image text in transcribed
image text in transcribed
3My Blackboard Content-Bkx Uplioad Assignment P: The Gx+ mode-view suny ed grmentupkadasignrert?content id759593_1&course id-963511&group,id The following program will heavily utilize the concept of nested loops. Be sure you are comfortable with this concept before beginning. Write a C++ program that plays the game of Pig, where one player is a human and the other is the computer (From here on referred t as Al Artificial Intelligence). The game of Pig is a sismple two-player dice game in which the fint player to reach Nor more points wins. You can specify the game thuresbold traditionally the gase is played to 100 but that woold make testing an debogging arduous. Using a lower threshold allows for more timely testing. This is a turn based game. On each turn, a player rolls a single six-sided die. This dice roll determines which of the two following actions wil If the player If the player rolls a 2 through 6, then s/he can either rolls a 1, thes the player gets no new points and the garme switches turns to the other player Coatinue theis turn and ROLL. AGAIN, accumulating the points for that turm on the dice roll or Shop their turm and HOL.D. If HOLD is chosen the the gamse switches turns to the other player sam of all previous rolls on this turn is added to the player's overall scere and To more deeply familiarize yourself with the game functionality you can play a graphical version here Your version of PIG will be When it is the baman's turn, the program sbould a console game, meaniag all game output will be displayed to the console in basic text. show the curreet score of bodh playors asd the currene roll Be sure to add souse lioe breaks to make the display rosier to Allow the human to input"or "R" to roll again r b or H so hold Your gase med han dle both cases (upper and lower case). This inpat must ahuo be validated, providiag the player with an ualimited ancent of att the player eaters a"."n respouse to this question the progrm should say heald be a tempts to eater the correct value. That ameans ir That in an lacerrect eutry. Try agais:and they as many chances as needed to enter the correct value, (use a while loop for this) The Al should fenction according to the Bollawing rule 8 suny.edu/wel uplondAssignment content id- 759593 18course id 96351, 18igroup id-8modes-view The AI should fonction according to the following rule until it has accuenulated 20rmre points for that turm, then HOLD. If the Al wins or rolls a I, then the turn ends immediately, just like the human player . When there is a winner the game should immediately announce which party won. .A dice roll can be simulated with a random number between 1 and 6 srandtimeo) "nil-rand( ) % 6 + 1; the playe unlimited amount of attemepts to enter the correct Game Architectare: The idea of being able to play multiple games can be coatrolled by a while loop The condition can be expressed as "As long as wants to play again The player should be asked if they would like to play again This should occur been determined. This input must also be validated, providing the player with an IMMEDIATELY when a victor has A "Tarns" cas be implemented using a nested while loop You will need a while loop to control the human's turm and anodber while loop (at the same level, not aested) to centeol the Al loop The human's while loop coadition cam be esxpressed as "As long as the dice roll is not a one and the bomas chooses roll again" . The Al while loop condition can be expressed as: "As keg as the dice roll not a one and the accumulated tum points are less than Game Archnecture Skeleton W Control multiple games whileiplayer wants to play agaln) Costrol asingle gme Define variables seeded for a single gse whileigame has sot bera woa 5 6 7 8 tc3bb.open.suny.edu/webapps/ content id-759593 18course id- 96351 18group id-8mod while(player wants to play again) /Control a single game Define variables needed for a single game while(game has not been won) /human turn while(dice roll is not a one and the human chooses roll again) roll dice accumulate points ask for Roll or Hold while(data is not valid make them try again) AI turn while(dice roll is not a one and the accumulated turn points are less than twenty) roll dice accumulate points l/determine game status Did someone win? How do you know? //play again? ask if the player wants to play again. Validate the input Extra Challenges (THESE ARE NOT REQUIRED): Simulate a coin flip to see who goes first. Allow the human to call heads or tails Allow the user to specify the point total for a win ADVICE Build this application one piece at a time AND TEST THOROUGHLY AS YOU GO! 2 Then do the haman turn and make sure it works 3 Then do the Al turn and make sure it works ASSIGNMENT-SUBMISSION. When finished, make sure to click Submit Oprionalily, dlick Save as Dret to save changes and contimur working later, or olick Cancl to quit without saving chengs e here to search Esc F3 FS F6 F7 Fe F9 F10

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions