2019-04-10 13:39:36 +02:00
|
|
|
|
using MLAgents;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class CozmoAgent : Agent
|
|
|
|
|
{
|
|
|
|
|
|
2019-05-15 12:07:27 +02:00
|
|
|
|
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
|
|
|
|
}
|