My Implementation of HiddenWord from Random Selection from WorldList

after i added WordList into BullCow cpp file, i also set the HiddenWord from a random selection from the WordList.

the UnrealMathUtility header file has a FMath::RandHelper(int 32 A) function that takes a int32 Number and returns a random number between Zero and Number
I set the HiddenWord = WordList but i had give an Index to one of words in the Array so that number comes from the RandHelper(). That RandomHelper takes a number and i set that equal to max number of elements in the Array (size of Array). So everytime it gives a different number. I will try a different seed() function because everytime you restart the game it may give the same sequence since we give a fixed number. Maybe a uniform distrubition kind of function. Anyway the code is below

you have to include the below header file into BullCowCartridge.cpp file

#include “Math/UnrealMathUtility.h”

then revised the SetUpGame() function as below (See specifically HiddenWord=…)

void UBullCowCartridge::SetupGame()
// welcome message
PrintLine(TEXT(“Welcome to BULLCOW GAME”));

HiddenWord = WordList [ FMath::RandHelper( WordList.Max() ) ];
Lives = HiddenWord.Len();
bGameOver = false;

PrintLine(TEXT("Guess the %i letter hidden word"), HiddenWord.Len());
PrintLine(TEXT("You have %i lives"), HiddenWord.Len());
PrintLine(TEXT("Type your guess \nPress enter to continue..."));