Skip to content

Commit 8c6629f

Browse files
authored
Added DecisionStep parameter to the decision requester (#5939)
* Added DecisionStep parameter to the decision requester * Updated com.unity.ml-agents/Runtime/DecisionRequester.cs * Added DecisionStep parameter to the decision requester - Updated the changelog
1 parent e2e0768 commit 8c6629f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

com.unity.ml-agents/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to
1414

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

1820
#### ml-agents / ml-agents-envs
1921
- Added training config feature to evenly distribute checkpoints throughout training. (#5842)

com.unity.ml-agents/Runtime/DecisionRequester.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ public class DecisionRequester : MonoBehaviour
3030
"of 5 means that the Agent will request a decision every 5 Academy steps.")]
3131
public int DecisionPeriod = 5;
3232

33+
/// <summary>
34+
/// Indicates when to requests a decision. By changing this value, the timing of decision
35+
/// can be shifted even among agents with the same decision period. The value can be
36+
/// from 0 to DecisionPeriod - 1.
37+
/// </summary>
38+
[Range(0, 19)]
39+
[Tooltip("Indicates when to requests a decision. By changing this value, the timing " +
40+
"of decision can be shifted even among agents with the same decision period. " +
41+
"The value can be from 0 to DecisionPeriod - 1.")]
42+
public int DecisionStep = 0;
43+
3344
/// <summary>
3445
/// Indicates whether or not the agent will take an action during the Academy steps where
3546
/// it does not request a decision. Has no effect when DecisionPeriod is set to 1.
@@ -53,6 +64,7 @@ public Agent Agent
5364

5465
internal void Awake()
5566
{
67+
Debug.Assert(DecisionStep < DecisionPeriod, "DecisionStep must be between 0 than DecisionPeriod - 1.");
5668
m_Agent = gameObject.GetComponent<Agent>();
5769
Debug.Assert(m_Agent != null, "Agent component was not found on this gameObject and is required.");
5870
Academy.Instance.AgentPreStep += MakeRequests;
@@ -107,7 +119,7 @@ void MakeRequests(int academyStepCount)
107119
/// <returns></returns>
108120
protected virtual bool ShouldRequestDecision(DecisionRequestContext context)
109121
{
110-
return context.AcademyStepCount % DecisionPeriod == 0;
122+
return context.AcademyStepCount % DecisionPeriod == DecisionStep;
111123
}
112124

113125
/// <summary>

0 commit comments

Comments
 (0)