IEnumerator FeedForward() { while (true) { for (int i = 0; i < 5; i++) { InputNeurons[i].CleanInput(); InputNeurons[i].AddInput(sensors.Sensorium[i]); } foreach (Neuron item in InputNeurons) { item.Prime(); } foreach (Neuron item in HiddenNeurons) { item.Prime(); } foreach (Neuron item in OutputNeurons) { item.Prime(); } if (OutputNeurons[0].Output > OutputNeurons[0].Threshhold) { carctrl.TurnLeft(); } if (OutputNeurons[1].Output > OutputNeurons[1].Threshhold) { carctrl.TurnRight(); } if (TestCar) { Debug.Log(allconnections[0].Weight); Debug.Log(allconnections[1].Weight); Debug.Log(allconnections[2].Weight); Debug.Log(allconnections[3].Weight); Debug.Log("output Neuron 0 = " + OutputNeurons[0].Output + " Output Neuron 1 = " + OutputNeurons[1].Output); } yield return(null); } }
void OnTriggerStay(Collider other) { if (alive) { if (other.gameObject.CompareTag("Lane_Separator") || other.gameObject.CompareTag("Car")) { carControl.TurnRight(); } alive = carControl.IsMoving(); } }
IEnumerator AIThing() { while (true) { float leftbias, rightbias; leftbias = Sensorium[0] + Sensorium[1] + Sensorium[2]; rightbias = Sensorium[2] + Sensorium[4] + Sensorium[3]; if (leftbias > courage && leftbias > rightbias) { ctrl.TurnRight(); } if (rightbias > courage && rightbias > leftbias) { ctrl.TurnLeft(); } yield return(null); } }