vendredi 20 mars 2020

c# random number code working when walking through it, but not when run without debugger

I have this code to generate a personality type:

public static Personality GeneratePersonalityType_NoOrigin(Personality p)
    {
        p.IE = new Random().Next(1, 100);
        if (p.IE >= 50)
        {
            p.personalitytype = p.personalitytype + "I";
        }
        else
        {
            p.personalitytype = p.personalitytype + "E";
        }
        p.NS = new Random().Next(1, 100);
        if (p.NS >= 50)
        {
            p.personalitytype = p.personalitytype + "N";
        }
        else
        {
            p.personalitytype = p.personalitytype + "S";
        }
        p.FT = new Random().Next(1, 100);
        if (p.FT >= 50)
        {
            p.personalitytype = p.personalitytype + "F";
        }
        else
        {
            p.personalitytype = p.personalitytype + "T";
        }
        p.JP = new Random().Next(1, 100);
        if (p.JP >= 50)
        {
            p.personalitytype = p.personalitytype + "J";
        }
        else
        {
            p.personalitytype = p.personalitytype + "P";
        }




        return p;

    }

When I run it in the debugger and walk through it, it gives one of the random 16 combinations. When I run it normally, it gives only 1 of 2 combinations every single time. INFJ and ESTP. I cannot seem to get it to work, and I do not understand what I did wrong? Can someone help me with this?




Aucun commentaire:

Enregistrer un commentaire