diff --git a/Assets/ML-Agents/Timers/AI training_timers.json b/Assets/ML-Agents/Timers/AI training_timers.json index aab6856..7f4d7cc 100644 --- a/Assets/ML-Agents/Timers/AI training_timers.json +++ b/Assets/ML-Agents/Timers/AI training_timers.json @@ -1 +1 @@ -{"count":1,"self":129.635968,"total":134.0807967,"children":{"InitializeActuators":{"count":1,"self":0.0010065,"total":0.0010065,"children":null},"InitializeSensors":{"count":1,"self":0.0010029,"total":0.0010029,"children":null},"AgentSendState":{"count":6461,"self":0.4243298,"total":0.6416294,"children":{"CollectObservations":{"count":6461,"self":0.1498118,"total":0.1498118,"children":null},"WriteActionMask":{"count":6461,"self":0.0179398,"total":0.0179398,"children":null},"RequestDecision":{"count":6461,"self":0.049547999999999995,"total":0.049547999999999995,"children":null}}},"DecideAction":{"count":6461,"self":3.6178863999999997,"total":3.655306,"children":{"RayPerceptionSensor.Perceive":{"count":12922,"self":0.0374195,"total":0.0374195,"children":null}}},"AgentAct":{"count":6461,"self":0.1448885,"total":0.1448885,"children":null}},"gauges":{"BensonImitationV2.CumulativeReward":{"count":8,"max":15.261137,"min":0.0150000015,"runningAverage":4.582781,"value":15.261137,"weightedAverage":4.90105152}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712915677","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 36cd304d-8333-4e13-9400-40712c29b116 -accessToken V38nPLIXDhAumRkhp_UQDiAFhJHlz31FOZlSjW8et9U005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"AI training","end_time_seconds":"1712915811"}} \ No newline at end of file +{"count":1,"self":9.9459248,"total":10.0981568,"children":{"InitializeActuators":{"count":1,"self":0.0010002,"total":0.0010002,"children":null},"InitializeSensors":{"count":1,"self":0.0025088999999999997,"total":0.0025088999999999997,"children":null},"AgentSendState":{"count":271,"self":0.0097879,"total":0.0213799,"children":{"CollectObservations":{"count":271,"self":0.0045096,"total":0.0045096,"children":null},"WriteActionMask":{"count":271,"self":0.0010061999999999998,"total":0.0010061999999999998,"children":null},"RequestDecision":{"count":271,"self":0.0025272999999999997,"total":0.0060761999999999995,"children":{"RayPerceptionSensor.Perceive":{"count":542,"self":0.0035489,"total":0.0035489,"children":null}}}}},"DecideAction":{"count":271,"self":0.0015027999999999999,"total":0.0015027999999999999,"children":null},"AgentAct":{"count":271,"self":0.1258398,"total":0.1258398,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712918619","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 36cd304d-8333-4e13-9400-40712c29b116 -accessToken V38nPLIXDhAumRkhp_UQDiAFhJHlz31FOZlSjW8et9U005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"AI training","end_time_seconds":"1712918629"}} \ No newline at end of file diff --git a/Assets/Scenes/AI Training.unity b/Assets/Scenes/AI Training.unity index d2b7733..5ca14c0 100644 --- a/Assets/Scenes/AI Training.unity +++ b/Assets/Scenes/AI Training.unity @@ -522,7 +522,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1387890555408215438, guid: 80c5f8bcfe7e033419638b39d9a278c4, type: 3} propertyPath: m_IsActive - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 2100622393876020061, guid: 80c5f8bcfe7e033419638b39d9a278c4, type: 3} propertyPath: CameraSide @@ -919,6 +919,10 @@ PrefabInstance: propertyPath: m_Name value: Player objectReference: {fileID: 0} + - target: {fileID: 5711380006811689493, guid: 5851f609a58dc884a99030da0105c6db, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7953198523918571078, guid: 5851f609a58dc884a99030da0105c6db, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -1058,7 +1062,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1387890555408215438, guid: 80c5f8bcfe7e033419638b39d9a278c4, type: 3} propertyPath: m_IsActive - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 2100622393876020061, guid: 80c5f8bcfe7e033419638b39d9a278c4, type: 3} propertyPath: CameraSide @@ -1282,7 +1286,23 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1484836458307072091, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_LocalScale.x - value: 4.514652 + value: 7.2992887 + objectReference: {fileID: 0} + - target: {fileID: 1484836458307072091, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalPosition.x + value: 61.57 + objectReference: {fileID: 0} + - target: {fileID: 1865281994371996840, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalScale.x + value: 0.25 + objectReference: {fileID: 0} + - target: {fileID: 1865281994371996840, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalScale.y + value: 0.25 + objectReference: {fileID: 0} + - target: {fileID: 1865281994371996840, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalScale.z + value: 0.25 objectReference: {fileID: 0} - target: {fileID: 2204259376183904707, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_LocalScale.x @@ -1316,6 +1336,18 @@ PrefabInstance: propertyPath: checkpoints.Array.data[15] value: objectReference: {fileID: 367546974} + - target: {fileID: 4361687674892069559, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4361687674892069559, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalScale.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4361687674892069559, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} + propertyPath: m_LocalScale.z + value: 1 + objectReference: {fileID: 0} - target: {fileID: 4361687674892069559, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_LocalPosition.x value: 61.9 @@ -1354,7 +1386,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5501784256737884761, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_LocalScale.x - value: 1.66666 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6288636727627254098, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_MaxRayDegrees @@ -1435,14 +1467,14 @@ PrefabInstance: - target: {fileID: 8242215082626919376, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_Model value: - objectReference: {fileID: 5022602860645237092, guid: fd44866499c75eb4795a6795ee8ed958, type: 3} + objectReference: {fileID: 0} - target: {fileID: 8242215082626919376, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_BehaviorName value: BensonImitationV2 objectReference: {fileID: 0} - target: {fileID: 8242215082626919376, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_BehaviorType - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 8262033930960634649, guid: 3664a8beed80ac848a9377d9ee14cb9b, type: 3} propertyPath: m_IsActive diff --git a/Assets/Scripts/AgentController.cs b/Assets/Scripts/AgentController.cs index b7822ff..dd80fe2 100644 --- a/Assets/Scripts/AgentController.cs +++ b/Assets/Scripts/AgentController.cs @@ -218,23 +218,27 @@ public class AgentController : Agent float checkpintDistance = distanceToCheckpoint(currentCheckpoint); + print("forward " + transform.forward); + + Vector3 checkpointDirection = currentCheckpoint.localPosition - transform.localPosition; + + print("checkpoint direction " + checkpointDirection); + + //print(angleToCheckpoint(currentCheckpoint)); + // float reward = (1 - Mathf.InverseLerp(0, 20, checkpintDistance)) / 1000; // AddReward(reward); if (checkpintDistance < 0.1f) { - Debug.Log(currentCheckpoint.name); - currentCheckpoint.GetComponent().isCollected = true; stepsSinceCheckpoint = 0; if (currentCheckpoint == checkpoints[checkpoints.Count - 1].transform) { AddReward(10f); - EndEpisode(); - - Debug.Log("END"); + EndEpisode(); } AddReward(1.0f); } @@ -267,6 +271,7 @@ public class AgentController : Agent discreteActionsOut[1] = 1; } + // finds distance from agent to closest point on the checkpoint line float distanceToCheckpoint(Transform checkpoint) { var closestPoint = checkpoint.GetComponent().ClosestPointOnBounds(transform.position); @@ -274,6 +279,15 @@ public class AgentController : Agent return distanceToCheckpoint; } + // find angle from agent to middle of checkpoint line. + float angleToCheckpoint(Transform checkpoint) + { + Vector3 checkpointDirection = checkpoint.localPosition - transform.localPosition; + + float angle = Vector3.Angle(transform.forward, checkpointDirection); + return angle; + } + // punishment for hitting a wall private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Wall")