Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

> In C Language create a 2-player game of dice. Game Rules: The user selects the number of rounds to be run. Each dice round

> In C Language create a 2-player game of dice.

Game Rules:

The user selects the number of rounds to be run. Each dice round consists of 3 values:

Dice value of the dice rolled. It is a random number between 1-6.

Points value associated with the round. It is a random number from 10-100 in multiples of 10. (10 * random number between 1-10).

Type the type of the round. There are 3 types of rounds:

REGULAR keep the points equal to the number of points as calculated above using a random number generator.

BONUS replace points to be equal to 200.

DOUBLE update points to be equal to DOUBLE the number of points as calculated above using a random number generator.

Probability of the round types:

20% for BONUS, 30% for DOUBLE and 50% for REGULAR

The game consists of two players (1 & 2). The game starts with one player at random.

For each round, one of the following cases can occur:Success: Player-1 (odd player) is the current player and the dice rolled is odd OR Player-2 (even player) is the current player and the dice rolled is even.

Current player gains the points, based on the type of the round (see above). The current players turn continues in the next round.

Failure: Player-1 (odd player) is the current player and the dice rolled is even OR Player-2 (even player) is the current player and the dice rolled is odd.

Current player incurs penalty of the same number of points, based on the type of the round (see above). In the next round, the current player is changed to the other player.

At the end of all rounds, the player with the highest points wins the game.

image text in transcribed

Main.c file below

image text in transcribed

Task 1: Complete the main.c - Download the attached main.C - Follow the instructions written in the comments in the main () function. The main () is the driver of the program. It calls the functions below to play the game. Task 2 - create and write dicegame.h - Include the header guard in the correct format. - Create an enum named ROUNDTYPE to identify the three round types: - BONUS, DOUBLE, REGULAR - Write all the function prototypes - see Task below. Task 3 - create and write di cegame.c. Write the following functions that uses the game rules described above: - int getRandomNumber ( int min, int max ) - This function computes a random number between min and max, inclusive, and returns it. - ROUNDTYPE getRoundType (1) - This function decides the type of the round based on the probability values mentioned in game rules (20\% for BONUS, 30% for DOUBLE and 50\% for REGULAR). HINT: Use the getRandomNumber () function to generate a random number between 0 through 9 and use this value for probability. - int getRoundPoints ( ROUNDTYPE roundType ) - This function calculates and return the points associated with the given round type, based on the rules mentioned above. You will need to call the getRandomNumber () function to generate the points randomly. - void printPlayerPoints ( int p1, int p2 ) - This function prints out the player points at the end of each round in the format shown below: P1: 200 P2: 100 - void printRoundinfo( ROUNDTYPE t, int dice, int points ) This function prints out the information for each round in the format shown below: Type : BONUS DICE :4 POINTS : 200

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

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions