浏览代码

Merge branch 'development-0.3' into dev-api-doc-academy

# Conflicts:
#	unity-environment/Assets/ML-Agents/Editor/MLAgentsEditModeTest.cs
#	unity-environment/Assets/ML-Agents/Examples/Basic/Scripts/BasicAgent.cs
#	unity-environment/Assets/ML-Agents/Scripts/Academy.cs
/develop-generalizationTraining-TrainerController
Marwan Mattar 7 年前
当前提交
ba6911c3
共有 60 个文件被更改,包括 3204 次插入2451 次删除
  1. 18
      docs/ML-Agents-Overview.md
  2. 1
      docs/Readme.md
  3. 2
      python/unitytrainers/ppo/trainer.py
  4. 22
      unity-environment/Assets/ML-Agents/Editor/AgentEditor.cs
  5. 50
      unity-environment/Assets/ML-Agents/Editor/BrainEditor.cs
  6. 2
      unity-environment/Assets/ML-Agents/Editor/MLAgentsEditModeTest.cs
  7. 34
      unity-environment/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DDecision.cs
  8. 18
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Area.cs
  9. 34
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/AreaAgent.cs
  10. 14
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/AreaDecision.cs
  11. 2
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/GoalInteract.cs
  12. 12
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Push/PushAcademy.cs
  13. 42
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Push/PushAgent.cs
  14. 24
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Push/PushArea.cs
  15. 10
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Wall/WallAcademy.cs
  16. 46
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Wall/WallAgent.cs
  17. 24
      unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Wall/WallArea.cs
  18. 4
      unity-environment/Assets/ML-Agents/Examples/Banana/Scripts/BananaAgent.cs
  19. 18
      unity-environment/Assets/ML-Agents/Examples/Banana/Scripts/BananaLogic.cs
  20. 12
      unity-environment/Assets/ML-Agents/Examples/Basic/Scripts/BasicAcademy.cs
  21. 12
      unity-environment/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAcademy.cs
  22. 22
      unity-environment/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs
  23. 8
      unity-environment/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerBanana.cs
  24. 22
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CameraFollow.cs
  25. 114
      unity-environment/Assets/ML-Agents/Examples/GridWorld/GridWorld.unity
  26. 993
      unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_3x3.bytes
  27. 6
      unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_3x3.bytes.meta
  28. 977
      unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_5x5.bytes
  29. 6
      unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_5x5.bytes.meta
  30. 14
      unity-environment/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAcademy.cs
  31. 51
      unity-environment/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
  32. 152
      unity-environment/Assets/ML-Agents/Examples/Reacher/Scene.unity
  33. 22
      unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/FlyCamera.cs
  34. 12
      unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs
  35. 5
      unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs
  36. 12
      unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherDecision.cs
  37. 18
      unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherGoal.cs
  38. 30
      unity-environment/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab
  39. 16
      unity-environment/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs
  40. 216
      unity-environment/Assets/ML-Agents/Examples/Tennis/Scripts/hitWall.cs
  41. 979
      unity-environment/Assets/ML-Agents/Examples/Tennis/TFModels/Tennis.bytes
  42. 6
      unity-environment/Assets/ML-Agents/Examples/Tennis/TFModels/Tennis.bytes.meta
  43. 344
      unity-environment/Assets/ML-Agents/Examples/Tennis/Tennis.unity
  44. 4
      unity-environment/Assets/ML-Agents/Scripts/Academy.cs
  45. 18
      unity-environment/Assets/ML-Agents/Scripts/Agent.cs
  46. 14
      unity-environment/Assets/ML-Agents/Scripts/BCTeacherHelper.cs
  47. 8
      unity-environment/Assets/ML-Agents/Scripts/Brain.cs
  48. 2
      unity-environment/Assets/ML-Agents/Scripts/Communicator.cs
  49. 39
      unity-environment/Assets/ML-Agents/Scripts/CoreBrainHeuristic.cs
  50. 22
      unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs
  51. 2
      unity-environment/Assets/ML-Agents/Scripts/CoreBrainPlayer.cs
  52. 28
      unity-environment/Assets/ML-Agents/Scripts/Decision.cs
  53. 2
      unity-environment/Assets/ML-Agents/Scripts/ExternalCommunicator.cs
  54. 12
      unity-environment/Assets/ML-Agents/Template/Scripts/TemplateAcademy.cs
  55. 20
      unity-environment/Assets/ML-Agents/Template/Scripts/TemplateAgent.cs
  56. 2
      unity-environment/Assets/ML-Agents/Template/Scripts/TemplateDecision.cs
  57. 37
      docs/Learning-Environment-On-Demand-Decision.md
  58. 47
      docs/Training-LSTM.md
  59. 911
      docs/images/ml-agents-LSTM.png
  60. 61
      docs/images/ml-agents-ODD.png

18
docs/ML-Agents-Overview.md


The [Imitation Learning](Training-Imitation-Learning.md) tutorial covers this training
mode with the **Anti-Graviator** sample environment.
### Recurrent Neural Networks
In some scenarios, agents must learn to remember the past in order to take the
best decision. When an agent only has partial observability of the environment,
keeping track of past observations can help the agent learn. We provide an
implementation of [LSTM](https://en.wikipedia.org/wiki/Long_short-term_memory) in
our trainers that enable the agent to store memories to be used in future steps.
The [Training with LSTM](Training-LSTM.md) tutorial covers this feature and
the **Hallway** environment demonstrates its capabilities.
## Flexible Training Scenarios
While the discussion so-far has mostly focused on training a single agent, with

However, this could also be helpful for the Heuristic and Internal Brains,
particularly when debugging agent behaviors. You can learn more about using
the broadcasting feature [here](Feature-Broadcasting.md).
* **On Demand Decision** - With ML-Agents it is possible to have agents
request decisions only when needed as opposed to requesting decisions at
every step. This enables training of turn based games, games where agents
must react to events or games where agents can take actions of variable
duration. Switching between decision taking at every step and
on-demand-decision is one button click away. You can learn more about the
on-demand-decision feature [here](Learning-Environment-On-Demand-Decision)

1
docs/Readme.md


* [Training with Proximal Policy Optimization](Training-PPO.md)
* [Training with Curriculum Learning](Training-Curriculum-Learning.md)
* [Training with Imitation Learning](Training-Imitation-Learning.md)
* [Training with LSTM](Training-LSTM.md)
* [Training on the Cloud with Amazon Web Services](Training-on-Amazon-Web-Service.md)
* [Using TensorBoard to Observe Training](Using-Tensorboard.md)

2
python/unitytrainers/ppo/trainer.py


values = self.sess.run(run_list, feed_dict=feed_dict)
run_out = dict(zip(run_list, values))
self.stats['value_estimate'].append(run_out[self.model.value].mean())
self.stats['entropy'].append(run_out[self.model.entropy])
self.stats['entropy'].append(run_out[self.model.entropy].mean())
self.stats['learning_rate'].append(run_out[self.model.learning_rate])
if self.use_recurrent:
return (run_out[self.model.output],

22
unity-environment/Assets/ML-Agents/Editor/AgentEditor.cs


EditorGUILayout.PropertyField(brain);
EditorGUILayout.LabelField("Agent Cameras");
for (int i = 0; i < cameras.arraySize; i++)
{
EditorGUILayout.PropertyField(cameras.GetArrayElementAtIndex(i), new GUIContent("Camera " + (i + 1).ToString() + ": "));
}
for (int i = 0; i < cameras.arraySize; i++)
{
EditorGUILayout.PropertyField(cameras.GetArrayElementAtIndex(i), new GUIContent("Camera " + (i + 1).ToString() + ": "));
}
if (GUILayout.Button("Remove Camera", EditorStyles.miniButton))
{
cameras.arraySize--;
}
if (GUILayout.Button("Remove Camera", EditorStyles.miniButton))
{
cameras.arraySize--;
}
"The per-agent maximum number of steps."));
"The per-agent maximum number of steps."));
EditorGUILayout.PropertyField(isResetOnDone, new GUIContent("Reset On Done",
"If checked, the agent will reset on done. Else, AgentOnDone() will be called."));
EditorGUILayout.PropertyField(isEBS, new GUIContent("On Demand Decision", "If checked, you must manually request decisions."));

actionsPerDecision.intValue = Mathf.Max(1, actionsPerDecision.intValue);
}
serializedAgent.ApplyModifiedProperties();
serializedAgent.ApplyModifiedProperties();
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
base.OnInspectorGUI();

50
unity-environment/Assets/ML-Agents/Editor/BrainEditor.cs


[SerializeField]
bool _Foldout = true;
public override void OnInspectorGUI ()
{
Brain myBrain = (Brain)target;
SerializedObject serializedBrain = serializedObject;
public override void OnInspectorGUI ()
{
Brain myBrain = (Brain)target;
SerializedObject serializedBrain = serializedObject;
if (myBrain.transform.parent == null) {
EditorGUILayout.HelpBox ("A Brain GameObject must be a child of an Academy GameObject!", MessageType.Error);
} else if (myBrain.transform.parent.GetComponent<Academy> () == null) {
EditorGUILayout.HelpBox ("The Parent of a Brain must have an Academy Component attached to it!", MessageType.Error);
}
if (myBrain.transform.parent == null) {
EditorGUILayout.HelpBox ("A Brain GameObject must be a child of an Academy GameObject!", MessageType.Error);
} else if (myBrain.transform.parent.GetComponent<Academy> () == null) {
EditorGUILayout.HelpBox ("The Parent of a Brain must have an Academy Component attached to it!", MessageType.Error);
}
BrainParameters parameters = myBrain.brainParameters;
BrainParameters parameters = myBrain.brainParameters;
serializedBrain.Update();
serializedBrain.Update();
_Foldout = EditorGUILayout.Foldout(_Foldout, "Brain Parameters");
int indentLevel = EditorGUI.indentLevel;

}
EditorGUI.indentLevel = indentLevel;
SerializedProperty bt = serializedBrain.FindProperty("brainType");
EditorGUILayout.PropertyField(bt);
SerializedProperty bt = serializedBrain.FindProperty("brainType");
EditorGUILayout.PropertyField(bt);
if (bt.enumValueIndex < 0) {
bt.enumValueIndex = (int)BrainType.Player;
}
if (bt.enumValueIndex < 0) {
bt.enumValueIndex = (int)BrainType.Player;
}
serializedBrain.ApplyModifiedProperties();
serializedBrain.ApplyModifiedProperties();
myBrain.UpdateCoreBrains ();
myBrain.coreBrain.OnInspector ();
myBrain.UpdateCoreBrains ();
myBrain.coreBrain.OnInspector ();
#if !NET_4_6 && ENABLE_TENSORFLOW
EditorGUILayout.HelpBox ("You cannot have ENABLE_TENSORFLOW without NET_4_6", MessageType.Error);
#endif
}
#if !NET_4_6 && ENABLE_TENSORFLOW
EditorGUILayout.HelpBox ("You cannot have ENABLE_TENSORFLOW without NET_4_6", MessageType.Error);
#endif
}
}

2
unity-environment/Assets/ML-Agents/Editor/MLAgentsEditModeTest.cs


using UnityEngine;
using UnityEngine;
using NUnit.Framework;
using System.Reflection;

34
unity-environment/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DDecision.cs


public class Ball3DDecision : MonoBehaviour, Decision
{
public float rotationSpeed = 2f;
List<float> ret = new List<float>();
if (state[2] < 0 || state[5] < 0)
{
ret.Add(state[5]);
}
else
{
ret.Add(state[5]);
}
if (state[3] < 0 || state[7] < 0)
{
ret.Add(-state[7]);
}
else
{
ret.Add(-state[7]);
}
return ret.ToArray();
List<float> act = new List<float>();
// state[5] is the velocity of the ball in the x orientation.
// We use this number to control the Platform's z axis rotation speed,
// so that the Platform is tilted in the x orientation correspondingly.
act.Add(state[5] * rotationSpeed);
// state[7] is the velocity of the ball in the z orientation.
// We use this number to control the Platform's x axis rotation speed,
// so that the Platform is tilted in the z orientation correspondingly.
act.Add(-state[7] * rotationSpeed);
return act.ToArray();
// If the vector action space type is discrete, then we don't do anything.
else
{
return new float[1]{ 1f };

18
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Area.cs


public class Area : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public virtual void ResetArea() {

34
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/AreaAgent.cs


public override void CollectObservations()
{
Vector3 velocity = GetComponent<Rigidbody>().velocity;
AddVectorObs((transform.position.x - area.transform.position.x));
AddVectorObs((transform.position.y - area.transform.position.y));
AddVectorObs((transform.position.z + 5 - area.transform.position.z));
AddVectorObs(velocity.x);
AddVectorObs(velocity.y);
AddVectorObs(velocity.z);
}
AddVectorObs((transform.position.x - area.transform.position.x));
AddVectorObs((transform.position.y - area.transform.position.y));
AddVectorObs((transform.position.z + 5 - area.transform.position.z));
AddVectorObs(velocity.x);
AddVectorObs(velocity.y);
AddVectorObs(velocity.z);
}
public void MoveAgent(float[] act) {
float directionX = 0;

AddReward(-0.005f);
MoveAgent(vectorAction);
if (gameObject.transform.position.y < 0.0f || Mathf.Abs(gameObject.transform.position.x - area.transform.position.x) > 8f ||
if (gameObject.transform.position.y < 0.0f || Mathf.Abs(gameObject.transform.position.x - area.transform.position.x) > 8f ||
{
{
}
}
}
}
public override void AgentReset()
{
transform.position = new Vector3(Random.Range(-3.5f, 3.5f), 1.1f, -8f) + area.transform.position;
GetComponent<Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
public override void AgentReset()
{
transform.position = new Vector3(Random.Range(-3.5f, 3.5f), 1.1f, -8f) + area.transform.position;
GetComponent<Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
area.GetComponent<Area>().ResetArea();
}
area.GetComponent<Area>().ResetArea();
}
}

14
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/AreaDecision.cs


public class AreaDecision : MonoBehaviour, Decision {
public float[] Decide (List<float> state, List<Texture2D> observation, float reward, bool done, List<float> memory)
{
{
}
}
public List<float> MakeMemory (List<float> state, List<Texture2D> observation, float reward, bool done, List<float> memory)
{
return new List<float>();
}
public List<float> MakeMemory (List<float> state, List<Texture2D> observation, float reward, bool done, List<float> memory)
{
return new List<float>();
}
}

2
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/GoalInteract.cs


agent.Done();
agent.AddReward(1f);
}
}
}
}

12
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Push/PushAcademy.cs


public float blockSize;
public float xVariation;
public override void AcademyReset()
{
public override void AcademyReset()
{
}
}
public override void AcademyStep()
{
public override void AcademyStep()
{
}
}
}

42
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Push/PushAgent.cs


public class PushAgent : AreaAgent
{
public GameObject goalHolder;
public GameObject goalHolder;
public GameObject block;
Rigidbody rb;

public override void InitializeAgent()
{
base.InitializeAgent();
base.InitializeAgent();
public override void CollectObservations()
{
public override void CollectObservations()
{
velocity = rb.velocity;
blockVelocity = block.GetComponent<Rigidbody>().velocity;
AddVectorObs((transform.position.x - area.transform.position.x));

AddVectorObs((block.transform.position.y - area.transform.position.y));
AddVectorObs((block.transform.position.z + 5 - area.transform.position.z));
AddVectorObs(velocity.x);
AddVectorObs(velocity.y);
AddVectorObs(velocity.z);
AddVectorObs(velocity.x);
AddVectorObs(velocity.y);
AddVectorObs(velocity.z);
AddVectorObs(blockVelocity.x);
AddVectorObs(blockVelocity.y);
AddVectorObs(blockVelocity.z);
AddVectorObs(blockVelocity.x);
AddVectorObs(blockVelocity.y);
AddVectorObs(blockVelocity.z);
}
}
public override void AgentAction(float[] vectorAction, string textAction)
{

if (gameObject.transform.position.y < 0.0f || Mathf.Abs(gameObject.transform.position.x - area.transform.position.x) > 8f ||
Mathf.Abs(gameObject.transform.position.z + 5 - area.transform.position.z) > 8)
{
{
}
}
}
}
public override void AgentReset()
{
public override void AgentReset()
{
rb.velocity = new Vector3(0f, 0f, 0f);
rb.velocity = new Vector3(0f, 0f, 0f);
}
}
public override void AgentOnDone()
{
public override void AgentOnDone()
{
}
}
}

24
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Push/PushArea.cs


public GameObject goalHolder;
public GameObject academy;
// Use this for initialization
void Start () {
academy = GameObject.Find("Academy");
}
// Update is called once per frame
void Update () {
}
// Use this for initialization
void Start () {
academy = GameObject.Find("Academy");
}
// Update is called once per frame
void Update () {
}
public override void ResetArea()
{
public override void ResetArea()
{
float goalSize = academy.GetComponent<PushAcademy>().goalSize;
float blockSize = academy.GetComponent<PushAcademy>().blockSize;
float xVariation = academy.GetComponent<PushAcademy>().xVariation;

blockSize = Random.Range(blockSize * 0.9f, blockSize * 1.1f);
block.transform.localScale = new Vector3(blockSize, 1f, blockSize);
goalHolder.transform.localScale = new Vector3(goalSize, 1f, goalSize);
}
}
}

10
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Wall/WallAcademy.cs


public float minWallHeight;
public float maxWallHeight;
public override void AcademyReset()
{
public override void AcademyReset()
{
}
}
public override void AcademyStep()
{
public override void AcademyStep()
{
}

46
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Wall/WallAgent.cs


public class WallAgent : AreaAgent
{
public GameObject goalHolder;
public GameObject goalHolder;
base.InitializeAgent();
base.InitializeAgent();
public override void CollectObservations()
{
public override void CollectObservations()
{
Vector3 velocity = GetComponent<Rigidbody>().velocity;
AddVectorObs((transform.position.x - area.transform.position.x));
AddVectorObs((transform.position.y - area.transform.position.y));

AddVectorObs((block.transform.position.y - area.transform.position.y));
AddVectorObs((block.transform.position.z + 5 - area.transform.position.z));
AddVectorObs(wall.transform.localScale.y);
AddVectorObs(wall.transform.localScale.y);
AddVectorObs(velocity.x);
AddVectorObs(velocity.y);
AddVectorObs(velocity.z);
AddVectorObs(velocity.x);
AddVectorObs(velocity.y);
AddVectorObs(velocity.z);
AddVectorObs(blockVelocity.x);
AddVectorObs(blockVelocity.y);
AddVectorObs(blockVelocity.z);
}
AddVectorObs(blockVelocity.x);
AddVectorObs(blockVelocity.y);
AddVectorObs(blockVelocity.z);
}
public override void AgentAction(float[] vectorAction, string textAction)
{

if (gameObject.transform.position.y < 0.0f ||
Mathf.Abs(gameObject.transform.position.x - area.transform.position.x) > 8f ||
Mathf.Abs(gameObject.transform.position.z + 5 - area.transform.position.z) > 8)
{
{
}
}
}
}
public override void AgentReset()
{
transform.position = new Vector3(Random.Range(-3.5f, 3.5f), 1.1f, -8f) + area.transform.position;
GetComponent<Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
public override void AgentReset()
{
transform.position = new Vector3(Random.Range(-3.5f, 3.5f), 1.1f, -8f) + area.transform.position;
GetComponent<Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
}
}
public override void AgentOnDone()
{
public override void AgentOnDone()
{
}
}
}

24
unity-environment/Assets/ML-Agents/Examples/Area/Scripts/Wall/WallArea.cs


public GameObject block;
public GameObject goalHolder;
// Use this for initialization
void Start () {
academy = GameObject.Find("Academy");
}
// Update is called once per frame
void Update () {
}
// Use this for initialization
void Start () {
academy = GameObject.Find("Academy");
}
// Update is called once per frame
void Update () {
}
wall.transform.localScale = new Vector3(12f, Random.Range(wallHeightMin, wallHeightMax) - 0.1f, 1f);
wall.transform.localScale = new Vector3(12f, Random.Range(wallHeightMin, wallHeightMax) - 0.1f, 1f);
goalHolder.transform.position = new Vector3(Random.Range(-3.5f, 3.5f), -0.1f, 0f) + gameObject.transform.position;
}
goalHolder.transform.position = new Vector3(Random.Range(-3.5f, 3.5f), -0.1f, 0f) + gameObject.transform.position;
}
}

4
unity-environment/Assets/ML-Agents/Examples/Banana/Scripts/BananaAgent.cs


public override void InitializeAgent()
{
base.InitializeAgent();
agentRB = GetComponent<Rigidbody>(); //cache the RB
agentRB = GetComponent<Rigidbody>(); // cache the RB
Monitor.verticalOffset = 1f;
myArea = area.GetComponent<BananaArea>();
myAcademy = myAcademyObj.GetComponent<BananaAcademy>();

transform.Rotate(rotateDir, Time.deltaTime * turnSpeed);
}
if (agentRB.velocity.sqrMagnitude > 25f) //slow it down
if (agentRB.velocity.sqrMagnitude > 25f) // slow it down
{
agentRB.velocity *= 0.95f;
}

18
unity-environment/Assets/ML-Agents/Examples/Banana/Scripts/BananaLogic.cs


public bool respawn;
public BananaArea myArea;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void OnEaten() {
if (respawn)

12
unity-environment/Assets/ML-Agents/Examples/Basic/Scripts/BasicAcademy.cs


public class BasicAcademy : Academy {
public override void AcademyReset()
{
public override void AcademyReset()
{
}
}
public override void AcademyStep()
{
public override void AcademyStep()
{
}
}
}

12
unity-environment/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAcademy.cs


public class BouncerAcademy : Academy {
public override void AcademyReset()
{
public override void AcademyReset()
{
}
}
public override void AcademyStep()
{
public override void AcademyStep()
{
}
}
}

22
unity-environment/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs


rb.velocity = rb.velocity.normalized * speed;
}
public override void CollectObservations()
{
public override void CollectObservations()
{
}
}
public override void AgentAction(float[] vectorAction, string textAction)
{

}
else
{
//AddReward(0.05f);
// AddReward(0.05f);
}
}
public override void AgentReset()
{
public override void AgentReset()
{
}
}
public override void AgentOnDone()
{
public override void AgentOnDone()
{
}
}
private void OnTriggerEnter(Collider collision)
{

8
unity-environment/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerBanana.cs


void Start(){
}
// Update is called once per frame
void FixedUpdate () {
// Update is called once per frame
void FixedUpdate () {
}
}
private void OnTriggerEnter(Collider collision)
{

22
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CameraFollow.cs


public class CameraFollow : MonoBehaviour {
public Transform target;
Vector3 offset;
public Transform target;
Vector3 offset;
// Use this for initialization
void Start () {
offset = gameObject.transform.position - target.position;
}
// Update is called once per frame
void Update () {
//gameObject.transform.position = target.position + offset;
// Use this for initialization
void Start () {
offset = gameObject.transform.position - target.position;
}
// Update is called once per frame
void Update () {
// gameObject.transform.position = target.position + offset;
}
}
}

114
unity-environment/Assets/ML-Agents/Examples/GridWorld/GridWorld.unity


resetParameters:
resetParameters:
- key: gridSize
value: 3
value: 5
- key: numObstacles
value: 1
- key: numGoals

m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!114 &215565037
--- !u!114 &181601419
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
continuousPlayerActions: []

- key: 275
value: 3
defaultAction: -1
brain: {fileID: 1535917239}
--- !u!114 &219137297
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 0
graphModel: {fileID: 4900000, guid: 69bc5a8ff4f4b465b8b374d88541c8bd, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
StatePlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
ObservationPlaceholderName:
- observation_0
ActionPlaceholderName: action
PreviousActionPlaceholderName: prev_action
brain: {fileID: 1535917239}
--- !u!1 &231883441
GameObject:

m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &434995297
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 0
graphModel: {fileID: 4900000, guid: 5cf779dc0ed064c7080b9f4a3bfffed8, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
VectorObservationPlacholderName: vector_observation
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
VisualObservationPlaceholderName:
- visual_observation_0
ActionPlaceholderName: action
PreviousActionPlaceholderName: prev_action
brain: {fileID: 1535917239}
--- !u!1 &486401523
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 486401524}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1263276658
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 1535917239}
--- !u!114 &1445635773
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 1535917239}
--- !u!1 &1535917237
GameObject:
m_ObjectHideFlags: 0

vectorObservationSpaceType: 1
brainType: 0
CoreBrains:
- {fileID: 215565037}
- {fileID: 1445635773}
- {fileID: 1263276658}
- {fileID: 219137297}
instanceID: 41160
- {fileID: 181601419}
- {fileID: 1725065038}
- {fileID: 2081313990}
- {fileID: 434995297}
instanceID: 12542
--- !u!1 &1553342942
GameObject:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1553342942}
--- !u!114 &1725065038
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 1535917239}
--- !u!1 &1726089810
GameObject:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 1657514749044530, guid: 628960e910f094ad1909ecc88cc8016d,
type: 2}
m_PrefabInternal: {fileID: 2008405821}
--- !u!114 &2081313990
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 1535917239}

993
unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_3x3.bytes
文件差异内容过多而无法显示
查看文件

6
unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_3x3.bytes.meta


fileFormatVersion: 2
guid: 426162c47484e466d8378d2321a5617c
timeCreated: 1515001510
licenseType: Pro
guid: c9452e7152c084dfeb7db2db89067546
timeCreated: 1520389551
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:

977
unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_5x5.bytes
文件差异内容过多而无法显示
查看文件

6
unity-environment/Assets/ML-Agents/Examples/GridWorld/TFModels/GridWorld_5x5.bytes.meta


fileFormatVersion: 2
guid: 69bc5a8ff4f4b465b8b374d88541c8bd
timeCreated: 1517599883
licenseType: Pro
guid: 5cf779dc0ed064c7080b9f4a3bfffed8
timeCreated: 1520389566
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:

14
unity-environment/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAcademy.cs


public class HallwayAcademy : Academy {
public float agentRunSpeed;
public float agentRotationSpeed;
public Material goalScoredMaterial; //when a goal is scored the ground will use this material for a few seconds.
public Material failMaterial; //when fail, the ground will use this material for a few seconds.
public float gravityMultiplier; //use ~3 to make things less floaty
public float agentRunSpeed;
public float agentRotationSpeed;
public Material goalScoredMaterial; // when a goal is scored the ground will use this material for a few seconds.
public Material failMaterial; // when fail, the ground will use this material for a few seconds.
public float gravityMultiplier; // use ~3 to make things less floaty
public override void InitializeAcademy()
{

public override void AcademyReset()
{
public override void AcademyReset()
{
}
}

51
unity-environment/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs


//Put this script on your blue cube.
// Put this script on your blue cube.
using System.Collections;
using System.Collections.Generic;

{
public GameObject ground; //ground game object. we will use the area bounds to spawn the blocks
public GameObject ground; // ground game object. we will use the area bounds to spawn the blocks
public GameObject orangeBlock; //the orange block we are going to be pushing
public GameObject orangeBlock; // the orange block we are going to be pushing
Rigidbody shortBlockRB; //cached on initialization
Rigidbody agentRB; //cached on initialization
Material groundMaterial; //cached on Awake()
Rigidbody shortBlockRB; // cached on initialization
Rigidbody agentRB; // cached on initialization
Material groundMaterial; // cached on Awake()
Renderer groundRenderer;
HallwayAcademy academy;

{
base.InitializeAgent();
academy = FindObjectOfType<HallwayAcademy>();
brain = FindObjectOfType<Brain>(); //only one brain in the scene so this should find our brain. BRAAAINS.
brain = FindObjectOfType<Brain>(); // only one brain in the scene so this should find our brain. BRAAAINS.
agentRB = GetComponent<Rigidbody>(); //cache the agent rigidbody
groundRenderer = ground.GetComponent<Renderer>(); //get the ground renderer so we can change the material when a goal is scored
groundMaterial = groundRenderer.material; //starting material
agentRB = GetComponent<Rigidbody>(); // cache the agent rigidbody
groundRenderer = ground.GetComponent<Renderer>(); // get the ground renderer so we can change the material when a goal is scored
groundMaterial = groundRenderer.material; // starting material
}

RayPerception(rayDistance, rayAngles, detectableObjects, 0f);
}
//swap ground material, wait time seconds, then swap back to the regular ground material.
// swap ground material, wait time seconds, then swap back to the regular ground material.
yield return new WaitForSeconds(time); //wait for 2 sec
yield return new WaitForSeconds(time); // wait for 2 sec
groundRenderer.material = groundMaterial;
}

Vector3 dirToGo = Vector3.zero;
Vector3 rotateDir = Vector3.zero;
//If we're using Continuous control you will need to change the Action
// If we're using Continuous control you will need to change the Action
if (brain.brainParameters.vectorActionSpaceType == SpaceType.continuous)
{
dirToGo = transform.forward * Mathf.Clamp(act[0], -1f, 1f);

}
}
transform.Rotate(rotateDir, Time.deltaTime * 100f);
agentRB.AddForce(dirToGo * academy.agentRunSpeed, ForceMode.VelocityChange); //GO
agentRB.AddForce(dirToGo * academy.agentRunSpeed, ForceMode.VelocityChange); // GO
}
public override void AgentAction(float[] vectorAction, string textAction)

MoveAgent(vectorAction); //perform agent actions
bool fail = false; // did the agent or block get pushed off the edge?
if (!Physics.Raycast(agentRB.position, Vector3.down, 20)) //if the agent has gone over the edge, we done.
if (!Physics.Raycast(agentRB.position, Vector3.down, 20)) // if the agent has gone over the edge, we done.
fail = true; //fell off bro
fail = true; // fell off bro
Done(); //if we mark an agent as done it will be reset automatically. AgentReset() will be called.
Done(); // if we mark an agent as done it will be reset automatically. AgentReset() will be called.
StartCoroutine(GoalScoredSwapGroundMaterial(academy.failMaterial, .5f)); //swap ground material to indicate fail
StartCoroutine(GoalScoredSwapGroundMaterial(academy.failMaterial, .5f)); // swap ground material to indicate fail
}
}

if (col.gameObject.CompareTag("goal")) //touched goal
if (col.gameObject.CompareTag("goal")) // touched goal
AddReward(1f); //you get 5 points
StartCoroutine(GoalScoredSwapGroundMaterial(academy.goalScoredMaterial, 2)); //swap ground material for a bit to indicate we scored.
AddReward(1f); // you get 5 points
StartCoroutine(GoalScoredSwapGroundMaterial(academy.goalScoredMaterial, 2)); // swap ground material for a bit to indicate we scored.
AddReward(-0.1f); //you lose a point
StartCoroutine(GoalScoredSwapGroundMaterial(academy.failMaterial, .5f)); //swap ground material to indicate fail
AddReward(-0.1f); // you lose a point
StartCoroutine(GoalScoredSwapGroundMaterial(academy.failMaterial, .5f)); // swap ground material to indicate fail
Done(); //if we mark an agent as done it will be reset automatically. AgentReset() will be called.
Done(); // if we mark an agent as done it will be reset automatically. AgentReset() will be called.
//In the editor, if "Reset On Done" is checked then AgentReset() will be called automatically anytime we mark done = true in an agent script.
// In the editor, if "Reset On Done" is checked then AgentReset() will be called automatically anytime we mark done = true in an agent script.
public override void AgentReset()
{
selection = Random.Range(0, 2);

152
unity-environment/Assets/ML-Agents/Examples/Reacher/Scene.unity


--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3

m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 762086411}
m_IndirectSpecularColor: {r: 0.4465934, g: 0.49642956, b: 0.5748249, a: 1}
m_UseRadianceAmbientProbe: 0
m_IndirectSpecularColor: {r: 0.4465785, g: 0.49641252, b: 0.574817, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
serializedVersion: 9
m_AtlasSize: 1024
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1

m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4

m_PrefabParentObject: {fileID: 1644872085946016, guid: 2f13abef2db804f96bdc7692a1dcf2b2,
type: 2}
m_PrefabInternal: {fileID: 103720292}
--- !u!114 &105498462
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
continuousPlayerActions: []
discretePlayerActions: []
defaultAction: -1
brain: {fileID: 846768605}
--- !u!114 &169591833
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)
m_EditorClassIdentifier:
broadcast: 1
graphModel: {fileID: 4900000, guid: 8db6173148a6f4e7fa654ed627c88d7a, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
VectorObservationPlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
VisualObservationPlaceholderName: []
ActionPlaceholderName: action
PreviousActionPlaceholderName: prev_action
brain: {fileID: 846768605}
--- !u!1001 &201192304
Prefab:
m_ObjectHideFlags: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: 3736de91af62e4be7a3d8752592c6c61, type: 2}
m_StaticBatchInfo:

m_PrefabParentObject: {fileID: 1644872085946016, guid: 2f13abef2db804f96bdc7692a1dcf2b2,
type: 2}
m_PrefabInternal: {fileID: 376525309}
--- !u!114 &399235793
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
continuousPlayerActions: []
discretePlayerActions: []
defaultAction: -1
brain: {fileID: 846768605}
--- !u!1001 &405812494
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 1644872085946016, guid: 2f13abef2db804f96bdc7692a1dcf2b2,
type: 2}
m_PrefabInternal: {fileID: 813023944}
--- !u!114 &831098326
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 0}
--- !u!1 &846768603
GameObject:
m_ObjectHideFlags: 0

-
vectorActionSpaceType: 1
vectorObservationSpaceType: 1
brainType: 3
brainType: 2
- {fileID: 105498462}
- {fileID: 949391681}
- {fileID: 1042778401}
- {fileID: 169591833}
instanceID: 3972
- {fileID: 399235793}
- {fileID: 831098326}
- {fileID: 1767077297}
- {fileID: 1188890699}
instanceID: 19516
--- !u!1001 &915173805
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 1644872085946016, guid: 2f13abef2db804f96bdc7692a1dcf2b2,
type: 2}
m_PrefabInternal: {fileID: 915173805}
--- !u!114 &949391681
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 0}
--- !u!114 &1042778401
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 846768605}
--- !u!1001 &1065008966
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 1644872085946016, guid: 2f13abef2db804f96bdc7692a1dcf2b2,
type: 2}
m_PrefabInternal: {fileID: 1185345513}
--- !u!114 &1188890699
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)
m_EditorClassIdentifier:
broadcast: 1
graphModel: {fileID: 4900000, guid: 8db6173148a6f4e7fa654ed627c88d7a, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
VectorObservationPlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
VisualObservationPlaceholderName: []
ActionPlaceholderName: action
PreviousActionPlaceholderName: prev_action
brain: {fileID: 846768605}
--- !u!1001 &1216133380
Prefab:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 1644872085946016, guid: 2f13abef2db804f96bdc7692a1dcf2b2,
type: 2}
m_PrefabInternal: {fileID: 1716924926}
--- !u!114 &1767077297
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 846768605}
--- !u!1001 &1781444637
Prefab:
m_ObjectHideFlags: 0

22
unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/FlyCamera.cs


space : Moves camera on X and Z axis only. So camera doesn't gain any height*/
public float mainSpeed = 100.0f; //regular speed
public float shiftAdd = 250.0f; //multiplied by how long shift is held. Basically running
public float maxShift = 1000.0f; //Maximum speed when holdin gshift
public float camSens = 0.25f; //How sensitive it with mouse
public float mainSpeed = 100.0f; // regular speed
public float shiftAdd = 250.0f; // multiplied by how long shift is held. Basically running
public float maxShift = 1000.0f; // Maximum speed when holdin gshift
public float camSens = 0.25f; // How sensitive it with mouse
private Vector3 lastMouse = new Vector3(255, 255, 255); //kind of in the middle of the screen, rather than at the top (play)
private Vector3 lastMouse = new Vector3(255, 255, 255); // kind of in the middle of the screen, rather than at the top (play)
private float totalRun = 1.0f;
void Awake()

//transform.position.Set(0,8,-32);
//transform.rotation.Set(15,0,0,1);
// transform.position.Set(0,8,-32);
// transform.rotation.Set(15,0,0,1);
transform.position = new Vector3(0, 8, -32);
transform.rotation = Quaternion.Euler(25, 0, 0);
}

lastMouse = new Vector3(transform.eulerAngles.x + lastMouse.x, transform.eulerAngles.y + lastMouse.y, 0);
transform.eulerAngles = lastMouse;
lastMouse = Input.mousePosition;
//Mouse camera angle done.
// Mouse camera angle done.
//Keyboard commands
// Keyboard commands
Vector3 p = GetBaseInput();
if (Input.GetKey(KeyCode.LeftShift))
{

Vector3 newPosition = transform.position;
if (Input.GetKey(KeyCode.Space)
|| (movementStaysFlat && !(rotateOnlyIfMousedown && Input.GetMouseButton(1))))
{ //If player wants to move on X and Z axis only
{ // If player wants to move on X and Z axis only
transform.Translate(p);
newPosition.x = transform.position.x;
newPosition.z = transform.position.z;

}
private Vector3 GetBaseInput()
{ //returns the basic values, if it's 0 than it's not active.
{ // returns the basic values, if it's 0 than it's not active.
Vector3 p_Velocity = new Vector3();
if (Input.GetKey(KeyCode.W))
{

12
unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAcademy.cs


public float goalSpeed;
public override void AcademyReset()
{
public override void AcademyReset()
{
}
}
public override void AcademyStep()
{
public override void AcademyStep()
{
}
}
}

5
unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs


/// We collect the normalized rotations, angularal velocities, and velocities of both
/// limbs of the reacher as well as the relative position of the target and hand.
/// </summary>
public override void CollectObservations()
{
public override void CollectObservations()
{
AddVectorObs(pendulumA.transform.rotation.eulerAngles.x / 180.0f - 1.0f);
AddVectorObs(pendulumA.transform.rotation.eulerAngles.y / 180.0f - 1.0f);
AddVectorObs(pendulumA.transform.rotation.eulerAngles.z / 180.0f - 1.0f);

goal.transform.localScale = new Vector3(goalSize, goalSize, goalSize);
}
}

12
unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherDecision.cs


public class ReacherDecision : MonoBehaviour, Decision {
public float[] Decide (List<float> state, List<Texture2D> observation, float reward, bool done, List<float> memory)
{
{
float[] action = new float[4];
for (int i = 0; i < 4; i++) {
action[i] = Random.Range(-1f, 1f);

}
}
{
return new List<float>();
}
{
return new List<float>();
}
}

18
unity-environment/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherGoal.cs


public GameObject hand;
public GameObject goalOn;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
private void OnTriggerEnter(Collider other)
{

30
unity-environment/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab


m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1

m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5

m_Name:
m_EditorClassIdentifier:
brain: {fileID: 0}
stepCounter: 0
eventBased: 0
numberOfStepsBetweenActions: 1
onDemandDecision: 0
numberOfActionsBetweenDecisions: 5
ball: {fileID: 1766663729253338}
invertX: 1

m_Name:
m_EditorClassIdentifier:
brain: {fileID: 0}
stepCounter: 0
eventBased: 0
numberOfStepsBetweenActions: 1
onDemandDecision: 0
numberOfActionsBetweenDecisions: 5
ball: {fileID: 1766663729253338}
invertX: 0

16
unity-environment/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs


public GameObject agentA;
public GameObject agentB;
// Use this for initialization
void Start () {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
// Update is called once per frame
void Update () {
}
public void MatchReset() {
float ballOut = Random.Range(6f, 8f);

216
unity-environment/Assets/ML-Agents/Examples/Tennis/Scripts/hitWall.cs


public class hitWall : MonoBehaviour
{
public GameObject areaObject;
public int lastAgentHit;
public GameObject areaObject;
public int lastAgentHit;
// Use this for initialization
void Start()
{
lastAgentHit = -1;
}
// Use this for initialization
void Start()
{
lastAgentHit = -1;
}
private void OnTriggerExit(Collider other)
{
TennisArea area = areaObject.GetComponent<TennisArea>();
TennisAgent agentA = area.agentA.GetComponent<TennisAgent>();
TennisAgent agentB = area.agentB.GetComponent<TennisAgent>();
private void OnTriggerExit(Collider other)
{
TennisArea area = areaObject.GetComponent<TennisArea>();
TennisAgent agentA = area.agentA.GetComponent<TennisAgent>();
TennisAgent agentB = area.agentB.GetComponent<TennisAgent>();
if (other.name == "over")
{
if (lastAgentHit == 0)
{
if (other.name == "over")
{
if (lastAgentHit == 0)
{
}
else
{
}
else
{
}
lastAgentHit = 0;
}
lastAgentHit = 0;
}
}
}
}
private void OnCollisionEnter(Collision collision)
{
TennisArea area = areaObject.GetComponent<TennisArea>();
TennisAgent agentA = area.agentA.GetComponent<TennisAgent>();
TennisAgent agentB = area.agentB.GetComponent<TennisAgent>();
private void OnCollisionEnter(Collision collision)
{
TennisArea area = areaObject.GetComponent<TennisArea>();
TennisAgent agentA = area.agentA.GetComponent<TennisAgent>();
TennisAgent agentB = area.agentB.GetComponent<TennisAgent>();
if (collision.gameObject.tag == "iWall")
{
if (collision.gameObject.name == "wallA")
{
if (lastAgentHit == 0)
{
if (collision.gameObject.tag == "iWall")
{
if (collision.gameObject.name == "wallA")
{
if (lastAgentHit == 0)
{
agentB.score += 1;
}
else
{
agentA.SetReward(0);
agentB.score += 1;
}
else
{
agentA.SetReward(0);
agentA.score += 1;
}
}
else if (collision.gameObject.name == "wallB")
{
if (lastAgentHit == 0)
{
agentA.score += 1;
}
}
else if (collision.gameObject.name == "wallB")
{
if (lastAgentHit == 0)
{
agentB.score += 1;
}
else
{
agentA.SetReward(0);
agentB.score += 1;
}
else
{
agentA.SetReward(0);
agentA.score += 1;
}
}
else if (collision.gameObject.name == "floorA")
{
if (lastAgentHit == 0 || lastAgentHit == -1)
{
agentA.score += 1;
}
}
else if (collision.gameObject.name == "floorA")
{
if (lastAgentHit == 0 || lastAgentHit == -1)
{
agentB.SetReward(0);
agentB.score += 1;
}
else
{
agentB.SetReward(0);
agentB.score += 1;
}
else
{
agentB.SetReward(0);
agentB.score += 1;
agentB.SetReward(0);
agentB.score += 1;
}
}
else if (collision.gameObject.name == "floorB")
{
if (lastAgentHit == 1 || lastAgentHit == -1)
{
agentA.SetReward(0);
}
}
else if (collision.gameObject.name == "floorB")
{
if (lastAgentHit == 1 || lastAgentHit == -1)
{
agentA.SetReward(0);
agentA.score += 1;
}
else
{
agentA.SetReward(0);
agentA.score += 1;
}
else
{
agentA.SetReward(0);
agentA.score += 1;
}
}
else if (collision.gameObject.name == "net")
{
if (lastAgentHit == 0)
{
agentA.score += 1;
}
}
else if (collision.gameObject.name == "net")
{
if (lastAgentHit == 0)
{
agentB.SetReward(0);
agentB.score += 1;
}
else
{
agentA.SetReward(0);
agentB.SetReward(0);
agentB.score += 1;
}
else
{
agentA.SetReward(0);
agentA.score += 1;
}
}
agentA.score += 1;
}
}
agentB.Done();
area.MatchReset();
}
agentB.Done();
area.MatchReset();
}
if (collision.gameObject.tag == "agent")
{
if (collision.gameObject.name == "AgentA")
{
lastAgentHit = 0;
}
else
{
lastAgentHit = 1;
}
}
}
if (collision.gameObject.tag == "agent")
{
if (collision.gameObject.name == "AgentA")
{
lastAgentHit = 0;
}
else
{
lastAgentHit = 1;
}
}
}
}

979
unity-environment/Assets/ML-Agents/Examples/Tennis/TFModels/Tennis.bytes
文件差异内容过多而无法显示
查看文件

6
unity-environment/Assets/ML-Agents/Examples/Tennis/TFModels/Tennis.bytes.meta


fileFormatVersion: 2
guid: 57cd436ad0d12422ba379708e135815b
timeCreated: 1516054446
licenseType: Pro
guid: c428950472279436d97dd5fa123febc4
timeCreated: 1520386972
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:

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


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 36699497}
--- !u!114 &55969174
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
continuousPlayerActions:
- key: 97
index: 0
value: -1
- key: 100
index: 0
value: 1
- key: 32
index: 1
value: 1
discretePlayerActions:
- key: 276
value: 0
- key: 275
value: 1
- key: 0
value: 3
- key: 273
value: 2
defaultAction: 3
brain: {fileID: 459283648}
--- !u!114 &142813437
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 459283648}
--- !u!1001 &258257356
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

-
vectorActionSpaceType: 1
vectorObservationSpaceType: 1
brainType: 0
brainType: 3
- {fileID: 1421859681}
- {fileID: 471755396}
- {fileID: 582107017}
- {fileID: 1240109700}
instanceID: 101116
--- !u!114 &471755396
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 459283648}
--- !u!114 &508473255
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)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 1948813725}
- {fileID: 55969174}
- {fileID: 142813437}
- {fileID: 1174913534}
- {fileID: 2117068745}
instanceID: 39492
--- !u!1001 &530994421
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 812997c7bc2544b6f927ff684c03450f, type: 2}
m_IsPrefabParent: 0
--- !u!114 &582107017
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 459283648}
--- !u!1001 &667349971
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

resetParameters: []
episodeCount: 0
stepsSinceReset: 0
--- !u!114 &1028659588
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
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: 3
- key: 32
value: 2
defaultAction: 3
brain: {fileID: 1948813725}
--- !u!1001 &1065879750
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 812997c7bc2544b6f927ff684c03450f, type: 2}
m_IsPrefabParent: 0
--- !u!114 &1174913534
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 459283648}
--- !u!1001 &1180609771
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 812997c7bc2544b6f927ff684c03450f, type: 2}
m_IsPrefabParent: 0
--- !u!114 &1240109700
--- !u!114 &1559375794
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b23992c8eb17439887f5e944bf04a40, type: 3}
m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(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)
m_EditorClassIdentifier:
broadcast: 1
graphModel: {fileID: 4900000, guid: 57cd436ad0d12422ba379708e135815b, type: 3}

valueType: 1
minValue: -1
maxValue: 1
minValue: 0
maxValue: 0
StatePlacholderName: state
VectorObservationPlacholderName: vector_observation
ObservationPlaceholderName: []
VisualObservationPlaceholderName: []
brain: {fileID: 459283648}
--- !u!114 &1317929880
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)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
brain: {fileID: 0}
--- !u!114 &1421859681
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
continuousPlayerActions:
- key: 97
index: 0
value: -1
- key: 100
index: 0
value: 1
- key: 32
index: 1
value: 1
discretePlayerActions:
- key: 276
value: 0
- key: 275
value: 1
- key: 0
value: 3
- key: 273
value: 2
defaultAction: 3
brain: {fileID: 459283648}
PreviousActionPlaceholderName: prev_action
brain: {fileID: 1948813725}
--- !u!1001 &1667694556
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 60, y: 30, z: 0}
--- !u!114 &1777611709
--- !u!114 &1775005643
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)(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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(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: 3
- key: 32
value: 2
defaultAction: 3
brain: {fileID: 1948813725}
brain: {fileID: 0}
--- !u!1001 &1834785653
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1871669621}
--- !u!114 &1911175829
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
graphModel: {fileID: 4900000, guid: 57cd436ad0d12422ba379708e135815b, type: 3}
graphScope:
graphPlaceholders:
- name: epsilon
valueType: 1
minValue: 0
maxValue: 0
BatchSizePlaceholderName: batch_size
StatePlacholderName: state
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
ObservationPlaceholderName: []
ActionPlaceholderName: action
brain: {fileID: 1948813725}
--- !u!1001 &1913269664
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 812997c7bc2544b6f927ff684c03450f, type: 2}
m_IsPrefabParent: 0
--- !u!114 &1943524482
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
brain: {fileID: 1948813725}
--- !u!1 &1948813723
GameObject:
m_ObjectHideFlags: 0

m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &1948813724
Transform:
m_ObjectHideFlags: 0

vectorObservationSpaceType: 1
brainType: 0
CoreBrains:
- {fileID: 1777611709}
- {fileID: 1317929880}
- {fileID: 508473255}
- {fileID: 1911175829}
instanceID: 101204
- {fileID: 1028659588}
- {fileID: 1775005643}
- {fileID: 1943524482}
- {fileID: 1559375794}
instanceID: 30164
--- !u!1001 &1965335106
Prefab:
m_ObjectHideFlags: 0

type: 2}
propertyPath: brain
value:
objectReference: {fileID: 1948813725}
objectReference: {fileID: 459283648}
- target: {fileID: 114800310164848628, guid: 812997c7bc2544b6f927ff684c03450f,
type: 2}
propertyPath: scoreText

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2073469450}
--- !u!114 &2117068745
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)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)(Clone)
m_EditorClassIdentifier:
broadcast: 1
graphModel: {fileID: 4900000, guid: c428950472279436d97dd5fa123febc4, type: 3}
graphScope:
graphPlaceholders: []
BatchSizePlaceholderName: batch_size
VectorObservationPlacholderName: vector_observation
RecurrentInPlaceholderName: recurrent_in
RecurrentOutPlaceholderName: recurrent_out
VisualObservationPlaceholderName: []
ActionPlaceholderName: action
PreviousActionPlaceholderName: prev_action
brain: {fileID: 459283648}

4
unity-environment/Assets/ML-Agents/Scripts/Academy.cs


using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
/**

}
return brains;
}
}
}

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


/// <summary>
/// The brain that will control this agent.
/// Use the inspector to drag the desired brain gameObject into
/// the Brain field.
/// the Brain field.
///</summary>
[HideInInspector]
public Brain brain;

///</summary>
private float reward;
/// Whether or not the agent is requests an action
/// Whether or not the agent requests an action.
/// Whether or not the agent is requests a decision
/// Whether or not the agent requests a decision.
private bool requestDecision;
/// <summary>

private int id;
/// <summary>
/// Unity method called when the agent is istanciated or set to active.
/// Unity method called when the agent is instantiated or set to active.
/// </summary>
private void OnEnable()
{

/// When GiveBrain is called, the agent unsubscribes from its
/// previous brain and subscribes to the one passed in argument.
/// Use this method to provide a brain to the agent via script.
///<param name= "b" >The Brain the agent will subscribe to.</param>
///<param name= "b" >The Brain the agent will subscribe to.</param>
/// <summary>
public void GiveBrain(Brain b)
{

/// <summary>
/// Is called when the agent must request the brain for a new decision.
/// </summary>
public void RequestDecision()
public void RequestDecision()
{
requestDecision = true;
RequestAction();

/// </summary>
public void RequestAction()
public void RequestAction()
{
requestAction = true;
}

/// <summary>
/// Initialize the agent with this method
/// Must be implemented in agent-specific child class.
/// This method called only once when the agent is enabled.
/// This method called only once when the agent is enabled.
/// </summary>
public virtual void InitializeAgent()
{

{
if (!hasAlreadyReset)
{
//If event based, the agent can reset as soon
// If event based, the agent can reset as soon
// as it is done
_AgentReset();
hasAlreadyReset = true;

14
unity-environment/Assets/ML-Agents/Scripts/BCTeacherHelper.cs


public KeyCode recordKey = KeyCode.R;
public KeyCode resetKey = KeyCode.C;
// Use this for initialization
void Start () {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(recordKey))
{
recordExperiences = !recordExperiences;

Monitor.Log("Recording experiences " + recordKey.ToString(), recordExperiences.ToString());
float timeSinceBufferReset = Time.time - bufferResetTime;
Monitor.Log("Seconds since buffer reset " + resetKey.ToString(), Mathf.FloorToInt(timeSinceBufferReset));
}
}
void FixedUpdate()
{

8
unity-environment/Assets/ML-Agents/Scripts/Brain.cs


//[HideInInspector]
///**< \brief Keeps track of the agents which subscribe to this brain*/
//public Dictionary<int, Agent> agents = new Dictionary<int, Agent>();
// public Dictionary<int, Agent> agents = new Dictionary<int, Agent>();
[SerializeField]
ScriptableObject[] CoreBrains;

//Ensures the coreBrains are not dupplicated with the brains
// Ensures the coreBrains are not dupplicated with the brains
* If the brain gameObject was just created, it generates a list of
* coreBrains (one for each brainType) */
* If the brain gameObject was just created, it generates a list of
* coreBrains (one for each brainType) */
public void UpdateCoreBrains()
{

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


public string logPath;
/**< \brief The default reset parameters are sent via socket*/
public Dictionary<string, float> resetParameters;
public Dictionary<string, float> resetParameters;
/**< \brief A list of the all the brains names sent via socket*/
public List<string> brainNames;

39
unity-environment/Assets/ML-Agents/Scripts/CoreBrainHeuristic.cs


/// Uses the Decision Component to decide that action to take
public void DecideAction(Dictionary<Agent, AgentInfo> agentInfo)
{
if (coord!=null)
{
if (coord!=null)
{
}
if (decision == null)
}
if (decision == null)
agent.UpdateVectorAction(decision.Decide(
agent.UpdateVectorAction(decision.Decide(
agentInfo[agent].stackedVectorObservation,
agentInfo[agent].visualObservations,
agentInfo[agent].reward,

}
agentInfo[agent].stackedVectorObservation,
agentInfo[agent].visualObservations,
agentInfo[agent].reward,
agentInfo[agent].done,
agentInfo[agent].memories));
agentInfo[agent].stackedVectorObservation,
agentInfo[agent].visualObservations,
agentInfo[agent].reward,
agentInfo[agent].done,
agentInfo[agent].memories));
}
}

#if UNITY_EDITOR
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
broadcast = EditorGUILayout.Toggle(new GUIContent("Broadcast",
"If checked, the brain will broadcast states and actions to Python."), broadcast);
if (brain.gameObject.GetComponent<Decision>() == null)
{
#if UNITY_EDITOR
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
broadcast = EditorGUILayout.Toggle(new GUIContent("Broadcast",
"If checked, the brain will broadcast states and actions to Python."), broadcast);
if (brain.gameObject.GetComponent<Decision>() == null)
{
}
#endif
}
#endif
}
}

22
unity-environment/Assets/ML-Agents/Scripts/CoreBrainInternal.cs


{
#if ENABLE_TENSORFLOW
#if UNITY_ANDROID
// This needs to ba called only once and will raise an exception if
// This needs to ba called only once and will raise an exception if
try{
TensorFlowSharp.Android.NativeBinding.Init();
}
catch{
}
try{
TensorFlowSharp.Android.NativeBinding.Init();
}
catch{
}
#endif
if ((communicator == null)
|| (!broadcast))

public void DecideAction(Dictionary<Agent, AgentInfo> agentInfo)
{
#if ENABLE_TENSORFLOW
if (coord != null)
{
coord.GiveBrainInfo(brain, agentInfo);
}
if (coord != null)
{
coord.GiveBrainInfo(brain, agentInfo);
}
int currentBatchSize = agentInfo.Count();
List<Agent> agentList = agentInfo.Keys.ToList();
if (currentBatchSize == 0)

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


else
{
foreach (Agent agent in agentInfo.Keys)
{
{
var action = new float[1] { defaultAction };
foreach (DiscretePlayerAction dha in discretePlayerActions)
{

28
unity-environment/Assets/ML-Agents/Scripts/Decision.cs


/// \brief Implement this method to define the logic of decision making
/// for the CoreBrainHeuristic
/** Given the information about the agent, return a vector of actions.
* @param state The state of the agent
* @param observation The cameras the agent uses
* @param reward The reward the agent had at the previous step
* @param done Weather or not the agent is done
* @param memory The memories stored from the previous step with MakeMemory()
* @return The vector of actions the agent will take at the next step
*/
* @param state The state of the agent
* @param observation The cameras the agent uses
* @param reward The reward the agent had at the previous step
* @param done Whether or not the agent is done
* @param memory The memories stored from the previous step with MakeMemory()
* @return The vector of actions the agent will take at the next step
*/
* @param state The state of the agent
* @param observation The cameras the agent uses
* @param reward The reward the agent had at the previous step
* @param done Weather or not the agent is done
* @param memory The memories stored from the previous step with MakeMemory()
* @return The vector of memories the agent will use at the next step
*/
* @param state The state of the agent
* @param observation The cameras the agent uses
* @param reward The reward the agent had at the previous step
* @param done Weather or not the agent is done
* @param memory The memories stored from the previous step with MakeMemory()
* @return The vector of memories the agent will use at the next step
*/
List<float> MakeMemory(List<float> state, List<Texture2D> observation, float reward, bool done, List<float> memory);
}

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


sMessage.maxes = new List<bool>(defaultNumAgents);
sMessage.textObservations = new List<string>(defaultNumAgents);
//Initialize the list of brains the Communicator must listen to
// Initialize the list of brains the Communicator must listen to
// Issue : This assumes all brains are broadcasting.
foreach (string k in accParamerters.brainNames)
{

12
unity-environment/Assets/ML-Agents/Template/Scripts/TemplateAcademy.cs


public class TemplateAcademy : Academy {
public override void AcademyReset()
{
public override void AcademyReset()
{
}
}
public override void AcademyStep()
{
public override void AcademyStep()
{
}
}
}

20
unity-environment/Assets/ML-Agents/Template/Scripts/TemplateAgent.cs


public override void CollectObservations()
{
public override void CollectObservations()
{
}
}
}
}
public override void AgentReset()
{
public override void AgentReset()
{
}
}
public override void AgentOnDone()
{
public override void AgentOnDone()
{
}
}
}

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


public List<float> MakeMemory(List<float> state, List<Texture2D> observation, float reward, bool done, List<float> memory)
{
return new List<float>();
}
}

37
docs/Learning-Environment-On-Demand-Decision.md


# On Demand Decision Making
## Description
On demand decision making allows agents to request decisions from their
brains only when needed instead of requesting decisions at a fixed
frequency. This is useful when the agents commit to an action for a
variable number of steps or when the agents cannot make decisions
at the same time. This typically the case for turn based games, games
where agents must react to events or games where agents can take
actions of variable duration.
## How to use
In the agent inspector, there is a checkbox called
`On Demand Decision`
![Brain Inspector](images/ml-agents-ODD.png)
* If `On Demand Decision` is not checked, all the agents will
request a new decision every `Decision Frequency` steps and
perform an action every step. In the example above,
`CollectObservations()` will be called every 5 steps and
`AgentAct()` will be called at every step. This means that the
agent will reuse the decision the brain has given it.
* If `On Demand Decision` is checked, you are in charge of telling
the agent when to request a decision and when to request an action.
To do so, call the following methods on your agent component.
* `RequestDecision()` Call this method to signal the agent that it
must collect its observations and ask the brain for a decision at
the next step of the simulation. Note that when an agent requests
a decision, it will also request an action automatically
(This is to ensure that all decisions lead to an action during training)
* `RequestAction()` Call this method to signal the agent that
it must reuse its previous action at the next step of the
simulation. The Agent will not ask the brain for a new decision,
it will just call `AgentAct()` with the same action.

47
docs/Training-LSTM.md


# Using Recurrent Neural Network in ML-Agents
## What are memories for?
Have you ever entered a room to get something and immediately forgot
what you were looking for? Don't let that happen to
your agents.
It is now possible to give memories to your agents. When training, the
agents will be able to store a vector of floats to be used next time
they need to make a decision.
![Brain Inspector](images/ml-agents-LSTM.png)
Deciding what the agents should remember in order to solve a task is not
easy to do by hand, but our training algorithms can learn to keep
track of what is important to remember with [LSTM](https://en.wikipedia.org/wiki/Long_short-term_memory).
## How to use
When configuring the trainer parameters in the `trainer_config.yaml`
file, add the following parameters to the Brain you want to use.
```
use_recurrent: true
sequence_length: 64
memory_size: 256
```
* `use_recurent` is a flag that notifies the trainer that you want
to use a Recurrent Neural Network.
* `sequence_length` defines how long the sequences of experiences
must be while training. In order to use a LSTM, training requires
a sequence of experiences instead of single experiences.
* `memory_size` corresponds to the size of the memory the agent
must keep. Note that if this number is too small, the agent will not
be able to remember a lot of things. If this number is too large,
the neural network will take longer to train.
## Limitations
* LSTM does not work well with continuous vector action space.
Please use discrete vector action space for better results.
* Since the memories must be sent back and forth between python
and Unity, using too large `memory_size` will slow down training.
* Adding a recurrent layer increases the complexity of the neural
network, it is recommended to decrease `num_layers` when using recurrent.
* It is required that `memory_size` be divisible by 4.

911
docs/images/ml-agents-LSTM.png

之前 之后
宽度: 1042  |  高度: 384  |  大小: 216 KiB

61
docs/images/ml-agents-ODD.png

之前 之后
宽度: 402  |  高度: 148  |  大小: 17 KiB
正在加载...
取消
保存