Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lets play Dirty Dice The assignments objective is to create a C++ based game in which one player (the user) competes against the computer where

Lets play Dirty Dice The assignments objective is to create a C++ based game in which one player (the user) competes against the computer where each player tries to steal the points from the opponent. Each player starts out with 100 points. The game is won by the first player to reach a set number of points. The number of points required to win the game is to be inputted by the user. Each turn, the player (human or computer) repeatedly rolls a dice until either a 3 is rolled or the player chooses to hold. If player chooses to hold, the sum of the rolls (i.e. the turn total) is calculated. At any time during a player's turn, the player is faced with a binary decision: 0. roll - If the player rolls a a. 3: the player steals 3 points from the opponent and it becomes the opponent's turn. b. 1, 2, 4, 5, 6: the number is added to the player's turn total and the player's turn continues (i.e. gets to roll again). 1. hold - The turn total is calculated. The points are subtracted from the opponents score and added to the current players score. It becomes the opponent's turn. Check whether a winner has been established at the end of every turn. The player who takes the first turn in the game is chosen randomly. Do NOT use: global variables, arrays, pass by reference functions, or pass by pointer functions. NOTE: if your C++ file does not compile with standard g++ compiler in Jupyter Hub you will get a zero on the C++ portion of the assignment (no partial credit). This will be the case with all C++ assignments going forward. Requirements: 1) Your program should contain the following three functions (besides the main function, of course): roll - takes in nothing. Returns a random int between 1 and 6. oneTurn - takes in a single boolean variable to indicate whether its users or computers turn (e.g. 1 = human turn, 0 = computer turn). Plays out the entire turn until player either rolls a 3 or chooses to hold. Returns the turn total as an integer value. (Note: this function should be calling the r oll function). The computer player should: Roll until it reaches at least some minimum turn total Have some randomness in its decision making Be capable of rolling or holding past the minimum loopGame - takes in a single integer value for game points goal (i.e. the number of points player needs to reach to win the game). Continues to repeat until either computer player or human player has won. Returns a boolean value (1 = computer win, 0 = human win). (Note: this function should be calling the oneTurn function). 2) Your program should interactively display the player and the computer choices, the dice rolls, the running turn total and the running score after each turn. 3) You will need to use randomization for this assignment. Make sure you are seeding the randomizer so your program doesnt end up generating the same pseudorandom sequence every time. 4) For interacting with the user, you must use cin and cout.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions