Question
C++ question Create a program that can simulate randomly rolling dice for the game of Yahtzee. This game is fairly complex but our program will
C++ question
Create a program that can simulate randomly rolling dice for the game of Yahtzee. This game is fairly complex but our program will only look for full houses (two and three of a kind of different numbers). To simplify the programming logic, the user has to decide which type of full house they want before the simulation starts! Furthermore, the program must simulate 10,000 Yahtzee turns! The key idea is that you have three rolls every simulation turn and you always start with five dice each turn. Each roll consists of throwing however many dice you have left (dont roll a dice again that you have decided to keep!) Here is an example of 1 simulation turn with three rolls and the user is looking for a full house of 5s and 6s: Roll 1: 5 4 5 5 3 Roll 2: 5 6 Roll 3: 6 Roll 1 starts with 5 dice and the user has three 5s which are kept and not rolled again. On roll 2, the user gets another 5 but already has a three of a kind in 5s, so only the 6 is kept. Finally, on roll 3, the user rolls another 6 for a full house of three 5s and two 6s
I don't know why my code does not work
Below is my code:
#include
#include
#include
using namespace std;
int main(){
double XXX=0,YYY,ZZZ,seed,Y2,Z2,kk,jj,qq=1;
cout<< "Enter two dice for full house: ";
cin >> YYY >> ZZZ;
cout << "Enter seed value: ";
cin >> seed;
uniform_int_distribution<>dist(1,6);
int dice = dist(engine);
for(int ii=1;ii<10001;ii++){
qq=1;
for(jj=1;jj<4;jj++){
for(kk=qq;kk<6;kk++){
if(dice==YYY||dice==ZZZ){
if(dice=YYY){
Y2++;
qq++;
else{
Z2++;
qq++;
}
}
}
}
if(Y2==2 && Z2==3){
XXX++;
}else if (Y2==3 && Z2==2){
XXX++;
}else{
XXX=XXX+0;
}}
cout <<"Simulation found "< return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started