|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Register the agent to the MultiAgentGroup.
|
|
|
|
/// Registered agents will be able to receive group rewards from the MultiAgentGroup
|
|
|
|
/// and share observations during training.
|
|
|
|
/// </summary>
|
|
|
|
/// <inheritdoc />
|
|
|
|
public virtual void RegisterAgent(Agent agent) |
|
|
|
{ |
|
|
|
if (!m_Agents.Contains(agent)) |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Remove the agent from the MultiAgentGroup.
|
|
|
|
/// </summary>
|
|
|
|
/// <inheritdoc />
|
|
|
|
public virtual void UnregisterAgent(Agent agent) |
|
|
|
{ |
|
|
|
if (m_Agents.Contains(agent)) |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public int GetId() |
|
|
|
{ |
|
|
|
return m_Id; |
|
|
|
|
|
|
/// Get list of all agents registered to this MultiAgentGroup.
|
|
|
|
/// Get list of all agents currently registered to this MultiAgentGroup.
|
|
|
|
/// List of agents belongs to the MultiAgentGroup.
|
|
|
|
/// List of agents registered to the MultiAgentGroup.
|
|
|
|
/// </returns>
|
|
|
|
public List<Agent> GetRegisteredAgents() |
|
|
|
{ |
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Add group reward for all agents under this MultiAgentGroup.
|
|
|
|
/// Disabled agent will not receive this reward.
|
|
|
|
/// Increments the group rewards for all agents in this MultiAgentGroup.
|
|
|
|
/// <remarks>
|
|
|
|
/// This function increase or decrease the group rewards by given amount for all agents
|
|
|
|
/// in the group. Use <see cref="SetGroupReward(float)"/> to set the group reward assigned
|
|
|
|
/// to the current step with a specific value rather than increasing or decreasing it.
|
|
|
|
///
|
|
|
|
/// A positive group reward indicates the whole group's accomplishments or desired behaviors.
|
|
|
|
/// Every agent in the group will receive the same group reward no matter whether the
|
|
|
|
/// agent's act directly leads to the reward. Group rewards are meant to reinforce agents
|
|
|
|
/// to act in the group's best interest instead of indivisual ones.
|
|
|
|
/// Group rewards are treated differently than individual agent rewards during training, so
|
|
|
|
/// calling AddGroupReward() is not equivalent to calling agent.AddReward() on each agent in the group.
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="reward">Incremental group reward value.</param>
|
|
|
|
public void AddGroupReward(float reward) |
|
|
|
{ |
|
|
|
foreach (var agent in m_Agents) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Set group reward for all agents under this MultiAgentGroup.
|
|
|
|
/// Disabled agent will not receive this reward.
|
|
|
|
/// Set the group rewards for all agents in this MultiAgentGroup.
|
|
|
|
/// <remarks>
|
|
|
|
/// This function replaces any group rewards given during the current step for all agents in the group.
|
|
|
|
/// Use <see cref="AddGroupReward(float)"/> to incrementally change the group reward rather than
|
|
|
|
/// overriding it.
|
|
|
|
///
|
|
|
|
/// A positive group reward indicates the whole group's accomplishments or desired behaviors.
|
|
|
|
/// Every agent in the group will receive the same group reward no matter whether the
|
|
|
|
/// agent's act directly leads to the reward. Group rewards are meant to reinforce agents
|
|
|
|
/// to act in the group's best interest instead of indivisual ones.
|
|
|
|
/// Group rewards are treated differently than individual agent rewards during training, so
|
|
|
|
/// calling SetGroupReward() is not equivalent to calling agent.SetReward() on each agent in the group.
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="reward">The new value of the group reward.</param>
|
|
|
|
public void SetGroupReward(float reward) |
|
|
|
{ |
|
|
|
foreach (var agent in m_Agents) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the current step counter (within the current episode).
|
|
|
|
/// End episodes for all agents in this MultiAgentGroup.
|
|
|
|
/// <remarks>
|
|
|
|
/// This should be used when the episode can no longer continue, such as when the group
|
|
|
|
/// reaches the goal or fails at the task.
|
|
|
|
/// </remarks>
|
|
|
|
public void EndGroupEpisode() |
|
|
|
{ |
|
|
|
foreach (var agent in m_Agents) |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// End Episode for all agents under this MultiAgentGroup.
|
|
|
|
/// Indicate that the episode is over but not due to the "fault" of the group.
|
|
|
|
/// This has the same end result as calling <see cref="EndGroupEpisode"/>, but has a
|
|
|
|
/// slightly different effect on training.
|
|
|
|
/// <remarks>
|
|
|
|
/// This should be used when the episode could continue, but has gone on for
|
|
|
|
/// a sufficient number of steps.
|
|
|
|
/// </remarks>
|
|
|
|
public void GroupEpisodeInterrupted() |
|
|
|
{ |
|
|
|
foreach (var agent in m_Agents) |
|
|
|