Question: 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
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:
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).
hold - The turn total is calculated, the points are subtracted from the
opponents score, and it becomes the opponent's turn.
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).
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.
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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
