浏览代码

Add group ID

/comms-grad
Ervin Teng 4 年前
当前提交
f74e9a54
共有 3 个文件被更改,包括 18 次插入4 次删除
  1. 1
      com.unity.ml-agents/Editor/BehaviorParametersEditor.cs
  2. 9
      com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
  3. 12
      ml-agents/mlagents/trainers/behavior_id_utils.py

1
com.unity.ml-agents/Editor/BehaviorParametersEditor.cs


needPolicyUpdate = needPolicyUpdate || EditorGUI.EndChangeCheck();
EditorGUILayout.PropertyField(so.FindProperty("TeamId"));
EditorGUILayout.PropertyField(so.FindProperty("GroupId"));
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());
{
EditorGUILayout.PropertyField(so.FindProperty("m_UseChildSensors"), true);

9
com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs


/// </summary>
[HideInInspector, SerializeField, FormerlySerializedAs("m_TeamID")]
public int TeamId;
/// <summary>
/// The group ID for this behavior.
/// </summary>
[HideInInspector, SerializeField]
[Tooltip("Assign the same Group ID to all Agents in the same Area.")]
public int GroupId;
// TODO properties here instead of Agent
[FormerlySerializedAs("m_useChildSensors")]

/// </summary>
public string FullyQualifiedBehaviorName
{
get { return m_BehaviorName + "?team=" + TeamId; }
get { return m_BehaviorName + "?team=" + TeamId + "&group=" + GroupId; }
}
internal IPolicy GeneratePolicy(ActionSpec actionSpec, HeuristicPolicy.ActionGenerator heuristic)

12
ml-agents/mlagents/trainers/behavior_id_utils.py


behavior_id: str
brain_name: str
team_id: int
group_id: int
Parses a name_behavior_id of the form name?team=0
Parses a name_behavior_id of the form name?team=0&group=0
group_id: int = 0
if "group" in ids:
group_id = int(ids["group"][0])
behavior_id=name_behavior_id, brain_name=name, team_id=team_id
behavior_id=name_behavior_id,
brain_name=name,
team_id=team_id,
group_id=group_id,
)

正在加载...
取消
保存