Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to

### Minor Changes
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
- Added DecisionStep parameter to DecisionRequester (#)
- This will allow the staggering of execution timing when using multi-agents, leading to more stable performance.

#### ml-agents / ml-agents-envs
- Added training config feature to evenly distribute checkpoints throughout training. (#5842)
Expand Down
14 changes: 13 additions & 1 deletion com.unity.ml-agents/Runtime/DecisionRequester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ public class DecisionRequester : MonoBehaviour
"of 5 means that the Agent will request a decision every 5 Academy steps.")]
public int DecisionPeriod = 5;

/// <summary>
/// Indicates when to requests a decision. By changing this value, the timing of decision
/// can be shifted even among agents with the same decision period. The value can be
/// from 0 to DecisionPeriod - 1.
/// </summary>
[Range(0, 19)]
[Tooltip("Indicates when to requests a decision. By changing this value, the timing " +
"of decision can be shifted even among agents with the same decision period. " +
"The value can be from 0 to DecisionPeriod - 1.")]
public int DecisionStep = 0;

/// <summary>
/// Indicates whether or not the agent will take an action during the Academy steps where
/// it does not request a decision. Has no effect when DecisionPeriod is set to 1.
Expand All @@ -53,6 +64,7 @@ public Agent Agent

internal void Awake()
{
Debug.Assert(DecisionStep < DecisionPeriod, "DecisionStep must be between 0 than DecisionPeriod - 1.");
m_Agent = gameObject.GetComponent<Agent>();
Debug.Assert(m_Agent != null, "Agent component was not found on this gameObject and is required.");
Academy.Instance.AgentPreStep += MakeRequests;
Expand Down Expand Up @@ -107,7 +119,7 @@ void MakeRequests(int academyStepCount)
/// <returns></returns>
protected virtual bool ShouldRequestDecision(DecisionRequestContext context)
{
return context.AcademyStepCount % DecisionPeriod == 0;
return context.AcademyStepCount % DecisionPeriod == DecisionStep;
}

/// <summary>
Expand Down