My BullCow Wrapup (Extra Features)

For added features for Bulls and Cows, I added a difficulty menu where the player types out what kind of difficulty they would want. Depending on the difficulty, the player live will either increase two times or not. If you also win or lose, you will get the option to either play again with a new hidden word or quit by pressing escape (though only in editor).

I may add more(like revealing more hints about what the word is) but I feel proud!

2 Likes

How did you like the bull cow game section?

It was fun after going through it a second time. A lot of programming ideas were still new for me at the time I went through it, so I focused on understanding those ideas that I didn’t get (like structs) so that I can get the full picture. Now that I do, I enjoyed the course much more than before.

I have added one more feature before continuing forward with the course and that was by showing the players letters on their bulls and cows. I have gotten the idea from previous forums on showing the letters that the player has guessed for the bulls and cows and figured that it will help make the game feel more fun.

Hey Even i am looking for the same type of output …can you share your code… I am trying to create difficulty levels and would also like to know that how did you display Bull and Cow Letters. I am looking for an idea to structure my code. Right now my codes a bit scrambled and I’m not able to get an output like yours.
Thanks

For what I did with the difficulty, I made some declarations of the variables for easy and normal difficulty.
Once I set up the variables in the header files, I then created three functions in the header:

SetUpHiddenWordAndLivesEasy() SetUpHiddenWordAndLivesNormal() ProcessDifficulty()

These three functions will make up the bulk of how I did the difficulty select along with how forgiving or unforgiving the game is depending on what is chosen.

With that done, now comes the implementation. I usually leave the beginplay and Oninput as is since I feel there is no need to change the location of them. Everything else comes below the two starting functions.

What I do next is create conditional checks of if and else statements to check if the player has chosen easy or normal or if they have chosen anything at all. I feel it would be easier to show what I done but basically, its like what we did in the course for setting up the lives based on the hidden word but multiplying the lives if chosen easy or just not doing anything to the lives if chosen normal

This is where the bool values come in handy for the conditionals since depending if they are true or not, these lines of code will be executed depending if one or the other is true or false.

I am not sure if I have done a good job explaining it but I hope you got the idea for it. I’ll show how I got the bull and cows letters to display soon but right now I am a bit busy with stuff. Let me know how it goes and ask me anything if you need stuff to be cleared up etc.

1 Like

Thanks for the reply…I have some questions
Have you put ProcessDifficulty inside OnInput function which is taking all the input for all the game features like
ProcessGuess function which evaluates the guess by the player.

If so then have you created different if ...else if statements inside OnInput function which will not only check the reply for Difficulty of level but also evaluate the guess by the player for right or wrong.

Posting full code of your game might help me to understand that what was your approach for your game to work well and also help me to add some new features to the game my own way.

Here is my idea to add some features to the game:-
I have been trying to implement different ways in the code to create a level based word game just like we did in TripleX Game.

I have tried different ways to do it but somehow I get stuck in the code and get confused while creating a loop.

I want to increment the Level upto 5 where Level++ will also increase Number of letters in Hidden Word.

For Eg:

LEVEL 1
Guess 3 letter word
> bed
Level cleared
LEVEL 2
Guess 4 letter word
> cake
Level Cleared
.
.
.
LEVEL 5
Guess 7 letter Word
> bridges
YOU WIN...You are a CHAMPION.
Press ENTER to play Again

Well there are many more features to add but for now I’m trying to focus at incrementing Levels.

For a start I created a new Function which will control the number of letters per level and ++level will be done when Guess==HiddenWord .

I was thinking to create a code the same way we did in TripleX Game but I’m not sure that it will work because there we created one major function which contained all other functions and was compiled into main() and it had only one parameter of level Difficulty .

Upon seeing the screenshot shared by you Now I have started to think that maybe I can create different if...else if.. statements inside OnInput function which will increment the level and also evaluate the guess input of the player (Not sure if it might work).
Please share your thoughts…that might help me progress my work.

Thanks alot for your reply.

My apologies for a late reply, some stuff happened but now I got the time to reply. For the OnInput function I did created an If and else statements so that the program can determine if it was already chosen. Let me show you the OnInput Function here:

As you can see, I use a boolean check to see if either easy or normal was chosen or if it hasn’t been then it goes to process difficulty function using the Input parameter from OnInput.

I will send you another posts soon so that way it doesn’t look cluttered.

1 Like

Here is the screenshot of the source code for bullcow:

Here is the screenshot for the header files (not including the Hiddenword List):

As for increasing the difficulty by increasing the word count, you will need to do a different method from the one we were taught since we have a list of hidden word and are using a algorithm to randomize the list of valid words that we can use. My guess is that you may have to create different header lists depending on the difficulty that the player is on. So one header file heading let say three letter isograms, next header holding four letter isograms etc. I am not sure if it is THE best solution but that is a possible one I think that can help with what you want to do with the difficulty. I hope this helps and I hope all goes well.

1 Like

Thanks for your reply… That is a great piece of code.
The way you have used the bools and created extra features for level difficulty really inspired me to use the same trick to create features inside my code. It was really helpful as I was able to figure out the code by own.
The way you have used bools taught me the real deal with bools and how can we use them to our advantage at every point.

The problem for incrementing of levels is also solved… At first I messed up the whole code while creating Levels for the game but then I kept on trying to code the game in different ways and figured out the way to increment the levels.
In the final solution I incremented the the levels by creating an if else statement inside ProcessGuess function

void UBullCowCartridge::ProcessGuess(const FString& Guess)
{   
    int32 MaxLevel=5;        

        if (Guess == HiddenWord) 
        {        

            if(Level >= MaxLevel)
            {
                PrintLine(TEXT("You Win The Game"));
                Level = 1;
                EndGame();                
                return;
            }

            else
            {
                PrintLine(TEXT("Level Cleared")); //checking input                
                
                Level += 1; //declared in header file
                // PrintLine(TEXT("2: Level == %i"), Level);
                PrintLine(TEXT("\nLevel %i"), Level);
                SetupGame();             
                return;
            }
            
        }
        else
        {
            CheckGuess(Guess);
            return;
        }               
}

You may visit here to check out the features I have added:

Thanks alot :smile:

1 Like

No problem! Glad to be of help and that all went well! :smiley:

1 Like

Privacy & Terms