Exemple #1
0
    void Update()
    {
        // Random bool
        if (Input.GetKey(keyRandomBool))
        {
            Debug.Log("The gotten value is " + random.GetRandomBool(0.5f));
        }

        // Random float
        if (Input.GetKey(keyRandomFloat))
        {
            Debug.Log("The gotten value is " + random.GetRandomFloat(3.5f, 5.0f));
        }


        // Pseudo random example (and testing)
        if (Input.GetKey(keyPseudoRandom))
        {
            // You can use this code to better understand what is the result of each "RandomBool" method
            bool result = random.GetPseudoRandomBool(tryNumber, 0.2f);
            //bool result = random.GetPseudoRandomBool(tryNumber, 15);
            //bool result = random.GetRandomBool(0.2f);

            randomResults.Add(result);

            if (result)
            {
                workingTryNumbers.Add(tryNumber);
                if (tryNumber > maxTryNumber)
                {
                    maxTryNumber = tryNumber;
                }
                tryNumber = 0;
            }
            else
            {
                tryNumber++;
            }

            int[] stats = new int[maxTryNumber];
            foreach (int regTry in workingTryNumbers)
            {
                stats[regTry - 1]++;
            }


            int contador = 0;
            foreach (var r in randomResults)
            {
                if (r)
                {
                    contador++;
                }
            }

            Debug.Log("Percentage of positive values: " + (float)contador / (float)randomResults.Count + ". Try with the maximum value: " + maxTryNumber + ". Average needed quantity of tries:" + (workingTryNumbers.Count > 0 ? workingTryNumbers.Average() : 0.0));
            DebugPro.Log(stats, "STATS: ");
        }
    }
Exemple #2
0
    void Start()
    {
        DebugPro.Log(" ======== DEBUGGING ARRAY: ======== ");
        int[] arrayInts = { 1, 2, 3, 4, 5, 6, 7, 8 };
        DebugPro.Log(arrayInts);                                                  // Array with no message
        DebugPro.Log(arrayInts, "Message printed before the list array: ");       // Array with message
        DebugPro.Log(arrayInts, "Message printed before the list array: ", this); // Array with message and referencing the component's gameObject


        DebugPro.Log(" ======== DEBUGGING LIST: ======== ");
        List <int> listInts = arrayInts.ToList();

        DebugPro.Log(listInts, "");                                             // List with no message
        DebugPro.Log(listInts, "Message printed before the list list: ");       // List with message
        DebugPro.Log(listInts, "Message printed before the list list: ", this); // List with message and referencing the component's gameObject
    }
Exemple #3
0
    void Update()
    {
        // Random bool
        if (Input.GetKey(keyRandomBool))
        {
            bool obtainedBool = easyRandom.GetRandomBool(0.5f);
            if (obtainedBool)
            {
                trueBooleans++;
            }
            else
            {
                falseBooleans++;
            }
            Debug.Log("The gotten value is " + obtainedBool + ". Average = " + (trueBooleans * 100f / (trueBooleans + falseBooleans)) + "%");
        }


        // Random float
        if (Input.GetKey(keyRandomFloat))
        {
            Debug.Log("The gotten value is " + easyRandom.GetRandomFloat(3.5f, 5.0f));
        }


        // Pseudo-random distribution example (and testing)
        // An image of how the results should distribute (in blue): https://gamepedia.cursecdn.com/dota2_gamepedia/8/8b/AttacksUntilNextProc25.jpg?version=459537150af02c929fd939495fa78033
        if (Input.GetKey(keyPseudoRandom))
        {
            // You can use this code to better understand what is the result of each "RandomBool" method
            bool result = easyRandom.GetPseudoRandomDistributedBool(tryNumberSinceLastPositive, 0.25f);
            //bool result = random.GetPseudoRandomBool(tryNumber, 15);
            //bool result = random.GetRandomBool(0.2f);

            randomResults.Add(result);

            if (result)
            {
                workingTryNumbers.Add(tryNumberSinceLastPositive);
                if (tryNumberSinceLastPositive > maxTryNumber)
                {
                    maxTryNumber = tryNumberSinceLastPositive;
                }
                tryNumberSinceLastPositive = 0;
            }
            else
            {
                tryNumberSinceLastPositive++;
            }

            int[] stats = new int[maxTryNumber];
            foreach (int regTry in workingTryNumbers)
            {
                stats[regTry - 1]++;
            }

            int contador = 0;
            foreach (bool r in randomResults)
            {
                if (r)
                {
                    contador++;
                }
            }

            Debug.Log("Percentage of positive values: " + (float)contador / (float)randomResults.Count + ". Try with the maximum value: " + maxTryNumber + ". Average needed quantity of tries:" + (workingTryNumbers.Count > 0 ? workingTryNumbers.Average() : 0.0));
            DebugPro.LogEnumerable(stats, ", ", "STATS: ");
        }
    }