Game Manager WIP
This commit is contained in:
@@ -11,7 +11,7 @@ using Unity.VisualScripting;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
public class AgentControllerV7 : Agent
|
||||
public class AgentController: Agent
|
||||
{
|
||||
public float motorTorque = 300;
|
||||
public float brakeTorque = 500;
|
||||
@@ -32,8 +32,13 @@ public class AgentControllerV7 : Agent
|
||||
public int maxStepsPerCheckpoint = 300;
|
||||
public int distanceBetweenCheckpoints = 5;
|
||||
public bool ignoreMentalPain = true;
|
||||
bool isEnabled = true;
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void OnDisable()
|
||||
{
|
||||
isEnabled = false;
|
||||
return;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
@@ -47,6 +52,9 @@ public class AgentControllerV7 : Agent
|
||||
|
||||
public override void OnEpisodeBegin()
|
||||
{
|
||||
if (!isEnabled)
|
||||
return;
|
||||
|
||||
stepsSinceCheckpoint = 0;
|
||||
checkpointsCollected = 0;
|
||||
totalReward = 0;
|
||||
@@ -84,6 +92,7 @@ public class AgentControllerV7 : Agent
|
||||
|
||||
public override void CollectObservations(VectorSensor sensor)
|
||||
{
|
||||
|
||||
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
|
||||
|
||||
// distance to next checkpoint
|
||||
@@ -124,7 +133,9 @@ public class AgentControllerV7 : Agent
|
||||
}
|
||||
|
||||
public override void OnActionReceived(ActionBuffers actions)
|
||||
{
|
||||
{
|
||||
if (!isEnabled)
|
||||
return;
|
||||
// Actions size = 2 [vertical speed, horizontal speed] = [-1..1, -1..1] // discrete = [{0, 1, 2}, {0, 1, 2}] = [{-1, 0, 1}...]
|
||||
float vInput = 0;
|
||||
float hInput = 0;
|
||||
@@ -265,6 +276,9 @@ public class AgentControllerV7 : Agent
|
||||
|
||||
public override void Heuristic(in ActionBuffers actionsOut)
|
||||
{
|
||||
if (!isEnabled)
|
||||
return;
|
||||
|
||||
var discreteActionsOut = actionsOut.DiscreteActions;
|
||||
|
||||
discreteActionsOut[0] = 2;
|
||||
@@ -298,6 +312,9 @@ public class AgentControllerV7 : Agent
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision other) {
|
||||
if (!isEnabled)
|
||||
return;
|
||||
|
||||
// if (other.gameObject.tag == "NPC")
|
||||
// {
|
||||
// AddReward(0.1f);
|
||||
|
||||
Reference in New Issue
Block a user