jeudi 24 décembre 2015

Generate fake answers for a math calculation

I am making a quiz like game where I generate math expression and then I generate plus two fake answers given the result of the generated math expression. So user sees the math expression and is given three answers from which he need to choose the right one.

So far I have

switch(opIndexValue)
{
    case Helper.CASE_ADD:
        answer1 = resultValue + Random.Range(1, 4);
        answer2 = resultValue - Random.Range(1, 4);
        break;
    case Helper.CASE_SUBTR:
        answer1 = resultValue + Random.Range(1, 4);
        answer2 = resultValue - Random.Range(1, 4);
        break;
    case Helper.CASE_MULTI:
        answer1 = resultValue + Random.Range(1, 4);
        answer2 = resultValue - Random.Range(1, 4);
        break;
    case Helper.CASE_DIVIS:
        answer1 = resultValue + Random.Range(1, 4);
        answer2 = resultValue - Random.Range(1, 4);
        break;
}

It looks decent and it does the job but its kind of generic. If you are and adult it would quite easy for you to distigush the right solution among the three even without calculating in your mind.

If you were a mathematician how would you generate the two fake answers? On the other hand how would you generate 4 fake answers? :)

The code is written in C# / Unity3D 5.1.4.




Aucun commentaire:

Enregistrer un commentaire