The project is to create a 2-player game of dice.
The user selects the number of rounds to be run. Each dice round consists of 3 values:
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:
At the end of all rounds, the player with the highest points wins the game.
Write the following functions that uses the game rules described above:
P1: 200
P2: 100
Type : BONUS
DICE : 4
POINTS : 200
############### RUN-1 ###############
Enter the number of rounds: 5
P1 : 0
P2 : 0
ROUND 1
--------
Player : 1
Type : REGULAR
Dice : 5
Points : 70
P1 : 70
P2 : 0
ROUND 2
--------
Player : 1
Type : REGULAR
Dice : 2
Points : 50
P1 : 20
P2 : 0
ROUND 3
--------
Player : 2
Type : DOUBLE
Dice : 4
Points : 180
P1 : 20
P2 : 180
ROUND 4
--------
Player : 2
Type : DOUBLE
Dice : 3
Points : 140
P1 : 20
P2 : 40
ROUND 5
--------
Player : 1
Type : DOUBLE
Dice : 3
Points : 180
P1 : 200
P2 : 40
GAME OVER!!
P1 Won
############### RUN-2 ###############
Enter the number of rounds: 5
P1 : 0
P2 : 0
ROUND 1
--------
Player : 2
Type : REGULAR
Dice : 6
Points : 40
P1 : 0
P2 : 40
ROUND 2
--------
Player : 2
Type : BONUS
Dice : 3
Points : 200
P1 : 0
P2 : -160
ROUND 3
--------
Player : 1
Type : BONUS
Dice : 4
Points : 200
P1 : -200
P2 : -160
ROUND 4
--------
Player : 2
Type : REGULAR
Dice : 5
Points : 20
P1 : -200
P2 : -180
ROUND 5
--------
Player : 1
Type : DOUBLE
Dice : 6
Points : 100
P1 : -300
P2 : -180
GAME OVER!!
P2 Won
// Add all the includes for the required header files
// Start the main() function with both the parameters
int main()
{
int player1Points;
int player2Points;
int numRounds;
int round;
int roundPoints;
int currentPlayer;
int dice;
ROUNDTYPE roundType;
// Initialize the srand() to start the random generator
// Initialize the player-1 and player-2 points to 0
// Initialize all other required variables
// Ask the user for the number of rounds to run the game
// Call printPlayerPoints() function to print the initial player points which will be 0
printPlayerPoints(player1Points, player2Points);
// Set up the loop to go through all the rounds one at a time
for(round = 1; round <= numRounds; round++)
{
// Call the corresponding functions to get the information for this round - type, dice, points
// Print round number
// Print current player
// Call printRoundInfo() to print the round information
// MAIN GAME LOGIC
// Write code here to get the main game logic using branches
// 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 player’s 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.
}
// Call printPlayerPoints() to print the player information at the end of the round
}
printf("\nGAME OVER!!\n");
// Compare the final points for player-1 and player-2
// Print the winner as the one with higher points
// Return from the main() function to end the program successfully
}