Greetings!
Just in the IF statements section here, I looked at it and thought there is likely to be a logic problem with the double loop, so I decided to use the std::string::find function instead and evaluate the results. The find function is very efficient, and this takes the place of the second loop and is more useful IMHO. I could be wrong - not necessarily the “world’s best programmer.” I do tend to be a bit brutish with coding.
My code:
[CODE]
void FBullCowGame::FindBullsAndCows()
{
BCCount.BullCount = 0;
BCCount.CowCount = 0;
for (int32 i = 0; i < CurrentGuess.length(); i++)
{
std::size_t Position = FString::npos;
Position = CurrentWord.find(CurrentGuess[i]);
//std::cout << "Char: " << CurrentGuess[i] << ", Position: " << Position << ", " << i << "\n";
if (Position == i)
BCCount.BullCount++;
else
if (Position != FString::npos)
BCCount.CowCount++;
}
return;
}
[/CODE]
NOTE: the commented cout was just so I could verify I had it correct, just debugging there.
Comments?
Jon