Exemplo n.º 1
0
 private void InitMemory()
 {
     memory = new TrialMemory_Cylinder[cylinders.Length];
     for (int i = 0; i < memory.Length; i++)
     {
         memory[i]        = new TrialMemory_Cylinder();
         memory[i].count  = 0;
         memory[i].angles = new bool[angles.Length];
         for (int k = 0; k < angles.Length; k++)
         {
             memory[i].angles[k] = false;
         }
     }
 }
Exemplo n.º 2
0
    public Trial NextTrial()
    {
        Trial trial = new Trial();

        trial.method = currentMethods[currentMethodIndex];

        // determine available cylinder
        currentCylinderIndex_old = currentCylinderIndex;

        currentCylinderIndex = Random.Range(0, currentCylinders.Length - 1); //which cylinder by index

        /*if (currentCylinders.Length > 1)
         * {
         *  while (currentCylinderIndex_old == currentCylinderIndex)
         *  {
         *      currentCylinderIndex = Random.Range(0, currentCylinders.Length - 1); //which cylinder by index
         *  }
         * }
         *
         * currentCylinderIndex = Random.Range(0, currentCylinders.Length - 1); //which cylinder by index
         */

        //currentCylinderIndex = FindLessUsedCylinder(currentCylinderIndex); // this is for balancing but doesn't work

        /*
         * bool search = true;
         * while ((currentCylinderIndex_old == currentCylinderIndex) && search)
         *  {
         *  if (!ContainsOnlyOneCylinder(currentCylinderIndex_old))
         *  {
         *      currentCylinderIndex = Random.Range(0, currentCylinders.Length - 1); //which cylinder by index
         *  }
         *  else
         *  {
         *      currentCylinderIndex = Random.Range(0, currentCylinders.Length - 1); //which cylinder by index
         *      //currentCylinderIndex = FindLessUsedCylinder(currentCylinderIndex); // this is for balancing but doesn't work
         *      search = false;
         *  }
         * }
         */
        //}

        memory[currentCylinders[currentCylinderIndex]].count++;  //remember its usage
        trial.cylinder = currentCylinders[currentCylinderIndex]; // activate this cylinder for the current trial



        //load remaining set of angles
        TrialMemory_Cylinder tmc = memory[currentCylinders[currentCylinderIndex]]; // current memory object
        int countUnusedAngles    = 0;                                              //init

        for (int i = 0; i < tmc.angles.Length; i++)
        {
            if (!tmc.angles[i])
            {
                countUnusedAngles++;                //count the unused
            }
        }

        //debugHUD.text = "\n " + "cylinder " + currentCylinders[currentCylinderIndex] + "has " + countUnusedAngles + "unused angles" + debugHUD.text;
        int[] selectionAngles = new int[countUnusedAngles]; // new array for indices with number of unused angles


        int count = 0;  //init

        for (int i = 0; i < tmc.angles.Length; i++)
        {
            if (!tmc.angles[i])
            {
                selectionAngles[count] = i; //copy unused indices
                count++;
            }
        }


        // determine available angle
        currentAngleIndex = Random.Range(0, selectionAngles.Length - 1);                                  //which angle by index

        memory[currentCylinders[currentCylinderIndex]].angles[selectionAngles[currentAngleIndex]] = true; // remember the use of the angle
        trial.angle = angles[selectionAngles[currentAngleIndex]];                                         //activate selected angle for current trial
        trial.angle = angles[Random.Range(0, angles.Length - 1)];


        // if all angles are used, remove cylinder from choice for the next round
        if (!AngleIsLeft())
        {
            //    debugHUD.text = "\n " + "no angle is left for cylinder:" + currentCylinders[currentCylinderIndex] + debugHUD.text;
            RemoveCylinderFromChoice(currentCylinderIndex);
        }


        return(trial);
    }