Game Program. Not getting what i expected from all the work :(

sorry if this is not the right place. I am new.

This is Game called Mastermind. I have the description of the game on my progrAM. If you copy the code it completly works.

It just does not work :( .

Please help me. I will put your name and the website on the credits

Thanks in advance. Below is the code :)

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>

using namespace std;
// ***********************************Functions Delcarations




// Function 1 for the heading. It will just display the text.
void my_heading_displayer()


{
cout << "***********************************Mastermind********************************* " << endl;
cout << " " << endl;
cout << " Easy enough to understand " << endl;
cout << " " << endl;
cout << " I will give you the pattern of 4 colours. " << endl;
cout << " " << endl;
cout << " You have guess them in correct order in 10 tries " << endl;
cout << " " << endl;
cout << " The colours are Red, Yellow, Green, Blue, Orange, Gray " << endl;
cout << " " << endl;
cout << " Guess in the format RYGB " << endl;
cout << " " << endl;
cout << " " << endl;

}




// Functions 2 This Function will input the 4 guesses in form of an array and check if they are right

void guess_inputer(char guesser[], int n)
{
cout << "Enter your guess" << endl;
cout << " " << endl;
cin >> guesser[0] >> guesser[1] >> guesser[2] >> guesser[3] >> guesser[4];

// Looping it 4 times because we need to input 4 characters


for (int m = 0; m < 4; m++)
{
if (guesser[m] > 91) // lower case level
guesser[m] = guesser[m] - 32;
}


}

// Function 3 is how many right at position and how many right but at wrong spot.
// Two arrays. One is my loving guesser from before and another is right which che kts right spots.
// It is bool because we need to check the true and false for the colors and positions.

bool right_guesses_displayer(char guesser[], char check_right[])
{
int rightcolour=0;
int completeright=0;
int count;
bool variable1[4];
bool variable2[4];
bool variable3=false;


for (int m=0; m < 4 ; m++) // I want to access the values of my array from 0 to 1 using this loop.
{
variable1 [m]= false;
variable2 [m] =false;

}
// My loop which determines the colors in exact position
for (int m = 0; m < 4; m++)
{
if (guesser[m] == check_right[m])
{
rightcolour++;
variable1[m] = true;
}
}

// Following nested loops determine the colors right but in wrong place

for (int m=0 ; m < 4; m++)
{
if (!variable1[m])
{
for (int k = 0; k < 4; k++)
{
if (!variable1[k] && m != k)
{
if ((guesser[m] == check_right[k]) && !variable2[k])
{
variable3 = true;
count = k;
}
}
}
}

}








}







// ******************************************** Function Declaration ends********************************************
int main()
{

char symbol;
char guess[4];
char right[4];
bool playAgain = true;
bool won;
int numGuesses;

my_heading_displayer();

while (playAgain) {
won = false;
numGuesses = 10;

cout << endl;
// generate the correct random sequence
srand(time(0));
for (int m = 0; m < 4; m++)
{
int temp = (rand() % 6) + 1;


}
cout << endl;

// loop until the user gets the right value
while (!won && numGuesses > 0)
{
guess_inputer(guess, numGuesses);
won = right_guesses_displayer(guess, right);
numGuesses--;
}

if (won)
{
cout << "You win! The correct sequence was " << right[0] << " "
<< right[1] << " " << right[2] << " " << right[3] << endl;
}
else
{
cout << "You lost! The correct sequence was " << right[0] << " "
<< right[1] << " " << right[2] << " " << right[3] << endl;
}

cout << "Would you like to play again (Y or N): ";

cin >> symbol;

playAgain = (symbol == 'Y' || symbol == 'y') ? true : false;
}



system("PAUSE");
return EXIT_SUCCESS;

}

bump!!
Is the problem you are having that no matter what, the second guess is always a 'Correct' answer, despite it being any order or even random letters? Or are there any other problems you want to point out?
I thiink that is the problem. And also may be the problem is about converting integers to colors.
bump!. Still does not work
"Does not work" isn't very descriptive.

What doesn't work?
OK so the thing is that everytime I enter my guess it give me a upside down smily face and couts coorect answer.

I dont know where the mistake is. If I did i could solve it myself.
Topic archived. No new replies allowed.