Brain Scan Bot (NumWiz reskin)

Here are some images from my stand alone.



I added a second button to the last scene. Play again immediately launches the core game and Flee sends you back to the start scene.

I did find an interesting bug in the ‘NextGuess()’ function

        {
        guess = Random.Range(MaxGuess + 1, MinGuess);
        guessText.text = guess.ToString();
        }

was causing the button to not respond when the guess was 1 higher than the number chosen.
For example, if the number was 250 the high/low buttons stopped responding at 251.

My solution was to write a new function that fires at the top of the game called firstGuess() that has the full range then switch to nextGuess().

Is there a better way?

  void nextGuess()
        {
        guess = Random.Range(MaxGuess, MinGuess);
        guessText.text = guess.ToString();
        }

    void firstGuess()
        {
        guess = Random.Range(MaxGuess + 1, MinGuess);
        guessText.text = guess.ToString();
        }

2 Likes

Hi Thomas,

I really like your images, the robot is really cute, reminds me of Wall-E, but more confused :slight_smile:

Regarding the error, it’s a bit difficult to say without stepping through the problem, the buttons would stop responding if you had thrown an exception (error) however. Also, I note that you have your Max and Min in reverse order. As it happens this doesn’t really matter in this scenario, but be aware of things like this going forward as you may get unexpected results.


See also;

Thanks for the feedback Rob.

I’ve made the min max change you suggested and will be keeping an eye on that in the future

1 Like

Hey Thomas,

You’re very welcome :slight_smile:

With regards to your issue, you could always see if you can reproduce it, e.g. create a set of steps that make the issue occur, and then use a series of Debug.Log statements to help identify where the error occurs.

If you need any help with this, feel free to ask :slight_smile:

Where would I insert the Debug.Log to find the error? I’ve found that I can force the max guess to climb past 1000 and cycle through 1,2,3, and 4 if I hit higher/lower until I reach either extreme and then continue to press higher and lower in turn.

I’ve commented out my firstGuess() method because i dont think it is doing anything.

    void Start()
        {
        startGame();
        }

    void startGame()
        {
        //firstGuess();
        nextGuess();
        }

    public void onPressHigher()
        {
        MinGuess = guess +  1;
        nextGuess();
        Debug.Log(guess);
        }

    public void onPressLower()
        {
        MaxGuess = guess - 1;
        nextGuess();
        Debug.Log(guess);
        }

   void nextGuess()
        {
        guess = Random.Range(MinGuess, MaxGuess + 1);
        guessText.text = guess.ToString();
        }

    /*void firstGuess()
        {
        guess = Random.Range(MinGuess, MaxGuess + 1);
        guessText.text = guess.ToString();
        }*/

}

Hi Thomas,

My apologies for the delay in responding, I lost sight of this topic.

With regards to where I would put them where-ever you change the values. What I would then do to debug the game would be to work with the edge-cases first. So, perhaps with a pen and paper also, play your game and just go “higher” constantly until you can’t go any further. Make a note of all of the values that are appearing on each press of the button, and check that they are what you would expect.

I would then do the same test but clicking “lower” constantly, until again I reach the edge, making a note of the output and seeing what happens.

You may find that you only want to call your nextGuess method under certain circumstances, if so, you can add some logic via if statements perhaps to only call it under those conditions.

Assuming you haven’t already resolved your issue, if you want to publish a WebGL version of your game and pop the link up I will happily play your game and provide some detail of what I encounter also, although I won’t be privvy to the value of your variables during the game, only what is presented to the screen. Just let me know :slight_smile:

Privacy & Terms