Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to complete an assignment for my c++ course and I am stuck. Here are the directions: Liars Dice is a multiplayer dice

I am trying to complete an assignment for my c++ course and I am stuck. Here are the directions:

Liars Dice is a multiplayer dice game with a minimum of two players and no upper limit on the number of participants. The goal is to make a correct guess or correctly call another player a liar. This article states the rules of Liars Dice as follows: The first player calls out two numbers: first, how many dice on the table he or she thinks have been rolled as a number between one and six. For example, player one could say two fives, which means he or she thinks there are at least two dice that are fives among all the players dice (including his or her own). o At this point, all players can accept what has been called out and move on to player two or call player one out, which will end the round and result in a winner or loser for the round. If player one calls out two fives, it does not matter whether player one has a five or not as bluffing is allowed in Liars Dice. It only matters if another player believes player one is bluffing and calls him or her out on it. In that instance, all dice must be revealed. If player one is correct, the player wins. If player one is wrong, then the player who called him/her out is the winner. The round is then over. If player ones call is accepted, then player two calls out a number. The first number must be greater than what player one called. For example, if player one called out two fives, player two must call out three or higher for his or her first number, so three fives, three fours, or four twos would all be acceptable. One five or two sixes would be unacceptable. Game play continues until someone is called out.

I have tried to write a simple procedural program without using Classes and Opjects, but I'm not sure. I need a fresh set of eyes. Here is what I have so far.

#include "stdafx.h"

#include

#include

#include

#include

#include

using namespace std;

int number = 0;

int choice = 0;

int players[] = { 0,0,0,0,0};

int diceRoll[5] = {};

int main()

{

srand(time(NULL));

bool callOut = false;

cout << "How many players?" << endl;

cin >> number;

while (number >= 2)

{

int x, y;

srand(time(NULL));

int rollOfDice = 0;

for (x = 0; x <= number; x++)

{

for (y = 0; y < 5; y++)

{

rollOfDice = (rand() % 6)+1;

diceRoll[y] = rollOfDice;

}

players[x] = diceRoll[y];

}break;

}

while (!callOut)

{

cout << "First player call out how many dice have been rolled out on table" << endl << endl;

cout << "Second player type 1 if you believe player one or 2 if you don't" << endl << endl;

cin >> choice;

if (choice == 1)

{

callOut = false;

}

else

{

for (int i = 0; i < number; i++)

{

for (int j = 0; j < 6; j++)

{

cout << "player " << players[i] << " rolled " << diceRoll[j] << endl;

}

}

callOut = true;

}

}

if (number < 2)

{

cout << "Must choose 2 or more players" << endl;

}

cout << "End of game" << endl << endl;

return 0;

}

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago