浏览代码

default discrete action is now 0

bug fix for discrete broadcast action (the action size should be one in Agents.cs)
modified Tennis so that the default action is no action
modified the TemplateDecsion.cs to ensure non null values are sent from Decide() and MakeMemory()
/develop-generalizationTraining-TrainerController
vincentpierre 7 年前
当前提交
4d3716fe
共有 5 个文件被更改,包括 160 次插入118 次删除
  1. 6
      unity-environment/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  2. 242
      unity-environment/Assets/ML-Agents/Examples/Tennis/Tennis.unity
  3. 9
      unity-environment/Assets/ML-Agents/Scripts/Agent.cs
  4. 2
      unity-environment/Assets/ML-Agents/Scripts/CoreBrainPlayer.cs
  5. 19
      unity-environment/Assets/ML-Agents/Template/Scripts/TemplateDecision.cs

6
unity-environment/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


{
float moveX = 0.0f;
float moveY = 0.0f;
if (act[0] == 0f)
if (act[0] == 1f)
if (act[0] == 1f)
if (act[0] == 2f)
if (act[0] == 2f)
if (act[0] == 0f)
{
moveX = 0.0f;
}

242
unity-environment/Assets/ML-Agents/Examples/Tennis/Tennis.unity


tileSize: 256
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!114 &2702986
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 1948813725}
--- !u!114 &21374022
--- !u!114 &10967279
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)
continuousPlayerActions:
- key: 97
index: 0
value: -1
- key: 100
index: 0
value: 1
- key: 0
index: 0
value: 0
- key: 0
index: 0
value: 0
discretePlayerActions:
- key: 97
value: 0
- key: 100
value: 1
- key: 0
value: 0
- key: 32
value: 3
defaultAction: -1
brain: {fileID: 1948813725}
graphModel: {fileID: 0}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
StatePlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
ObservationPlaceholderName: []
ActionPlaceholderName: action
brain: {fileID: 0}
--- !u!1 &26143720
GameObject:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 36699497}
--- !u!114 &86818458
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 459283648}
--- !u!1 &459283646
GameObject:
m_ObjectHideFlags: 0

stateSpaceType: 1
brainType: 2
CoreBrains:
- {fileID: 1364070226}
- {fileID: 86818458}
- {fileID: 1447029077}
- {fileID: 532686528}
instanceID: 10250
--- !u!114 &532686528
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3}
m_Name: (Clone)(Clone)
m_EditorClassIdentifier:
graphModel: {fileID: 4900000, guid: c917523464309409996933c3b7063a9f, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
StatePlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
ObservationPlaceholderName: []
ActionPlaceholderName: action
brain: {fileID: 459283648}
- {fileID: 1308476791}
- {fileID: 1784104787}
- {fileID: 1864001037}
- {fileID: 1245752352}
instanceID: 19292
--- !u!1 &629009137
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: e51a3fb0b3186433ea84fc1e0549cc91, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 459283648}
brain: {fileID: 1948813725}
observations: []
maxStep: 5000
resetOnDone: 1

m_Interpolate: 0
m_Constraints: 122
m_CollisionDetection: 0
--- !u!114 &668404469
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 0}
--- !u!1 &731033571
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 05eee2a5536934f5684a65f151efd304, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1245752352
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
graphModel: {fileID: 4900000, guid: c917523464309409996933c3b7063a9f, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
StatePlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
ObservationPlaceholderName: []
ActionPlaceholderName: action
brain: {fileID: 459283648}
--- !u!114 &1247671385
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 1948813725}
--- !u!1 &1261870887
GameObject:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1261870887}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &1364070226
--- !u!114 &1308476791
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
value: 0
value: 1
value: 1
value: 2
defaultAction: -1
defaultAction: 0
--- !u!114 &1447029077
--- !u!114 &1344977993
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
brain: {fileID: 459283648}
brain: {fileID: 1948813725}
--- !u!1 &1605015604
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 60, y: 30, z: 0}
--- !u!114 &1784104787
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 459283648}
--- !u!1 &1838949272
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 2097046871}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!114 &1864001037
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 459283648}
--- !u!1 &1871669621
GameObject:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1871669621}
--- !u!114 &1880810220
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
continuousPlayerActions:
- key: 97
index: 0
value: -1
- key: 100
index: 0
value: 1
- key: 0
index: 0
value: 0
- key: 0
index: 0
value: 0
discretePlayerActions:
- key: 97
value: 1
- key: 100
value: 2
- key: 0
value: 0
- key: 32
value: 3
defaultAction: 0
brain: {fileID: 1948813725}
--- !u!1 &1948813723
GameObject:
m_ObjectHideFlags: 0

m_Component:
- component: {fileID: 1948813724}
- component: {fileID: 1948813725}
- component: {fileID: 1948813726}
m_Layer: 0
m_Name: MyBrain
m_TagString: Untagged

-
actionSpaceType: 0
stateSpaceType: 1
brainType: 0
brainType: 1
- {fileID: 21374022}
- {fileID: 668404469}
- {fileID: 2702986}
instanceID: 12574
- {fileID: 1880810220}
- {fileID: 1344977993}
- {fileID: 1247671385}
- {fileID: 10967279}
instanceID: 19482
--- !u!114 &1948813726
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1948813723}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3e2acdaec6974f37a5ca11872f71ae8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2073469450
GameObject:
m_ObjectHideFlags: 0

9
unity-environment/Assets/ML-Agents/Scripts/Agent.cs


if (brain != null)
{
brain.agents.Add(id, gameObject.GetComponent<Agent>());
agentStoredAction = new float[brain.brainParameters.actionSize];
if (brain.brainParameters.actionSpaceType == StateType.continuous)
{
agentStoredAction = new float[brain.brainParameters.actionSize];
}
else
{
agentStoredAction = new float[1];
}
memory = new float[brain.brainParameters.memorySize];
}
InitializeAgent();

2
unity-environment/Assets/ML-Agents/Scripts/CoreBrainPlayer.cs


/// Contains the mapping from input to discrete actions
private DiscretePlayerAction[] discretePlayerActions;
[SerializeField]
private int defaultAction = -1;
private int defaultAction = 0;
/// Reference to the brain that uses this CoreBrainPlayer
public Brain brain;

19
unity-environment/Assets/ML-Agents/Template/Scripts/TemplateDecision.cs


using System.Collections.Generic;
using UnityEngine;
public class TemplateDecision : MonoBehaviour, Decision {
public class TemplateDecision : MonoBehaviour, Decision
{
public float[] Decide (List<float> state, List<Camera> observation, float reward, bool done, float[] memory)
{
return default(float[]);
public float[] Decide(List<float> state, List<Camera> observation, float reward, bool done, float[] memory)
{
return new float[0];
}
}
public float[] MakeMemory (List<float> state, List<Camera> observation, float reward, bool done, float[] memory)
{
return default(float[]);
public float[] MakeMemory(List<float> state, List<Camera> observation, float reward, bool done, float[] memory)
{
return new float[0];
}
}
}
正在加载...
取消
保存