This commit is contained in:
2024-05-06 14:12:52 +02:00
parent a756f5e9aa
commit fc9d571b0b
2 changed files with 3 additions and 22 deletions

View File

@@ -90,8 +90,6 @@ public class AgentController: Agent
// transform.position.y,
// transform.position.z + rng
// );
}
@@ -170,17 +168,11 @@ public class AgentController: Agent
totalReward -= 0.0018f;
float forwardSpeed = Vector3.Dot(transform.forward, rb.velocity);
// Calculate how close the car is to top speed
// as a number from zero to one
float speedFactor = Mathf.InverseLerp(0, maxSpeed / 4, forwardSpeed);
// Use that to calculate how much torque is available
// (zero torque at top speed)
float currentMotorTorque = Mathf.Lerp(motorTorque, 0, speedFactor);
// …and to calculate how much to steer
// (the car steers more gently at top speed)
float currentSteerRange = Mathf.Lerp(steeringRange, steeringRangeAtMaxSpeed, speedFactor);
// Check whether the user input is in the same direction