|
|
|
|
|
|
public class BehaviorParameters : MonoBehaviour |
|
|
|
{ |
|
|
|
|
|
|
|
[Serializable] |
|
|
|
private enum BehaviorType |
|
|
|
{ |
|
|
|
Default, |
|
|
|
HeuristicOnly, |
|
|
|
InferenceOnly |
|
|
|
} |
|
|
|
|
|
|
|
[HideInInspector] [SerializeField] |
|
|
|
[HideInInspector] |
|
|
|
[SerializeField] |
|
|
|
[HideInInspector] [SerializeField] |
|
|
|
[HideInInspector] |
|
|
|
[SerializeField] |
|
|
|
[HideInInspector] [SerializeField] |
|
|
|
bool m_UseHeuristic; |
|
|
|
[HideInInspector] [SerializeField] |
|
|
|
[HideInInspector] |
|
|
|
[SerializeField] |
|
|
|
BehaviorType m_BehaviorType; |
|
|
|
[HideInInspector] |
|
|
|
[SerializeField] |
|
|
|
string m_BehaviorName = "My Behavior"; |
|
|
|
|
|
|
|
public BrainParameters brainParameters |
|
|
|
|
|
|
|
|
|
|
public IPolicy GeneratePolicy(Func<float[]> heuristic) |
|
|
|
{ |
|
|
|
if (m_UseHeuristic) |
|
|
|
{ |
|
|
|
return new HeuristicPolicy(heuristic); |
|
|
|
} |
|
|
|
if (FindObjectOfType<Academy>().IsCommunicatorOn) |
|
|
|
{ |
|
|
|
return new RemotePolicy(m_BrainParameters, m_BehaviorName); |
|
|
|
} |
|
|
|
if (m_Model != null) |
|
|
|
{ |
|
|
|
return new BarracudaPolicy(m_BrainParameters, m_Model, m_InferenceDevice); |
|
|
|
} |
|
|
|
else |
|
|
|
switch (m_BehaviorType) |
|
|
|
return new HeuristicPolicy(heuristic); |
|
|
|
case BehaviorType.HeuristicOnly: |
|
|
|
return new HeuristicPolicy(heuristic); |
|
|
|
case BehaviorType.InferenceOnly: |
|
|
|
return new BarracudaPolicy(m_BrainParameters, m_Model, m_InferenceDevice); |
|
|
|
case BehaviorType.Default: |
|
|
|
if (FindObjectOfType<Academy>().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); |
|
|
|
} |
|
|
|
default: |
|
|
|
return new HeuristicPolicy(heuristic); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|