void Update() { if (!trainingDone) { return; } List <double> calcOutputs = new List <double>(); List <double> inputs = new List <double>(); List <double> outputs = new List <double>(); float fDist = 0, rDist = 0, lDist = 0, r45Dist = 0, l45Dist = 0; kart.PerformRayCasts(out fDist, out rDist, out lDist, out r45Dist, out l45Dist, this.transform); inputs.Add(fDist); inputs.Add(rDist); inputs.Add(lDist); inputs.Add(r45Dist); inputs.Add(l45Dist); outputs.Add(0); outputs.Add(0); calcOutputs = ann.CalcOutput(inputs, outputs); float translationInput = Utils.Map(-1, 1, 0, 1, (float)calcOutputs[0]); float rotationInput = Utils.Map(-1, 1, 0, 1, (float)calcOutputs[1]); kart.Move(this.transform, translationInput, rotationInput); }
void Update() { float translationInput = Input.GetAxis("Vertical"); float rotationInput = Input.GetAxis("Horizontal"); kart.Move(this.transform, translationInput, rotationInput); List <float> rays = kart.CalculateRayData(this.transform); string td = rays[0] + "," + rays[1] + "," + rays[2] + "," + rays[3] + "," + rays[4] + "," + Utils.Round(translationInput) + "," + Utils.Round(rotationInput); if (!collectedTrainingData.Contains(td)) { collectedTrainingData.Add(td); } }