public RlmOptimizer(IRlmDbData rlmDbData, IRlmRneuronProcessor gpu = null)
        {
            Resources          = new Dictionary <string, Resource>();
            ResourceAttributes = new Dictionary <string, ResourceAttribute>();
            Constraints        = new Dictionary <string, Constraint>();
            CycleOutputs       = new Dictionary <string, object>();
            SessionOutputs     = new Dictionary <string, List <object> >();
            CycleInputs        = new Dictionary <string, object>();

            TrainingVariables.Add("CycleScore", new TrainingVariable()
            {
                Name = "CycleScore"
            });
            TrainingVariables.Add("SessionScore", new TrainingVariable()
            {
                Name = "SessionScore"
            });

            //if (!string.IsNullOrEmpty(databaseName))
            //{
            //    DatabaseName = databaseName;
            //}

            RlmDbData    = rlmDbData;
            DatabaseName = rlmDbData.DatabaseName;

            if (gpu != null)
            {
                Gpu = gpu;
            }
        }
예제 #2
0
    // Update is called once per frame
    public void Run()
    {
        switch( state )
        {
        case "initialize":
            state = "centering";
            break;

        case "centering":
            if( centerScriptL.Test(this.player) && centerScriptR.Test(this.player) )
            {
                centerScriptL.SetCenteredMaterial(true);
                centerScriptR.SetCenteredMaterial(true);

                if( CallTimer( delayDur ) )
                {
                    goto case "set variables";
                }
                else
                {
                    numMeasures += 2;
                    waitingAcceleration +=
                        Mathf.Sqrt( Mathf.Pow( (lastXLeft - leftPointer.transform.position.x), 2 ) + Mathf.Pow( (lastYLeft - leftPointer.transform.position.y), 2 ) ) +
                        Mathf.Sqrt( Mathf.Pow( (lastXRight - rightPointer.transform.position.x), 2 ) + Mathf.Pow( (lastYRight - rightPointer.transform.position.y), 2 ) );

                    UpdatePreviousCoordinates();
                    break;
                }
            }
            else
            {
                centerScriptL.SetCenteredMaterial(false);
                centerScriptR.SetCenteredMaterial(false);

                testTimer = null;
                break;
            }
        case "set variables":
            varis = new TrainingVariables( signalRadius, center.position );
            //thisCue = Instantiate( cue, Main.center, cylQuat ) as GameObject;
            thisCue = Instantiate( cue, center.position, cylQuat ) as GameObject;

            thisCue.renderer.material = cueMaterials[varis.cueIndex];
            state = "cue";
            goto case "cue";
        case "cue":
            if( centerScriptL.Test(this.player) && centerScriptR.Test(this.player) )
            {
                if( CallTimer( cueDur ) )
                {
                    Destroy( thisCue );
                    state = "wait";
                    goto case "wait";
                }
                else
                {
                    break;
                }
            }
            else
            {
                testTimer = null;
                Destroy( thisCue );
                state = "centering";
                break;
            }
        case "wait":

            if( centerScriptL.Test(this.player) && centerScriptR.Test(this.player) )
            {
                // wait for random range time and show signal.
                if( CallTimer( Random.Range(1.25f, 1.75f) ) )
                {
                    averageAcceleration = waitingAcceleration / numMeasures;
                    state = "signal";
                    goto case "signal";
                }
                else
                {
                    break;
                }
            }
            else // user moved after cue and before signal.
            {
                ErrorFeedback(new Vector3(0.0f, 0.0f, 0.0f));
                WriteData( false, "0", -0.001F, rt );
                StoreJSONTrial( false, "0", -0.001F, rt );
                Reset();
                break;
            }
        case "signal":
            thisSig = Instantiate(signal, varis.signalVec, Quaternion.identity) as GameObject;
            thisSig.GetComponent<TrainingSignal>().SetTestingScript(this.gameObject);
            if( !varis.valid )
            {
                thisSig.GetComponent<TrainingSignal>().setValid(false);
            }
            signalTime = Time.time;
            state = "testing";

            UpdatePreviousCoordinates();

            goto case "testing";
        case "testing":

            DetectAcceleration();
            UpdatePreviousCoordinates();

            if( (!centerScriptL.Test(this.player) || !centerScriptR.Test(this.player) ) && varis.valid && !leftCenter) // user moved on a valid signal, count reaction time
            {
                rt = Time.time - signalTime;
                leftCenter = true;
            }

            coordinateRecording = true;

            if( CallTimer( reactDur ) )
            {
                // valid signal that user didn't touch
                if( varis.valid ) {
                    ErrorFeedback(thisSig.transform.position);

                    WriteData( false, "1", -0.001F, rt );
                    StoreJSONTrial( false, "1", -0.001F, rt );
                }
                // user did not move on an invalid signal -> OK
                else {
                    ValidMovePopup(new Vector3(0.0f, 0.0f, 0.0f));
                    // apply acceleration equal to 0.5f RT
                    playerMovementScript.SetSpeeds(0.8f);
                    playerMovementScript.ThrusterFeedback(0.8f);
                    this.audio.PlayOneShot(thrusterSound);

                    WriteData( true, "0", -0.001F, -0.001F );
                    StoreJSONTrial( true, "0", -0.001F, -0.001F );
                }
                Destroy( thisSig );
                Reset();
                break;
            }
            else if( !centerScriptL.Test(this.player) || !centerScriptR.Test(this.player) ) // user left center
            {
                if( !varis.valid ) // user moved on invalid signal, count as a full trial
                {
                    ErrorFeedback(thisSig.transform.position);

                    WriteData( false, "0", -0.001F, Time.time - signalTime );
                    StoreJSONTrial( false, "0", -0.001F, Time.time - signalTime );

                    Destroy( thisSig );
                    Reset();
                    break;
                }
            }
            break;
        case "complete":
                GracefulGoodbye();
                break;
        default:
            break;
        }
    }