Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (elapsed > 0.5f)
     {
         Stim stim = new Stim();
         print(stim.ToString());
         elapsed = 0;
     }
     elapsed += Time.deltaTime;
 }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     GlobalData.elapsedTime += Time.deltaTime;
     if (GlobalData.elapsedTime > (60 * 10))
     {
         SceneManager.LoadScene("EndScene");
     }
     numElapsed      += Time.deltaTime;
     equationElapsed += Time.deltaTime;
     //if equation should be displayed, display it and update number
     if (numElapsed > 4)
     {
         numberText.text = "";
         toggleEquation(true);
         equationText.text = currentStim.ToString();
     }
     //if equation time is up, generate new stim
     if (numElapsed > 8)
     {
         feedback.text = "";
         if (!firstStim && !guessed)
         {
             GlobalData.faults++;
             GlobalData.totalFaults++;
         }
         toggleEquation(false);
         firstStim    = false;
         currentStim  = new Stim();
         guessed      = false;
         equationShow = UnityEngine.Random.Range(5, 10);
         numElapsed   = 0;
         //if they've seen all the presentations
         if (numPresentations == 0)
         {
             //if the equation is also finished
             if (equationText.text == "")
             {
                 //load new scene
                 SceneManager.LoadScene("_Scenes/InputAnswer");
                 GlobalData.currentSequence = numbersList;
             }
             //else if there are more presentations
         }
         else
         {
             int nextNumber = UnityEngine.Random.Range(0, 9);
             numbersList.Add(nextNumber);
             numberText.text = nextNumber.ToString();
             numElapsed      = 0;
             numPresentations--;
         }
     }
 }
Exemple #3
0
        public void Simulate()
        {
            BuildTimeList();
            ///Lista dei nodi che cambiano valore
            nodeChanged = new List<int>();

            AllStim.Sort();
            Net.Sort();

            int Activity = 0;

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(OutFile))
            {
                Time = -1;
                do
                {
                    Activity = 0;
                    Time++;
                    while( AllStim.Count != 0  && AllStim[0].Time == Time)
                    {
                        Net[AllStim[0].Node].PS = Net[AllStim[0].Node].NS = AllStim[0].V;
                        nodeChanged.Add(AllStim[0].Node); //aggiungi alla lista dei nodi che cambiano valore
                        AllStim.RemoveAt(0);
                    }
                    file.WriteLine(" ");
                    file.WriteLine("Step: " + Time.ToString());
                    foreach (Node N in Net)
                    {
                        file.WriteLine("Node " + NodeNetRev[N.NodeNb] + "  " + N.NS.ToString());
                        ///Se il nodo è diverso da uno stimolo
                        if (N.GT != GateType.STIM)
                        {
                            //controlla se agli ingressi c'è stato un cambiamento
                            foreach (int i in N.Inputs)
                            {
                                if (nodeChanged.Contains(i))
                                {
                                    EvaluateNode(N);
                                    break;
                                    ///il break c'è per valutare il nodo per una volta sola
                                }
                            }
                        }
                    }

                    foreach (Node N in Net)
                    {
                        if (N.PS != N.NS)
                        {
                            Activity++;
                            ///Se c'è stato un cambiamento aggiungilo alla lista degli stimoli
                            bool b = false;
                            if (N.NS == true)
                                b = true;
                            Stim stim = new Stim(b, Time + 1, N.NodeNb);
                            AllStim.Add(stim);
                            N.PS = N.NS;
                        }

                    }
                    nodeChanged.Clear();
                    AllStim.Sort();
                } while (Activity > 0);

            }
        }