Hello!
I was thinking about enhancing experience of “getting to the right number” in Number Wizard UI. Using Random() it may sometimes take too long for user to get to the right number, while using our previous method of (higher_guess + lower_guess)/2 seems too rigid, though it is faster.
So I have an idea to make it like this: first 3 guesses (or so) are random, and then we get the rigid method till the end. So first it feels like true guessing and then it gets straight to right answer in shortest (logically speaking ;)) way.
So my question is, how do I program that? Some hints? Should I be able to do it knowing as much as far (I just have finished Number Wizard UI part) or it will be clearer to do something like that after going deeper into the course?
Let’s see code as far:
public class NumberWizard : MonoBehaviour
{
[SerializeField] int max;
[SerializeField] int min;
[SerializeField] TextMeshProUGUI guessText;
int guess;
// Start is called before the first frame update
void Start()
{
StartGame();
}
void StartGame()
{
NextGuess();
}
// Update is called once per frame
public void OnPressHigher()
{
min = guess + 1;
NextGuess();
}
public void OnPressLower()
{
max = guess - 1;
NextGuess();
}
void NextGuess()
{
guess = (Random.Range(min, max + 1));
guessText.text = guess.ToString();
}
}