Exemplo n.º 1
0
    void FixedUpdate()
    {
        if (ballCtrl.GetPosition().y - diskCtrl.GetPosition().y < -5 ||
            Mathf.Abs(ballCtrl.GetPosition().x - diskCtrl.GetPosition().x) > 5 ||
            Mathf.Abs(ballCtrl.GetPosition().z - diskCtrl.GetPosition().z) > 5)
        {
            Restart();
        }
        switch (mode)
        {
        case EvaluationMode.Neural:
            OutputData neuralOutput = Neural.Evaluate(PrepareData());
            diskCtrl.SetAngularVelocity(FloatToVector3(neuralOutput.outputDiskRotationSpeedVector));
            break;

        case EvaluationMode.Fuzzy:
            OutputData fuzzyOutput = FuzzyLogic.Evaluate(PrepareData());
            //	fuzzyOutput.outputDiskRotationSpeedVector[2] = -fuzzyOutput.outputDiskRotationSpeedVector[2];
            diskCtrl.SetAngularVelocity(FloatToVector3(fuzzyOutput.outputDiskRotationSpeedVector));
            break;

            /*		case EvaluationMode.TrainNeural:
             *                      OutputData neuralOutputExp = new OutputData(Vector3ToFloat(diskCtrl.GetAngularVelocity()));
             *                      if (diskCtrl.GetAngularVelocity() != Vector3.zero)
             *                              Neural.Train(PrepareData(), neuralOutputExp);
             *                      break;*/
        }
    }
Exemplo n.º 2
0
 void Update()
 {
     if (enabledControl)
     {
         diskCtrl.SetAngularVelocity(new Vector3(
                                         Input.mousePosition.y - lastMousePosition.y,
                                         0,
                                         -(Input.mousePosition.x - lastMousePosition.x)
                                         ) * multiplier);
     }
     else
     {
         diskCtrl.SetAngularVelocity(Vector3.zero);
     }
     if (Input.GetKeyDown(KeyCode.M))
     {
         enabledControl = !enabledControl;
     }
     lastMousePosition = Input.mousePosition;
 }