Skip to content

Commit

Permalink
Initial version of environment, models still need tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
jiwoojang committed May 22, 2018
1 parent efdd381 commit cc315fc
Show file tree
Hide file tree
Showing 503 changed files with 83,408 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Ignore Unity temporary files, build results, etc
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
/[Bb]uilds[Nn][Cc]lips/
/.vs/

# Autogenerated VS/MD solution and project files
ExportedObj/
.vs/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd

# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Tensorflow Sharp Files
/Assets/ML-Agents/Plugins/Android*
/Assets/ML-Agents/Plugins/iOS*
/Assets/ML-Agents/Plugins/Computer*
/Assets/ML-Agents/Plugins/System*

# Builds
*.apk
*.unitypackage

# OSX
.DS_Store
9 changes: 9 additions & 0 deletions Assets/ML-Agents.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/ML-Agents/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions Assets/ML-Agents/Editor/AgentEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using UnityEngine;
using UnityEditor;

/*
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.
*/
[CustomEditor(typeof(Agent), true)]
[CanEditMultipleObjects]
public class AgentEditor : Editor
{

public override void OnInspectorGUI()
{
SerializedObject serializedAgent = serializedObject;
serializedAgent.Update();

SerializedProperty brain = serializedAgent.FindProperty("brain");
SerializedProperty actionsPerDecision = serializedAgent.FindProperty(
"agentParameters.numberOfActionsBetweenDecisions");
SerializedProperty maxSteps = serializedAgent.FindProperty(
"agentParameters.maxStep");
SerializedProperty isResetOnDone = serializedAgent.FindProperty(
"agentParameters.resetOnDone");
SerializedProperty isODD = serializedAgent.FindProperty(
"agentParameters.onDemandDecision");
SerializedProperty cameras = serializedAgent.FindProperty(
"agentParameters.agentCameras");

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() + ": "));
}
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Add Camera", EditorStyles.miniButton))
{
cameras.arraySize++;
}
if (GUILayout.Button("Remove Camera", EditorStyles.miniButton))
{
cameras.arraySize--;
}
EditorGUILayout.EndHorizontal();

EditorGUILayout.PropertyField(
maxSteps,
new GUIContent(
"Max Step", "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(
isODD,
new GUIContent(
"On Demand Decisions",
"If checked, you must manually request decisions."));
if (!isODD.boolValue)
{
EditorGUILayout.PropertyField(
actionsPerDecision,
new GUIContent(
"Decision Frequency",
"The agent will automatically request a decision every X" +
" steps and perform an action at every step."));
actionsPerDecision.intValue = Mathf.Max(1, actionsPerDecision.intValue);
}

serializedAgent.ApplyModifiedProperties();

EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
base.OnInspectorGUI();
}
}
12 changes: 12 additions & 0 deletions Assets/ML-Agents/Editor/AgentEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions Assets/ML-Agents/Editor/BrainEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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.
*/
[CustomEditor (typeof(Brain))]
public class BrainEditor : Editor
{
[SerializeField]
bool _Foldout = true;

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);
}

BrainParameters parameters = myBrain.brainParameters;
if (parameters.vectorActionDescriptions == null || parameters.vectorActionDescriptions.Length != parameters.vectorActionSize)
parameters.vectorActionDescriptions = new string[parameters.vectorActionSize];

serializedBrain.Update();


_Foldout = EditorGUILayout.Foldout(_Foldout, "Brain Parameters");
int indentLevel = EditorGUI.indentLevel;
if (_Foldout)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("Vector Observation");
EditorGUI.indentLevel++;

SerializedProperty bpVectorObsType = serializedBrain.FindProperty("brainParameters.vectorObservationSpaceType");
EditorGUILayout.PropertyField(bpVectorObsType, new GUIContent("Space Type", "Corresponds to whether state " +
"vector contains a single integer (Discrete) " +
"or a series of real-valued floats (Continuous)."));

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)."));

SerializedProperty bpVectorActionSize = serializedBrain.FindProperty("brainParameters.vectorActionSize");
EditorGUILayout.PropertyField(bpVectorActionSize, new GUIContent("Space Size", "Length of action vector " +
"for brain (In Continuous state space)." +
"Or number of possible values (In Discrete action space)."));

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);

}
EditorGUI.indentLevel = indentLevel;
SerializedProperty bt = serializedBrain.FindProperty("brainType");
EditorGUILayout.PropertyField(bt);




if (bt.enumValueIndex < 0) {
bt.enumValueIndex = (int)BrainType.Player;
}

serializedBrain.ApplyModifiedProperties();

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
}
}
12 changes: 12 additions & 0 deletions Assets/ML-Agents/Editor/BrainEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cc315fc

Please sign in to comment.