|
|
|
|
|
|
public int maxStep; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The team ID for this Agent.
|
|
|
|
/// </summary>
|
|
|
|
public int TeamId |
|
|
|
{ |
|
|
|
// TODO should we remove this and BehaviorName properties,
|
|
|
|
// and add properties in BehaviorParameters instead?
|
|
|
|
get |
|
|
|
{ |
|
|
|
LazyInitialize(); |
|
|
|
return m_PolicyFactory.TeamId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The name of the behavior of the Agent.
|
|
|
|
/// </summary>
|
|
|
|
public string BehaviorName |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
LazyInitialize(); |
|
|
|
return m_PolicyFactory.behaviorName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[SerializeField][HideInInspector] |
|
|
|
internal AgentParameters agentParameters; |
|
|
|
[SerializeField][HideInInspector] |
|
|
|
|
|
|
/// Updates the Model for the agent. Any model currently assigned to the
|
|
|
|
/// agent will be replaced with the provided one. If the arguments are
|
|
|
|
/// identical to the current parameters of the agent, the model will
|
|
|
|
/// remain unchanged, unless the force parameter is true.
|
|
|
|
/// remain unchanged.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="behaviorName"> The identifier of the behavior. This
|
|
|
|
/// will categorize the agent when training.
|
|
|
|
|
|
|
/// will be run.</param>
|
|
|
|
/// <param name="force">Whether to update the Agent even if all the parameters are the same.</param>
|
|
|
|
InferenceDevice inferenceDevice = InferenceDevice.CPU, |
|
|
|
bool force = false) |
|
|
|
InferenceDevice inferenceDevice = InferenceDevice.CPU) |
|
|
|
if (!force) |
|
|
|
{ |
|
|
|
// If everything is the same, don't make any changes.
|
|
|
|
return; |
|
|
|
} |
|
|
|
// If everything is the same, don't make any changes.
|
|
|
|
return; |
|
|
|
m_PolicyFactory.SetModel(behaviorName, model, inferenceDevice); |
|
|
|
m_Brain?.Dispose(); |
|
|
|
m_Brain = m_PolicyFactory.GeneratePolicy(Heuristic); |
|
|
|
m_PolicyFactory.model = model; |
|
|
|
m_PolicyFactory.inferenceDevice = inferenceDevice; |
|
|
|
m_PolicyFactory.behaviorName = behaviorName; |
|
|
|
ReloadPolicy(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
/// <param name="force">Whether to update the Agent even if all the parameters are the same.</param>
|
|
|
|
public void SetBehaviorType(BehaviorType behaviorType, bool force = false) |
|
|
|
public void SetBehaviorType(BehaviorType behaviorType) |
|
|
|
if (m_PolicyFactory.behaviorType == behaviorType && !force) |
|
|
|
if (m_PolicyFactory.behaviorType == behaviorType) |
|
|
|
ReloadPolicy(); |
|
|
|
} |
|
|
|
|
|
|
|
internal void ReloadPolicy() |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|