예제 #1
0
 public Option <TrialState> HandleResponse(TrialState state, List <RecordResponses.Response> responses, string currentProblem)
 {
     if (state == TrialState.Problem)
     {
         if (responses.Count == 0)
         {
             return(Option <TrialState> .Create(TrialState.Slow));
         }
         else if (checker.Check(currentProblem, responses.Last().buttonPressed))
         {
             return(Option <TrialState> .Create(TrialState.Correct));
         }
         else
         {
             return(Option <TrialState> .Create(TrialState.Incorrect));
         }
     }
     return(Option <TrialState> .CreateEmpty());
 }
예제 #2
0
파일: Math.cs 프로젝트: yesjessn/VRAM
        void Update()
        {
            if (trialState == TrialState.Ending)
            {
                EndTask();
                return;
            }
            else if (trialState == TrialState.Starting)
            {
                print("Starting Math");
                ShowText(trialState.Instructions());
                trialState = trialState.Next();
                return;
            }
            var finishReady        = trialState == TrialState.Ready && input.GetButtonDown("Button3");
            var finishInstructions = trialState.isInstruction() && (input.GetButtonDown("Button1") || input.GetButtonDown("Button2") || input.GetButtonDown("Button4"));
            var finishState        = (int)trialState > (int)TrialState.Ready && (int)trialState <= (int)TrialState.ITI && (trialTimer.isComplete || recorder.hasResponse);

            if (finishInstructions || finishReady || finishState)
            {
                if (finishReady)
                {
                    distractionController.gameObject.SetActive(true);
                }

                if (trialState != TrialState.Ending)
                {
                    var blockComplete = blockTimer.isComplete;
                    if (blockComplete)
                    {
                        currentBlock++;
                        if (currentBlock == NumberOfBlocks)
                        {
                            trialState = TrialState.Ending;
                            recordResults.Close();
                            return;
                        }
                        switch (type)
                        {
                        case BlockType.Easy:
                            type = BlockType.Medium;
                            break;

                        case BlockType.Medium:
                            type = BlockType.Easy;
                            break;
                        }
                        blockTimer.Start();
                    }

                    Option <TrialState> nextState = Option <TrialState> .CreateEmpty();

                    if (blockComplete || finishState || finishInstructions || finishReady)
                    {
                        if (trialState == TrialState.Problem)
                        {
                            var responses = recorder.StopRecording();
                            salienceController.addResponseResult(checker.Check(currentProblemName, responses.Count > 0 ? responses.Last().buttonPressed : null));
                            if (practice.enabled)
                            {
                                nextState = practice.HandleResponse(trialState, responses, currentProblemName);
                            }
                            else
                            {
                                var output = new TrialOutput(currentTrial, currentBlock, type, responses);
                                recordResults.WriteRow(output.ToString());
                            }
                        }
                        if (nextState.Count() > 0)
                        {
                            trialState = nextState.First();
                            if (trialState != TrialState.Correct)
                            {
                                currentTrial--;
                            }
                        }
                        else
                        {
                            trialState = trialState.Next();
                        }
                        //print ("Starting state " + trialState);

                        var instruction = trialState.Instructions();
                        if (instruction != "")
                        {
                            ShowText(instruction);
                        }
                        else
                        {
                            var currentProblem = trialState.GetTexture(type, mathTextures);
                            currentProblemName = currentProblem.name;
                            ShowImage(currentProblem);

                            trialTimer.duration = trialState.Duration();
                            if (trialState == TrialState.Problem)
                            {
                                currentTrial++;
                                recorder.StartRecording();
                            }
                            trialTimer.Start();
                        }
                    }
                }
            }
        }