diff --git a/Assets/ML-Agents/Timers/ForestRacetrack_timers.json b/Assets/ML-Agents/Timers/ForestRacetrack_timers.json index 899f85f..44a20c1 100644 --- a/Assets/ML-Agents/Timers/ForestRacetrack_timers.json +++ b/Assets/ML-Agents/Timers/ForestRacetrack_timers.json @@ -1 +1 @@ -{"count":1,"self":7.7646456,"total":7.8548963,"children":{"InitializeActuators":{"count":8,"self":0.0035095,"total":0.0035095,"children":null},"InitializeSensors":{"count":8,"self":0.0035093999999999998,"total":0.0035093999999999998,"children":null},"AgentSendState":{"count":1,"self":0.0090396,"total":0.0199904,"children":{"CollectObservations":{"count":8,"self":0,"total":0,"children":null},"WriteActionMask":{"count":8,"self":0,"total":0,"children":null},"RequestDecision":{"count":8,"self":0.0109508,"total":0.0109508,"children":null}}},"DecideAction":{"count":1,"self":0.0632417,"total":0.0632417,"children":{"RayPerceptionSensor.Perceive":{"count":16,"self":0,"total":0,"children":null}}},"AgentAct":{"count":1,"self":0,"total":0,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714132819","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"ForestRacetrack","end_time_seconds":"1714132827"}} \ No newline at end of file +{"count":1,"self":111.73324799999999,"total":115.3655125,"children":{"InitializeActuators":{"count":8,"self":0.0010012999999999999,"total":0.0010012999999999999,"children":null},"InitializeSensors":{"count":8,"self":0.0015026,"total":0.0015026,"children":null},"AgentSendState":{"count":5535,"self":0.3819255,"total":0.4813301,"children":{"CollectObservations":{"count":8856,"self":0.055236799999999996,"total":0.055236799999999996,"children":null},"WriteActionMask":{"count":8856,"self":0.0010157999999999999,"total":0.0010157999999999999,"children":null},"RequestDecision":{"count":8856,"self":0.043151999999999996,"total":0.043151999999999996,"children":null}}},"DecideAction":{"count":5535,"self":2.6350796,"total":2.6868285,"children":{"RayPerceptionSensor.Perceive":{"count":17712,"self":0.0517488,"total":0.0517488,"children":null}}},"AgentAct":{"count":5535,"self":0.4606065,"total":0.4606065,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":13,"max":25.5656662,"min":21.4600677,"runningAverage":23.7516136,"value":25.0143127,"weightedAverage":23.9939575}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714134391","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"ForestRacetrack","end_time_seconds":"1714134506"}} \ No newline at end of file diff --git a/Assets/ML-Agents/Timers/WinScreen_timers.json b/Assets/ML-Agents/Timers/WinScreen_timers.json index caaf71a..faba239 100644 --- a/Assets/ML-Agents/Timers/WinScreen_timers.json +++ b/Assets/ML-Agents/Timers/WinScreen_timers.json @@ -1 +1 @@ -{"count":1,"self":367.47586559999996,"total":374.68267299999997,"children":{"InitializeActuators":{"count":16,"self":0.0010002,"total":0.0010002,"children":null},"InitializeSensors":{"count":16,"self":0.0019317,"total":0.0019317,"children":null},"AgentSendState":{"count":18354,"self":0.9089815,"total":1.1072521,"children":{"CollectObservations":{"count":25480,"self":0.11964609999999999,"total":0.11964609999999999,"children":null},"WriteActionMask":{"count":25480,"self":0.024442199999999997,"total":0.024442199999999997,"children":null},"RequestDecision":{"count":25480,"self":0.054182299999999996,"total":0.054182299999999996,"children":null}}},"DecideAction":{"count":18354,"self":5.1585944,"total":5.2748705,"children":{"RayPerceptionSensor.Perceive":{"count":50960,"self":0.1162763,"total":0.1162763,"children":null}}},"AgentAct":{"count":18354,"self":0.82174949999999991,"total":0.82174949999999991,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":28,"max":27.5440578,"min":20.9639225,"runningAverage":24.66793,"value":24.2929268,"weightedAverage":24.8807487}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714132843","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"WinScreen","end_time_seconds":"1714133217"}} \ No newline at end of file +{"count":1,"self":92.310976,"total":94.7386543,"children":{"InitializeActuators":{"count":8,"self":0.0010216,"total":0.0010216,"children":null},"InitializeSensors":{"count":8,"self":0.0020005,"total":0.0020005,"children":null},"AgentSendState":{"count":3706,"self":0.2585523,"total":0.33199409999999996,"children":{"CollectObservations":{"count":5928,"self":0.0394114,"total":0.0394114,"children":null},"WriteActionMask":{"count":5928,"self":0.0065324,"total":0.0065324,"children":null},"RequestDecision":{"count":5928,"self":0.027497999999999998,"total":0.027497999999999998,"children":null}}},"DecideAction":{"count":3706,"self":1.7604408,"total":1.7950252999999998,"children":{"RayPerceptionSensor.Perceive":{"count":11856,"self":0.0345845,"total":0.0345845,"children":null}}},"AgentAct":{"count":3706,"self":0.2966395,"total":0.2966395,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":6,"max":25.4789715,"min":19.6162643,"runningAverage":22.84457,"value":23.53373,"weightedAverage":22.6495037}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714133850","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"WinScreen","end_time_seconds":"1714133945"}} \ No newline at end of file diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index c0bfde9..0412468 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -16,6 +16,9 @@ public class PlayerController : MonoBehaviour public Rigidbody rigidBody; [HideInInspector] public int checkpointsCollected = 0; public GameObject[] checkpoints; + Vector3 startPosition; + Quaternion startRotation; + KeyCode resetCarKey = KeyCode.Backspace; // Start is called before the first frame update void Start() @@ -24,6 +27,9 @@ public class PlayerController : MonoBehaviour { rigidBody = GetComponent (); } + + startPosition = transform.position; + startRotation = transform.rotation; // Find all child GameObjects that have the WheelControl script attached @@ -128,6 +134,35 @@ public class PlayerController : MonoBehaviour float checkpintDistance = distanceToCheckpoint(currentCheckpoint); + // send back to previous checkpoint if stuck + + if (Input.GetKeyDown(resetCarKey)) + { + if (checkpointsCollected == 0) + { + transform.position = startPosition; + transform.rotation = startRotation; + } + + else + { + transform.position = new Vector3( + checkpoints[checkpointsCollected - 1].transform.position.x, + transform.position.y + 3, + checkpoints[checkpointsCollected - 1].transform.position.z + ); + + transform.eulerAngles = new Vector3( + transform.eulerAngles.x, + checkpoints[checkpointsCollected - 1].transform.eulerAngles.y, + transform.eulerAngles.z + ); + } + } + + + + if (checkpintDistance < 0.2f) { checkpointsCollected += 1;