Exemplo n.º 1
0
    void FixedUpdate()
    {
        if (!GameFinished && DataReceiver != null)
        {
            //Debug.Log("Wybieraj");

            LastSensorReading = DataReceiver.GetData();

            if (LastSensorReading != null && LastSensorReading.Data("Game In Progress") > 0)
            {
                //Debug.Log("Score: " + LastSensorReading.Data("Score"));
                int maxSensor = 0;

                //float[] decisionValues = NeuralNetwork.Calculate(LastSensorReading.Sensors);
                double[] reeeee = new double[LastSensorReading.Sensors.Length + 1];
                for (int i = 1; i < reeeee.Length; i++)
                {
                    reeeee[i] = (double)LastSensorReading.Sensors[i - 1];

                    if (reeeee[i] >= 1)
                    {
                        maxSensor++;
                    }
                }

                reeeee[0] = LastSensorReading.Data("Velocity") / 60;

                if (logEnabled)
                {
                    string temp =
                        "Velocity: " + reeeee[0].ToString("n3") + ", " +
                        "Sensor 0: " + reeeee[1].ToString("n3") + ", " +
                        "Sensor 1: " + reeeee[2].ToString("n3") + ", " +
                        "Sensor 2: " + reeeee[3].ToString("n3") + ", " +
                        "Sensor 3: " + reeeee[4].ToString("n3") + ", " +
                        "Sensor 4: " + reeeee[5].ToString("n3");

                    Debug.Log(temp);
                }

                var result = NeuralNetwork.Calculate(reeeee);
                CalculateNextOrder(result);
            }
            else
            {
                GameFinished = true;
            }
        }
    }
Exemplo n.º 2
0
 public int FinalScore()
 {
     return((LastSensorReading != null)? (int)LastSensorReading.Data("Score") : int.MinValue);
 }