예제 #1
0
        public VariantGenerator(List<TestQuestion> questions, int _numberOfQuestions, bool _mixAnswers)
        {
            this.questions = questions;
            this.NumberOfQuestions = _numberOfQuestions;
            this.mixAnswers = _mixAnswers;

            int[] set = new int[questions.Count];
            for (int i = 0; i < questions.Count; ++i)
                set[i] = i;

            randomizer = new ArrayRandomizer<int>(new List<int>(set));
        }
예제 #2
0
    private TargetData[] generateRandomTargets(int size)
    {
        float minDistanceOfSeparation = 7.5f;  // Minimum Distance of Seperation between the two pairs of targets.
        float minDistance             = 3.0f;  // Minimum distance to the target from the camera.
        float maxDistance             = 50.0f; // Maximum distance to the target from the camera.
        float minAngularSize          = 2.5f;  // Minimum angular size
        float maxAngularSize          = 10.0f; // Maximum angular size


        size -= 1;          // Becausing counting in arrays begins at 0, adjust the count.
        // Because the points are generated in pairs, if the size is now odd,
        // increase it by one so that the size will be even.
        // Size + 1 is used because counting begins at 0 inside of the array
        if (size % 2 != 0)
        {
            size++;
        }


        // Create the targets
        TargetData[] data = new TargetData[size];
        for (int i = 0; i < size; i += 2)
        {
            Debug.Log(string.Format("Target {0} and {1} created.", i, i + 1));
            // Create the taget data
            float  angularSize = Random.Range(minAngularSize, maxAngularSize);
            float  distance1   = Random.Range(minDistance, maxDistance);
            float  distance2   = Random.Range(minDistance, maxDistance);
            string fileName1   = "Target_" + i.ToString() + ".dat";
            string fileName2   = "Target_" + (i + 1).ToString() + ".dat";

            // If the targets are within 3 units of one another,
            // Recalculate one of the distances until they are
            // Farther apart
            while (Mathf.Abs(distance1 - distance2) < minDistanceOfSeparation)
            {
                distance2 = Random.Range(minDistance, maxDistance);
            }

            // Move the data into the target structs
            TargetData targetData1 = new TargetData(angularSize, distance1, fileName1);
            TargetData targetData2 = new TargetData(angularSize, distance2, fileName2);

            // Save the structs to the output
            data[i]     = targetData1;
            data[i + 1] = targetData2;
        }

        // Randomize the order so the pairs are not placed directly next to one another
        ArrayRandomizer.Randomize(data);
        return(data);
    }