public void Step() { float[] Inputs = Scan(); float[] Prediction = NN.GetOutput(Inputs); Vector3 NextPos = gameObject.transform.position; switch (OutputToDirection(Prediction)) { case 0: if (gameObject.transform.position.z > -5) { NextPos.z -= 1; Rb.position = NextPos; } break; case 1: break; case 2: if (gameObject.transform.position.z < 5) { NextPos.z += 1; Rb.position = NextPos; } break; default: break; } NN.AddToFitness(ScanFitness()); }
// Update is called once per frame void Update() { if (moving) { CheckDistance(); } UpdateInputs(); NeuralNetworkMove(); NeuralNetworkIncrementFitness(); lifeTime++; if (lifeTime > 20000) { Freeze(); tag = "Dead"; brain.AddToFitness(-200000000); } }