using Barracuda;
using System;
using UnityEngine;
namespace MLAgents
{
///
/// The Factory to generate policies.
///
public class BehaviorParameters : MonoBehaviour
{
[HideInInspector]
[SerializeField]
BrainParameters m_BrainParameters = new BrainParameters();
[HideInInspector] [SerializeField]
NNModel m_Model;
[HideInInspector] [SerializeField]
InferenceDevice m_InferenceDevice;
[HideInInspector] [SerializeField]
bool m_UseHeuristic;
[HideInInspector] [SerializeField]
string m_BehaviorName = "My Behavior";
public BrainParameters brainParameters
{
get { return m_BrainParameters; }
}
public string behaviorName
{
get { return m_BehaviorName; }
}
public IPolicy GeneratePolicy(Func heuristic)
{
if (m_UseHeuristic)
{
return new HeuristicPolicy(heuristic);
}
if (FindObjectOfType().IsCommunicatorOn)
{
return new RemotePolicy(m_BrainParameters, m_BehaviorName);
}
if (m_Model != null)
{
return new BarracudaPolicy(m_BrainParameters, m_Model, m_InferenceDevice);
}
else
{
return new HeuristicPolicy(heuristic);
}
}
public void GiveModel(
string behaviorName,
NNModel model,
InferenceDevice inferenceDevice = InferenceDevice.CPU)
{
m_Model = model;
m_InferenceDevice = inferenceDevice;
m_BehaviorName = behaviorName;
}
}
}