45 lines
895 B
C#
Raw Normal View History

2019-04-10 13:39:36 +02:00
using MLAgents;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CozmoAgent : Agent
{
public Camera renderCamera;
public Academy academy;
public float timeBetweenDecisionsAtInference;
private float timeSinceDecision;
public void FixedUpdate()
{
WaitTimeInference();
}
private void WaitTimeInference()
{
if (renderCamera != null)
{
renderCamera.Render();
}
if (!academy.GetIsInference())
{
RequestDecision();
}
else
{
if (timeSinceDecision >= timeBetweenDecisionsAtInference)
{
timeSinceDecision = 0f;
RequestDecision();
}
else
{
timeSinceDecision += Time.fixedDeltaTime;
}
}
}
2019-04-10 13:39:36 +02:00
}