GitHub
6 年前
当前提交
a196dde2
共有 488 个文件被更改,包括 2612 次插入 和 13040 次删除
-
4.gitignore
-
19README.md
-
176UnitySDK/Assets/ML-Agents/Editor/BrainEditor.cs
-
15UnitySDK/Assets/ML-Agents/Editor/BrainEditor.cs.meta
-
175UnitySDK/Assets/ML-Agents/Editor/ResetParameterDrawer.cs
-
61UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs
-
5UnitySDK/Assets/ML-Agents/Examples/3DBall/Prefabs/Game.prefab
-
5UnitySDK/Assets/ML-Agents/Examples/3DBall/Prefabs/GameHard.prefab
-
280UnitySDK/Assets/ML-Agents/Examples/3DBall/Scenes/3DBall.unity
-
226UnitySDK/Assets/ML-Agents/Examples/3DBall/Scenes/3DBallHard.unity
-
9UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DDecision.cs
-
70UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Prefabs/RLArea.prefab
-
68UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Prefabs/TeachingArea.prefab
-
57UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Prefabs/VisualRLArea.prefab
-
417UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scenes/Banana.unity
-
384UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scenes/BananaIL.unity
-
257UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scenes/VisualBanana.unity
-
444UnitySDK/Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity
-
6UnitySDK/Assets/ML-Agents/Examples/Basic/Scripts/BasicDecision.cs
-
12UnitySDK/Assets/ML-Agents/Examples/Bouncer/Prefabs/Environment.prefab
-
216UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scenes/Bouncer.unity
-
318UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scenes/BouncerIL.unity
-
35UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
-
25UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
-
21UnitySDK/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
-
192UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
-
753UnitySDK/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity
-
168UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scenes/GridWorld.unity
-
15UnitySDK/Assets/ML-Agents/Examples/Hallway/Prefabs/HallwayArea.prefab
-
17UnitySDK/Assets/ML-Agents/Examples/Hallway/Prefabs/VisualHallwayArea.prefab
-
322UnitySDK/Assets/ML-Agents/Examples/Hallway/Scenes/Hallway.unity
-
980UnitySDK/Assets/ML-Agents/Examples/Hallway/Scenes/HallwayIL.unity
-
234UnitySDK/Assets/ML-Agents/Examples/Hallway/Scenes/VisualHallway.unity
-
11UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab
-
13UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/VisualArea.prefab
-
567UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlock.unity
-
980UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockIL.unity
-
240UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scenes/VisualPushBlock.unity
-
42UnitySDK/Assets/ML-Agents/Examples/Pyramids/Prefabs/AreaPB.prefab
-
42UnitySDK/Assets/ML-Agents/Examples/Pyramids/Prefabs/VisualAreaPB.prefab
-
624UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scenes/Pyramids.unity
-
366UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scenes/PyramidsIL.unity
-
202UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scenes/VisualPyramids.unity
-
10UnitySDK/Assets/ML-Agents/Examples/Reacher/Prefabs/Agent.prefab
-
207UnitySDK/Assets/ML-Agents/Examples/Reacher/Scenes/Reacher.unity
-
6UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherDecision.cs
-
17UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RandomDecision.cs
-
899UnitySDK/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
-
2UnitySDK/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab.meta
-
941UnitySDK/Assets/ML-Agents/Examples/Soccer/Scenes/SoccerTwos.unity
-
6UnitySDK/Assets/ML-Agents/Examples/Template/Scripts/TemplateDecision.cs
-
17UnitySDK/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab
-
707UnitySDK/Assets/ML-Agents/Examples/Tennis/Scenes/Tennis.unity
-
317UnitySDK/Assets/ML-Agents/Examples/Tennis/Scenes/TennisIL.unity
-
20UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
-
27UnitySDK/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab
-
628UnitySDK/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
-
13UnitySDK/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab
-
747UnitySDK/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity
-
80UnitySDK/Assets/ML-Agents/Scripts/Academy.cs
-
21UnitySDK/Assets/ML-Agents/Scripts/ActionMasker.cs
-
81UnitySDK/Assets/ML-Agents/Scripts/Agent.cs
-
154UnitySDK/Assets/ML-Agents/Scripts/Batcher.cs
-
278UnitySDK/Assets/ML-Agents/Scripts/Brain.cs
-
58UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/BrainParametersProto.cs
-
4UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityInput.cs
-
6UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityMessage.cs
-
4UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityOutput.cs
-
2UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityRlInitializationOutput.cs
-
2UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityRlInput.cs
-
8UnitySDK/Assets/ML-Agents/Scripts/CommunicatorObjects/UnityToExternalGrpc.cs
-
8UnitySDK/Assets/ML-Agents/Scripts/Decision.cs
-
3UnitySDK/Assets/ML-Agents/Scripts/LearningBrain.cs.meta
-
80config/trainer_config.yaml
-
2docs/Background-Machine-Learning.md
-
16docs/Background-TensorFlow.md
-
2docs/Background-Unity.md
-
149docs/Basic-Guide.md
-
69docs/FAQ.md
-
80docs/Getting-Started-with-Balance-Ball.md
-
6docs/Glossary.md
-
23docs/Installation-Windows.md
-
42docs/Installation.md
-
2docs/Learning-Environment-Best-Practices.md
-
368docs/Learning-Environment-Create-New.md
-
5docs/Learning-Environment-Design-Academy.md
-
19docs/Learning-Environment-Design-Agents.md
-
70docs/Learning-Environment-Design-Brains.md
-
11docs/Learning-Environment-Design-Heuristic-Brains.md
-
9docs/Learning-Environment-Design-Player-Brains.md
-
51docs/Learning-Environment-Design.md
-
13docs/Learning-Environment-Examples.md
-
66docs/Learning-Environment-Executable.md
-
3docs/Limitations.md
-
64docs/ML-Agents-Overview.md
-
51docs/Migrating.md
-
17docs/Python-API.md
-
6docs/Readme.md
-
4docs/Training-Curriculum-Learning.md
-
78docs/Training-Imitation-Learning.md
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using UnityEditor; |
|||
using System.Linq; |
|||
/* |
|||
This code is meant to modify the behavior of the inspector on Brain Components. |
|||
Depending on the type of brain that is used, the available fields will be modified in the inspector accordingly. |
|||
*/ |
|||
/// <summary>
|
|||
/// CustomEditor for the Brain base class. Defines the default Inspector view for a Brain.
|
|||
/// Shows the BrainParameters of the Brain and expose a tool to deep copy BrainParameters
|
|||
/// between brains.
|
|||
/// </summary>
|
|||
{ |
|||
[SerializeField] bool _Foldout = true; |
|||
|
|||
{ |
|||
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); |
|||
} |
|||
|
|||
serializedBrain.Update(); |
|||
|
|||
|
|||
_Foldout = EditorGUILayout.Foldout(_Foldout, "Brain Parameters"); |
|||
int indentLevel = EditorGUI.indentLevel; |
|||
if (_Foldout) |
|||
{ |
|||
EditorGUI.indentLevel++; |
|||
EditorGUILayout.LabelField("Vector Observation"); |
|||
EditorGUI.indentLevel++; |
|||
|
|||
SerializedProperty bpVectorObsSize = |
|||
serializedBrain.FindProperty("brainParameters.vectorObservationSize"); |
|||
EditorGUILayout.PropertyField(bpVectorObsSize, new GUIContent("Space Size", |
|||
"Length of state " + |
|||
"vector for brain (In Continuous state space)." + |
|||
"Or number of possible values (in Discrete state space).")); |
|||
|
|||
|
|||
SerializedProperty bpNumStackedVectorObs = |
|||
serializedBrain.FindProperty("brainParameters.numStackedVectorObservations"); |
|||
EditorGUILayout.PropertyField(bpNumStackedVectorObs, new GUIContent( |
|||
"Stacked Vectors", "Number of states that" + |
|||
" will be stacked before beeing fed to the neural network.")); |
|||
|
|||
EditorGUI.indentLevel--; |
|||
SerializedProperty bpCamResol = |
|||
serializedBrain.FindProperty("brainParameters.cameraResolutions"); |
|||
EditorGUILayout.PropertyField(bpCamResol, new GUIContent("Visual Observation", |
|||
"Describes height, " + |
|||
"width, and whether to greyscale visual observations for the Brain."), true); |
|||
|
|||
EditorGUILayout.LabelField("Vector Action"); |
|||
EditorGUI.indentLevel++; |
|||
|
|||
SerializedProperty bpVectorActionType = |
|||
serializedBrain.FindProperty("brainParameters.vectorActionSpaceType"); |
|||
EditorGUILayout.PropertyField(bpVectorActionType, new GUIContent("Space Type", |
|||
"Corresponds to whether state" + |
|||
" vector contains a single integer (Discrete) " + |
|||
"or a series of real-valued floats (Continuous).")); |
|||
if (bpVectorActionType.enumValueIndex == 1) |
|||
{ |
|||
//Continuous case :
|
|||
SerializedProperty bpVectorActionSize = |
|||
serializedBrain.FindProperty("brainParameters.vectorActionSize"); |
|||
bpVectorActionSize.arraySize = 1; |
|||
SerializedProperty continuousActionSize = |
|||
bpVectorActionSize.GetArrayElementAtIndex(0); |
|||
EditorGUILayout.PropertyField(continuousActionSize, new GUIContent( |
|||
"Space Size", "Length of continuous action vector.")); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
// Discrete case :
|
|||
SerializedProperty bpVectorActionSize = |
|||
serializedBrain.FindProperty("brainParameters.vectorActionSize"); |
|||
bpVectorActionSize.arraySize = EditorGUILayout.IntField( |
|||
"Branches Size", bpVectorActionSize.arraySize); |
|||
EditorGUI.indentLevel++; |
|||
for (int branchIndex = 0; |
|||
branchIndex < bpVectorActionSize.arraySize; |
|||
branchIndex++) |
|||
{ |
|||
SerializedProperty branchActionSize = |
|||
bpVectorActionSize.GetArrayElementAtIndex(branchIndex); |
|||
EditorGUILayout.PropertyField(branchActionSize, new GUIContent( |
|||
"Branch " + branchIndex+" Size", |
|||
"Number of possible actions for the branch number " + branchIndex+".")); |
|||
} |
|||
EditorGUI.indentLevel--; |
|||
|
|||
} |
|||
|
|||
try |
|||
{ |
|||
BrainParameters parameters = myBrain.brainParameters; |
|||
int numberOfDescriptions = 0; |
|||
if (parameters.vectorActionSpaceType == SpaceType.continuous) |
|||
numberOfDescriptions = parameters.vectorActionSize[0]; |
|||
else |
|||
numberOfDescriptions = parameters.vectorActionSize.Length; |
|||
if (parameters.vectorActionDescriptions == null || |
|||
parameters.vectorActionDescriptions.Length != numberOfDescriptions) |
|||
parameters.vectorActionDescriptions = new string[numberOfDescriptions]; |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
|
|||
if (bpVectorActionType.enumValueIndex == 1) |
|||
{ |
|||
//Continuous case :
|
|||
SerializedProperty bpVectorActionDescription = |
|||
serializedBrain.FindProperty("brainParameters.vectorActionDescriptions"); |
|||
EditorGUILayout.PropertyField(bpVectorActionDescription, new GUIContent( |
|||
"Action Descriptions", "A list of strings used to name" + |
|||
" the available actions for the Brain."), true); |
|||
} |
|||
else |
|||
{ |
|||
// Discrete case :
|
|||
SerializedProperty bpVectorActionDescription = |
|||
serializedBrain.FindProperty("brainParameters.vectorActionDescriptions"); |
|||
EditorGUILayout.PropertyField(bpVectorActionDescription, new GUIContent( |
|||
"Branch Descriptions", "A list of strings used to name" + |
|||
" the available branches for the Brain."), true); |
|||
} |
|||
} |
|||
|
|||
EditorGUI.indentLevel = indentLevel; |
|||
SerializedProperty bt = serializedBrain.FindProperty("brainType"); |
|||
EditorGUILayout.PropertyField(bt); |
|||
|
|||
if (bt.enumValueIndex < 0) |
|||
var brain = (Brain) target; |
|||
var brainToCopy = EditorGUILayout.ObjectField( |
|||
"Copy Brain Parameters from : ", null, typeof(Brain), false) as Brain; |
|||
if (brainToCopy != null) |
|||
bt.enumValueIndex = (int) BrainType.Player; |
|||
brain.brainParameters = brainToCopy.brainParameters.Clone(); |
|||
EditorUtility.SetDirty(brain); |
|||
AssetDatabase.SaveAssets(); |
|||
return; |
|||
|
|||
var serializedBrain = serializedObject; |
|||
serializedBrain.Update(); |
|||
EditorGUILayout.PropertyField(serializedBrain.FindProperty("brainParameters"), true); |
|||
|
|||
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
|
|||
|
|||
// Draws a horizontal thick line
|
|||
EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f1895a43ed0f54ffd9ee06234c4399e7 |
|||
timeCreated: 1503270350 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
fileFormatVersion: 2 |
|||
guid: 7b07bebd03994ed08559c725da882b62 |
|||
timeCreated: 1537834304 |