This commit is contained in:
2024-04-23 08:34:56 +02:00
parent af1cf75b8d
commit bec6c88a63
3 changed files with 22 additions and 27589 deletions

View File

@@ -66,27 +66,11 @@ public class AgentControllerV7 : Agent
transform.localRotation = startRotation;
rigidBody.velocity = Vector3.zero;
rigidBody.angularVelocity = Vector3.zero;
// reset checkpoints
foreach (GameObject checkpoint in checkpoints)
{
checkpoint.GetComponent<Checkpoint>().isCollected = false;
}
}
public override void CollectObservations(VectorSensor sensor)
{
Transform currentCheckpoint = checkpoints[0].transform;
foreach (GameObject checkpoint in checkpoints)
{
bool isCollected = checkpoint.GetComponent<Checkpoint>().isCollected;
if (!isCollected)
{
currentCheckpoint = checkpoint.transform;
break;
}
}
Transform currentCheckpoint = checkpoints[checkpointsReached].transform;
// distance to next checkpoint
sensor.AddObservation(distanceToCheckpoint(currentCheckpoint));
@@ -215,17 +199,7 @@ public class AgentControllerV7 : Agent
}
// rewards
Transform currentCheckpoint = checkpoints[0].transform;
foreach (GameObject checkpoint in checkpoints)
{
bool isCollected = checkpoint.GetComponent<Checkpoint>().isCollected;
if (!isCollected)
{
currentCheckpoint = checkpoint.transform;
break;
}
}
Transform currentCheckpoint = checkpoints[checkpointsReached].transform;
float checkpintDistance = distanceToCheckpoint(currentCheckpoint);
float reward = (1 - Mathf.InverseLerp(0, distanceBetweenCheckpoints, checkpintDistance)) / 500;
@@ -242,10 +216,6 @@ public class AgentControllerV7 : Agent
AddReward(reward);
if (checkpintDistance < 0.1f)
{
currentCheckpoint.GetComponent<Checkpoint>().isCollected = true;