Skip to content

Commit 45e475f

Browse files
Make the demoRecorder write the experience on reset (#3463)
* Make the demoRecorder write the experience on reset * do nothing if demostore is null * Calling reset data if the action is null
1 parent 76181f1 commit 45e475f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ void NotifyAgentDone(bool maxStepReached = false)
275275
// We request a decision so Python knows the Agent is done immediately
276276
m_Brain?.RequestDecision(m_Info, sensors);
277277

278+
if (m_Recorder != null && m_Recorder.record && Application.isEditor)
279+
{
280+
m_Recorder.WriteExperience(m_Info, sensors);
281+
}
282+
278283
UpdateRewardStats();
279284

280285
// The Agent is done, so we give it a new episode Id
@@ -702,16 +707,16 @@ void AgentStep()
702707
if ((m_RequestAction) && (m_Brain != null))
703708
{
704709
m_RequestAction = false;
705-
if (m_Action.vectorActions != null)
706-
{
707-
AgentAction(m_Action.vectorActions);
708-
}
710+
AgentAction(m_Action.vectorActions);
709711
}
710712
}
711713

712714
void DecideAction()
713715
{
714716
m_Action.vectorActions = m_Brain?.DecideAction();
717+
if (m_Action.vectorActions == null){
718+
ResetData();
719+
}
715720
}
716721
}
717722
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static string SanitizeName(string demoName, int maxNameLength)
6969
/// </summary>
7070
public void WriteExperience(AgentInfo info, List<ISensor> sensors)
7171
{
72-
m_DemoStore.Record(info, sensors);
72+
m_DemoStore?.Record(info, sensors);
7373
}
7474

7575
public void Close()

0 commit comments

Comments
 (0)