-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[change] Make Agent non-abstract, update Basic scene. #3528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/// Observations are generated by the attached SensorComponent, and the actions | ||
/// are retrieved from the Agent. | ||
/// </summary> | ||
public class BasicAgent : MonoBehaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BasicController? BasicPlayer? BasicAI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BasicController
largeGoal.transform.position = new Vector3(m_LargeGoalPosition - 10f, 0f, 0f); | ||
} | ||
|
||
public override float[] Heuristic() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this since I don't want to inherit from Agent. I don't think it was getting us much.
@@ -92,16 +85,21 @@ public void FixedUpdate() | |||
|
|||
void WaitTimeInference() | |||
{ | |||
if (!Academy.Instance.IsCommunicatorOn) | |||
if (Academy.Instance.IsCommunicatorOn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic got flipped here accidentally at some point. Now training steps quickly and inference takes its time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😨
@@ -1,7 +1,9 @@ | |||
namespace MLAgents.Sensors | |||
using MLAgents.Sensors; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: moved out of com.unity.ml-agents
com.unity.ml-agents/Runtime/Agent.cs
Outdated
throw new UnityAgentsException( | ||
"The Heuristic method was not implemented for the Agent on the " + | ||
$"{gameObject.name} GameObject."); | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to keep this usable without inheriting, I think we need to remove this exception. Will to be overruled though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to remove it? If Heuristic is called but not implemented, an error should be raised. Or should be make a Heuristic component?
Other question, is it okay for it to be null? Does that break something down the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a log warning instead of an exception?
is it okay for it to be null?
I think that would depend on the AgentAction implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool!
$"{gameObject.name} GameObject."); | ||
Debug.LogWarning("Heuristic method called but not implemented. Return placeholder actions."); | ||
var param = m_PolicyFactory.brainParameters; | ||
var actionSize = param.vectorActionSpaceType == SpaceType.Continuous ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like this should be a property on brainParameters since we do it in ResetData() too :
ml-agents/com.unity.ml-agents/Runtime/Agent.cs
Lines 443 to 452 in 78a218b
if (param.vectorActionSpaceType == SpaceType.Continuous) | |
{ | |
m_Action.vectorActions = new float[param.vectorActionSize[0]]; | |
m_Info.storedVectorActions = new float[param.vectorActionSize[0]]; | |
} | |
else | |
{ | |
m_Action.vectorActions = new float[param.vectorActionSize.Length]; | |
m_Info.storedVectorActions = new float[param.vectorActionSize.Length]; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int BrainParameters.ActionAllocationSize()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, vectorActionSize should be an int and in discrete control only there should be an array of ints called discreteActionBrancheSizes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a bigger change that's out of scope for this PR. Are you OK leaving this code as is, or do you think a utility method/property would be cleaner?
$"{gameObject.name} GameObject."); | ||
Debug.LogWarning("Heuristic method called but not implemented. Return placeholder actions."); | ||
var param = m_PolicyFactory.brainParameters; | ||
var actionSize = param.vectorActionSpaceType == SpaceType.Continuous ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, vectorActionSize should be an int and in discrete control only there should be an array of ints called discreteActionBrancheSizes.
/// Observations are generated by the attached SensorComponent, and the actions | ||
/// are retrieved from the Agent. | ||
/// </summary> | ||
public class BasicAgent : MonoBehaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BasicController
Proposed change(s)
Agent.GetAction()
and uses a SensorComponent instead of CollectObservationsUseful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
Types of change(s)
Checklist
Other comments