Skip to content

Instantly share code, notes, and snippets.

@JackDraak
Created January 24, 2016 03:37
Show Gist options
  • Save JackDraak/b0e2329e4d270d63dcaa to your computer and use it in GitHub Desktop.
Save JackDraak/b0e2329e4d270d63dcaa to your computer and use it in GitHub Desktop.
excerpt
// output - after a guess is validated, print the results: Guess# of #, Bull# Cow#
void PrintTurnSummary()
{
// TODO logic for hint "hacker" levels... 0 = neophyte (none), 1 = cowtips only, 2 = bulltips only, 3 = bulls+cows, 4(?) = exclusions
FBullCowCounts BullCowCounts = BCGame.ProcessValidGuess(BCGame.GetGuess());
FString GameWord = BCGame.GetRankedIsogram();
FString Guess = BCGame.GetGuess();
int32 GameWordLength = GameWord.length();
FString MyCowsHint = "";
FString MyBullsHint = "";
for (int32 GameWordCharPosition = 0; GameWordCharPosition < GameWordLength; GameWordCharPosition++)
{
for (int32 GuessCharPosition = 0; GuessCharPosition < GameWordLength; GuessCharPosition++)
{
char GameWordChar = GameWord[GameWordCharPosition];
char GuessWordChar = tolower(Guess[GuessCharPosition]);
if (GuessWordChar == GameWordChar)
{
if (GameWordCharPosition == GuessCharPosition)
{
MyBullsHint.append(1, GameWord[GameWordCharPosition]);
}
else
{
MyCowsHint.append(1, GameWord[GameWordCharPosition]);
}
}
}
}
std::random_shuffle(MyCowsHint.begin(), MyCowsHint.end());
std::cout << "\n Guess Result #" << BCGame.GetTurn() << " of " << BCGame.GetMaxTries() << ": " << Guess << " has ";
if (!bBullHints) { std::cout << BullCowCounts.Bulls << " Bulls and "; }
else { std::cout << "-" << MyBullsHint << "- Bulls and "; }
if (!bCowHints) { std::cout << BullCowCounts.Cows << " Cows\n"; }
else { std::cout << "-" << MyCowsHint << "- Cows\n "; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment