Game manager WIP
This commit is contained in:
@@ -28,7 +28,7 @@ public class AgentControllerV7 : Agent
|
||||
float totalReward = 0;
|
||||
float totalMentalPain = 0;
|
||||
int stepsSinceCheckpoint = 0;
|
||||
int checkpointsReached = 0;
|
||||
[HideInInspector] public int checkpointsCollected = 0;
|
||||
public int maxStepsPerCheckpoint = 300;
|
||||
public int distanceBetweenCheckpoints = 5;
|
||||
public bool ignoreMentalPain = true;
|
||||
@@ -48,7 +48,7 @@ public class AgentControllerV7 : Agent
|
||||
public override void OnEpisodeBegin()
|
||||
{
|
||||
stepsSinceCheckpoint = 0;
|
||||
checkpointsReached = 0;
|
||||
checkpointsCollected = 0;
|
||||
totalReward = 0;
|
||||
totalMentalPain = 0;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class AgentControllerV7 : Agent
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
{
|
||||
Transform currentCheckpoint = checkpoints[checkpointsReached].transform;
|
||||
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
|
||||
|
||||
// distance to next checkpoint
|
||||
sensor.AddObservation(distanceToCheckpoint(currentCheckpoint));
|
||||
@@ -213,7 +213,7 @@ public class AgentControllerV7 : Agent
|
||||
}
|
||||
|
||||
// rewards
|
||||
Transform currentCheckpoint = checkpoints[checkpointsReached].transform;
|
||||
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
|
||||
|
||||
float checkpintDistance = distanceToCheckpoint(currentCheckpoint);
|
||||
float reward = (1 - Mathf.InverseLerp(0, distanceBetweenCheckpoints, checkpintDistance)) / 500;
|
||||
@@ -235,13 +235,13 @@ public class AgentControllerV7 : Agent
|
||||
stepsSinceCheckpoint = 0;
|
||||
|
||||
// If last checkpoint
|
||||
if (checkpointsReached == checkpoints.Count - 1)
|
||||
if (checkpointsCollected == checkpoints.Count - 1)
|
||||
{
|
||||
AddReward(10f);
|
||||
EndEpisode();
|
||||
}
|
||||
|
||||
checkpointsReached += 1;
|
||||
checkpointsCollected += 1;
|
||||
|
||||
//TODO fix variable names
|
||||
|
||||
|
||||
Reference in New Issue
Block a user