├── .gitignore ├── Assets ├── Controller.cs ├── Controller.cs.meta ├── Data.meta ├── Data │ ├── Eyes.mat │ ├── Eyes.mat.meta │ ├── Frictionless Material.physicMaterial │ ├── Frictionless Material.physicMaterial.meta │ ├── Fur.mat │ └── Fur.mat.meta ├── ML-Agents.meta ├── ML-Agents │ ├── Editor.meta │ ├── Editor │ │ ├── BrainEditor.cs │ │ └── BrainEditor.cs.meta │ ├── Plugins.meta │ ├── Plugins │ │ ├── JSON.meta │ │ └── JSON │ │ │ ├── Newtonsoft.Json.dll │ │ │ └── Newtonsoft.Json.dll.meta │ ├── RatML.meta │ ├── RatML │ │ ├── MLScripts.meta │ │ ├── MLScripts │ │ │ ├── TemplateAcademy.cs │ │ │ ├── TemplateAcademy.cs.meta │ │ │ ├── TemplateAgent.cs │ │ │ ├── TemplateAgent.cs.meta │ │ │ ├── TemplateDecision.cs │ │ │ └── TemplateDecision.cs.meta │ │ ├── Scene.unity │ │ └── Scene.unity.meta │ ├── Scripts.meta │ └── Scripts │ │ ├── Academy.cs │ │ ├── Academy.cs.meta │ │ ├── Agent.cs │ │ ├── Agent.cs.meta │ │ ├── Brain.cs │ │ ├── Brain.cs.meta │ │ ├── Communicator.cs │ │ ├── Communicator.cs.meta │ │ ├── CoreBrain.cs │ │ ├── CoreBrain.cs.meta │ │ ├── CoreBrainExternal.cs │ │ ├── CoreBrainExternal.cs.meta │ │ ├── CoreBrainHeuristic.cs │ │ ├── CoreBrainHeuristic.cs.meta │ │ ├── CoreBrainInternal.cs │ │ ├── CoreBrainInternal.cs.meta │ │ ├── CoreBrainPlayer.cs │ │ ├── CoreBrainPlayer.cs.meta │ │ ├── Decision.cs │ │ ├── Decision.cs.meta │ │ ├── ExternalCommunicator.cs │ │ ├── ExternalCommunicator.cs.meta │ │ ├── Monitor.cs │ │ ├── Monitor.cs.meta │ │ ├── UnityAgentsException.cs │ │ └── UnityAgentsException.cs.meta ├── MLScripts.meta ├── MLScripts │ ├── RatAcademy.cs │ ├── RatAcademy.cs.meta │ ├── RatAgent.cs │ ├── RatAgent.cs.meta │ ├── RatDecision.cs │ └── RatDecision.cs.meta ├── Prefabs.meta ├── Prefabs │ ├── EnvBox.prefab │ ├── EnvBox.prefab.meta │ ├── EnvHex.prefab │ ├── EnvHex.prefab.meta │ ├── EnvSmallBox.prefab │ ├── EnvSmallBox.prefab.meta │ ├── Rat.prefab │ └── Rat.prefab.meta ├── RecordExperiment.cs ├── RecordExperiment.cs.meta ├── TimeScale.cs ├── TimeScale.cs.meta ├── UtilityBase.cs ├── UtilityBase.cs.meta ├── UtilityExternalControl.cs ├── UtilityExternalControl.cs.meta ├── UtilityRandomAttractor.cs ├── UtilityRandomAttractor.cs.meta ├── UtilityRandomWalk.cs ├── UtilityRandomWalk.cs.meta ├── square.unity └── square.unity.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset ├── README.md ├── Rat.ipynb ├── RatLSTMWithNoise.ipynb ├── RatRNNWithNoise.ipynb ├── images ├── lstm_loss.png ├── lstm_neuron_activation.png └── lstm_paths.png ├── rat_data └── data.p ├── rat_data_rnd └── data.p └── unityagents ├── __init__.py ├── brain.py ├── curriculum.py ├── environment.py └── exception.py /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /[Pp]ackages/ 7 | /[Uu]nityPackageManager/ 8 | /Assets/AssetStoreTools* 9 | 10 | # Visual Studio 2015 cache directory 11 | /.vs/ 12 | 13 | # Autogenerated VS/MD/Consulo solution and project files 14 | ExportedObj/ 15 | .consulo/ 16 | *.csproj 17 | *.unityproj 18 | *.sln 19 | *.suo 20 | *.tmp 21 | *.user 22 | *.userprefs 23 | *.pidb 24 | *.booproj 25 | *.svd 26 | *.pdb 27 | 28 | # Unity3D generated meta files 29 | *.pidb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | /sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | *.app 38 | *.exe 39 | *.x86_64 40 | *.x86 41 | 42 | # Tensorflow Sharp Files 43 | /Assets/ML-Agents/Plugins/Android* 44 | /Assets/ML-Agents/Plugins/iOS* 45 | /Assets/ML-Agents/Plugins/Computer* 46 | /Assets/ML-Agents/Plugins/System* 47 | 48 | 49 | # Mac hidden files 50 | *.DS_Store 51 | */.ipynb_checkpoints 52 | */.idea 53 | *.pyc 54 | *.idea/misc.xml 55 | *.idea/modules.xml 56 | *.iml 57 | *.xml 58 | *.cache 59 | */build/ 60 | */dist/ 61 | *.egg-info* 62 | *.eggs* 63 | *.gitignore.swp 64 | 65 | .DS_Store 66 | -------------------------------------------------------------------------------- /Assets/Controller.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Linq; 4 | 5 | public class Controller : MonoBehaviour { 6 | 7 | public float runSpeed = .1f; 8 | public float turnSpeed = 10f; 9 | 10 | public int whiskersCount = 10; 11 | public float whiskersAngle = 120; 12 | public float whiskersLength = 1; 13 | 14 | private Rigidbody body; 15 | private float bodyRadius; 16 | 17 | private ObservableState state; 18 | public ObservableState observableState { get { return state; } } 19 | 20 | [Serializable] 21 | public struct ObservableState 22 | { 23 | public float heading, velocity; 24 | public float x, y; 25 | public float[] sensors; 26 | } 27 | 28 | void Start() 29 | { 30 | body = GetComponent(); 31 | bodyRadius = GetComponent().bounds.extents.z; 32 | } 33 | 34 | void FixedUpdate() 35 | { 36 | var sensors = ReadSensors(); 37 | 38 | var utilities = GetComponents(); 39 | var sumPriority = utilities.Sum(u => u.priority * (u.isActiveAndEnabled ? 1: 0f)); 40 | sumPriority = Mathf.Max(sumPriority, Mathf.Epsilon); 41 | 42 | Vector2 control = Vector2.zero; 43 | foreach (var u in utilities) 44 | if (u.isActiveAndEnabled) 45 | control += u.Control (sensors) * u.priority / sumPriority; 46 | 47 | body.angularVelocity = Vector3.up * Mathf.Deg2Rad * Mathf.Clamp(control.x, -1f, 1f) * turnSpeed; 48 | body.velocity = transform.forward * Mathf.Clamp01(control.y) * runSpeed; 49 | 50 | state = new ObservableState { 51 | heading = Mathf.Clamp(control.x, -1f, 1f), velocity = Mathf.Clamp01(control.y), // in 52 | x = transform.position.x, y = transform.position.y, // out 53 | sensors = sensors // aux 54 | }; 55 | } 56 | 57 | float[] ReadSensors() 58 | { 59 | var sensors = new float[whiskersCount]; 60 | 61 | var angle = -whiskersAngle / 2.0f; 62 | for (int q = 0; q < whiskersCount; ++q, angle += whiskersAngle / whiskersCount) 63 | { 64 | var dir = Quaternion.Euler(0, angle, 0) * transform.forward; 65 | var orig = transform.position + dir * bodyRadius; 66 | 67 | RaycastHit hit; 68 | if (Physics.Raycast(orig, dir, out hit, whiskersLength)) 69 | sensors[q] = 1.0f - hit.distance / whiskersLength; 70 | 71 | Debug.DrawLine(orig, orig + dir * whiskersLength, sensors[q] > 0 ? Color.red: Color.green, 0, false); 72 | } 73 | 74 | return sensors; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Assets/Controller.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72e5fca66c85943329bbc26afe735277 3 | timeCreated: 1509833745 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Data.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57ffa7b9ce5b64f49bc281fe67e24cba 3 | folderAsset: yes 4 | timeCreated: 1509880210 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Data/Eyes.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Eyes 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.864 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0, g: 0, b: 0, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/Data/Eyes.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8ba1c496f08c48e7a5e6269d595f075 3 | timeCreated: 1509835756 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Data/Frictionless Material.physicMaterial: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!134 &13400000 4 | PhysicMaterial: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: Frictionless Material 9 | dynamicFriction: 0 10 | staticFriction: 0 11 | bounciness: 0 12 | frictionCombine: 1 13 | bounceCombine: 0 14 | -------------------------------------------------------------------------------- /Assets/Data/Frictionless Material.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad6b5840d6fbb4a609ffa3b7d1cf3efb 3 | timeCreated: 1509835375 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 13400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Data/Fur.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Fur 10 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.292 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 0.8014706, g: 0.8014706, b: 0.8014706, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/Data/Fur.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b536362e1693b4dda82792d88b3925c6 3 | timeCreated: 1509835756 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ML-Agents.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 408c1fa17d3e6431d9dd845125d69ea2 3 | folderAsset: yes 4 | timeCreated: 1510274532 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67b4fb0b937cc471eae742addf6bda86 3 | folderAsset: yes 4 | timeCreated: 1503177274 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Editor/BrainEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using UnityEditor; 6 | using System.Linq; 7 | /* 8 | This code is meant to modify the behavior of the inspector on Brain Components. 9 | Depending on the type of brain that is used, the available fields will be modified in the inspector accordingly. 10 | */ 11 | [CustomEditor (typeof(Brain))] 12 | public class BrainEditor : Editor 13 | { 14 | public override void OnInspectorGUI () 15 | { 16 | Brain myBrain = (Brain)target; 17 | SerializedObject serializedBrain = serializedObject; 18 | 19 | if (myBrain.transform.parent == null) { 20 | EditorGUILayout.HelpBox ("A Brain GameObject must be a child of an Academy GameObject!", MessageType.Error); 21 | } else if (myBrain.transform.parent.GetComponent () == null) { 22 | EditorGUILayout.HelpBox ("The Parent of a Brain must have an Academy Component attached to it!", MessageType.Error); 23 | } 24 | 25 | BrainParameters parameters = myBrain.brainParameters; 26 | if (parameters.actionDescriptions == null || parameters.actionDescriptions.Length != parameters.actionSize) 27 | parameters.actionDescriptions = new string[parameters.actionSize]; 28 | 29 | serializedBrain.Update(); 30 | 31 | SerializedProperty bp = serializedBrain.FindProperty ("brainParameters"); 32 | EditorGUILayout.PropertyField(bp, true); 33 | 34 | SerializedProperty bt = serializedBrain.FindProperty("brainType"); 35 | EditorGUILayout.PropertyField(bt); 36 | 37 | if (bt.enumValueIndex < 0) { 38 | bt.enumValueIndex = (int)BrainType.Player; 39 | } 40 | 41 | serializedBrain.ApplyModifiedProperties(); 42 | 43 | myBrain.UpdateCoreBrains (); 44 | myBrain.coreBrain.OnInspector (); 45 | 46 | #if !NET_4_6 && ENABLE_TENSORFLOW 47 | EditorGUILayout.HelpBox ("You cannot have ENABLE_TENSORFLOW without NET_4_6", MessageType.Error); 48 | #endif 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Editor/BrainEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1895a43ed0f54ffd9ee06234c4399e7 3 | timeCreated: 1503270350 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6d56028f4c564724878c82cfa3c9e14 3 | folderAsset: yes 4 | timeCreated: 1502996258 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Plugins/JSON.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19240955c74d74ddf87ba8e888965f7b 3 | folderAsset: yes 4 | timeCreated: 1504198536 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Plugins/JSON/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/rat-rnn/e0e03f6f990fe9eafaaaf8433cd1e164b1b27e7a/Assets/ML-Agents/Plugins/JSON/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /Assets/ML-Agents/Plugins/JSON/Newtonsoft.Json.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2471d838da1db4d07ad5ad6a2c196a5b 3 | timeCreated: 1489286987 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 1 14 | settings: {} 15 | Editor: 16 | enabled: 0 17 | settings: 18 | DefaultValueInitialized: true 19 | WindowsStoreApps: 20 | enabled: 0 21 | settings: 22 | CPU: AnyCPU 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b026b677021af42a0b99c0d2a72c33cf 3 | folderAsset: yes 4 | timeCreated: 1510274623 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 555e3f618ec674c99b55df9b43caeae0 3 | folderAsset: yes 4 | timeCreated: 1510274623 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts/TemplateAcademy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TemplateAcademy : Academy { 6 | 7 | public override void AcademyReset() 8 | { 9 | 10 | 11 | } 12 | 13 | public override void AcademyStep() 14 | { 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts/TemplateAcademy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f692682f9d5844aa3a0569999202d01d 3 | timeCreated: 1503355437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts/TemplateAgent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TemplateAgent : Agent { 6 | 7 | 8 | 9 | public override List CollectState() 10 | { 11 | List state = new List(); 12 | 13 | return state; 14 | } 15 | 16 | public override void AgentStep(float[] act) 17 | { 18 | 19 | } 20 | 21 | public override void AgentReset() 22 | { 23 | 24 | } 25 | 26 | public override void AgentOnDone() 27 | { 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts/TemplateAgent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec1ec67d8254348a498a37c8f07b7b11 3 | timeCreated: 1503355437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts/TemplateDecision.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TemplateDecision : MonoBehaviour, Decision 6 | { 7 | 8 | public float[] Decide(List state, List observation, float reward, bool done, float[] memory) 9 | { 10 | return new float[0]; 11 | 12 | } 13 | 14 | public float[] MakeMemory(List state, List observation, float reward, bool done, float[] memory) 15 | { 16 | return new float[0]; 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/MLScripts/TemplateDecision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28538439dbb1c43e280dbab5d8ad62d9 3 | timeCreated: 1503355437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/Scene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 8 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | --- !u!157 &3 43 | LightmapSettings: 44 | m_ObjectHideFlags: 0 45 | serializedVersion: 11 46 | m_GIWorkflowMode: 1 47 | m_GISettings: 48 | serializedVersion: 2 49 | m_BounceScale: 1 50 | m_IndirectOutputScale: 1 51 | m_AlbedoBoost: 1 52 | m_TemporalCoherenceThreshold: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 9 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_TextureWidth: 1024 61 | m_TextureHeight: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFiltering: 0 81 | m_PVRFilteringMode: 1 82 | m_PVRCulling: 1 83 | m_PVRFilteringGaussRadiusDirect: 1 84 | m_PVRFilteringGaussRadiusIndirect: 5 85 | m_PVRFilteringGaussRadiusAO: 2 86 | m_PVRFilteringAtrousColorSigma: 1 87 | m_PVRFilteringAtrousNormalSigma: 1 88 | m_PVRFilteringAtrousPositionSigma: 1 89 | m_LightingDataAsset: {fileID: 0} 90 | m_UseShadowmask: 1 91 | --- !u!196 &4 92 | NavMeshSettings: 93 | serializedVersion: 2 94 | m_ObjectHideFlags: 0 95 | m_BuildSettings: 96 | serializedVersion: 2 97 | agentTypeID: 0 98 | agentRadius: 0.5 99 | agentHeight: 2 100 | agentSlope: 45 101 | agentClimb: 0.4 102 | ledgeDropHeight: 0 103 | maxJumpAcrossDistance: 0 104 | minRegionArea: 2 105 | manualCellSize: 0 106 | cellSize: 0.16666667 107 | manualTileSize: 0 108 | tileSize: 256 109 | accuratePlacement: 0 110 | m_NavMeshData: {fileID: 0} 111 | --- !u!1 &762086410 112 | GameObject: 113 | m_ObjectHideFlags: 0 114 | m_PrefabParentObject: {fileID: 0} 115 | m_PrefabInternal: {fileID: 0} 116 | serializedVersion: 5 117 | m_Component: 118 | - component: {fileID: 762086412} 119 | - component: {fileID: 762086411} 120 | m_Layer: 0 121 | m_Name: Directional Light 122 | m_TagString: Untagged 123 | m_Icon: {fileID: 0} 124 | m_NavMeshLayer: 0 125 | m_StaticEditorFlags: 0 126 | m_IsActive: 1 127 | --- !u!108 &762086411 128 | Light: 129 | m_ObjectHideFlags: 0 130 | m_PrefabParentObject: {fileID: 0} 131 | m_PrefabInternal: {fileID: 0} 132 | m_GameObject: {fileID: 762086410} 133 | m_Enabled: 1 134 | serializedVersion: 8 135 | m_Type: 1 136 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 137 | m_Intensity: 1 138 | m_Range: 10 139 | m_SpotAngle: 30 140 | m_CookieSize: 10 141 | m_Shadows: 142 | m_Type: 2 143 | m_Resolution: -1 144 | m_CustomResolution: -1 145 | m_Strength: 1 146 | m_Bias: 0.05 147 | m_NormalBias: 0.4 148 | m_NearPlane: 0.2 149 | m_Cookie: {fileID: 0} 150 | m_DrawHalo: 0 151 | m_Flare: {fileID: 0} 152 | m_RenderMode: 0 153 | m_CullingMask: 154 | serializedVersion: 2 155 | m_Bits: 4294967295 156 | m_Lightmapping: 4 157 | m_AreaSize: {x: 1, y: 1} 158 | m_BounceIntensity: 1 159 | m_FalloffTable: 160 | m_Table[0]: 0 161 | m_Table[1]: 0 162 | m_Table[2]: 0 163 | m_Table[3]: 0 164 | m_Table[4]: 0 165 | m_Table[5]: 0 166 | m_Table[6]: 0 167 | m_Table[7]: 0 168 | m_Table[8]: 0 169 | m_Table[9]: 0 170 | m_Table[10]: 0 171 | m_Table[11]: 0 172 | m_Table[12]: 0 173 | m_ColorTemperature: 6570 174 | m_UseColorTemperature: 0 175 | m_ShadowRadius: 0 176 | m_ShadowAngle: 0 177 | --- !u!4 &762086412 178 | Transform: 179 | m_ObjectHideFlags: 0 180 | m_PrefabParentObject: {fileID: 0} 181 | m_PrefabInternal: {fileID: 0} 182 | m_GameObject: {fileID: 762086410} 183 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 184 | m_LocalPosition: {x: 0, y: 3, z: 0} 185 | m_LocalScale: {x: 1, y: 1, z: 1} 186 | m_Children: [] 187 | m_Father: {fileID: 0} 188 | m_RootOrder: 1 189 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 190 | --- !u!1 &846768603 191 | GameObject: 192 | m_ObjectHideFlags: 0 193 | m_PrefabParentObject: {fileID: 0} 194 | m_PrefabInternal: {fileID: 0} 195 | serializedVersion: 5 196 | m_Component: 197 | - component: {fileID: 846768604} 198 | - component: {fileID: 846768605} 199 | m_Layer: 0 200 | m_Name: Brain 201 | m_TagString: Untagged 202 | m_Icon: {fileID: 0} 203 | m_NavMeshLayer: 0 204 | m_StaticEditorFlags: 0 205 | m_IsActive: 1 206 | --- !u!4 &846768604 207 | Transform: 208 | m_ObjectHideFlags: 0 209 | m_PrefabParentObject: {fileID: 0} 210 | m_PrefabInternal: {fileID: 0} 211 | m_GameObject: {fileID: 846768603} 212 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 213 | m_LocalPosition: {x: 0, y: 0, z: 0} 214 | m_LocalScale: {x: 1, y: 1, z: 1} 215 | m_Children: [] 216 | m_Father: {fileID: 1574236049} 217 | m_RootOrder: 0 218 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 219 | --- !u!114 &846768605 220 | MonoBehaviour: 221 | m_ObjectHideFlags: 0 222 | m_PrefabParentObject: {fileID: 0} 223 | m_PrefabInternal: {fileID: 0} 224 | m_GameObject: {fileID: 846768603} 225 | m_Enabled: 1 226 | m_EditorHideFlags: 0 227 | m_Script: {fileID: 11500000, guid: c676a8ddf5a5f4f64b35e9ed5028679d, type: 3} 228 | m_Name: 229 | m_EditorClassIdentifier: 230 | brainParameters: 231 | stateSize: 12 232 | actionSize: 4 233 | memorySize: 0 234 | cameraResolutions: 235 | - width: 80 236 | height: 80 237 | blackAndWhite: 1 238 | actionDescriptions: 239 | - Up 240 | - Down 241 | - Left 242 | - Right 243 | actionSpaceType: 0 244 | stateSpaceType: 1 245 | brainType: 2 246 | CoreBrains: [] 247 | CollectData: 0 248 | instanceID: 0 249 | --- !u!1 &1223085755 250 | GameObject: 251 | m_ObjectHideFlags: 0 252 | m_PrefabParentObject: {fileID: 0} 253 | m_PrefabInternal: {fileID: 0} 254 | serializedVersion: 5 255 | m_Component: 256 | - component: {fileID: 1223085757} 257 | - component: {fileID: 1223085756} 258 | m_Layer: 0 259 | m_Name: Agent 260 | m_TagString: Untagged 261 | m_Icon: {fileID: 0} 262 | m_NavMeshLayer: 0 263 | m_StaticEditorFlags: 0 264 | m_IsActive: 1 265 | --- !u!114 &1223085756 266 | MonoBehaviour: 267 | m_ObjectHideFlags: 0 268 | m_PrefabParentObject: {fileID: 0} 269 | m_PrefabInternal: {fileID: 0} 270 | m_GameObject: {fileID: 1223085755} 271 | m_Enabled: 1 272 | m_EditorHideFlags: 0 273 | m_Script: {fileID: 11500000, guid: 33bb739f1138d40798114d667776a1d6, type: 3} 274 | m_Name: 275 | m_EditorClassIdentifier: 276 | brain: {fileID: 846768605} 277 | observations: 278 | - {fileID: 1715640924} 279 | maxStep: 100 280 | resetOnDone: 1 281 | id: 0 282 | reward: 0 283 | done: 0 284 | value: 0 285 | CummulativeReward: 0 286 | stepCounter: 0 287 | agentStoredAction: [] 288 | memory: [] 289 | --- !u!4 &1223085757 290 | Transform: 291 | m_ObjectHideFlags: 0 292 | m_PrefabParentObject: {fileID: 0} 293 | m_PrefabInternal: {fileID: 0} 294 | m_GameObject: {fileID: 1223085755} 295 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 296 | m_LocalPosition: {x: 0.71938086, y: 0.27357092, z: 4.1970553} 297 | m_LocalScale: {x: 1, y: 1, z: 1} 298 | m_Children: [] 299 | m_Father: {fileID: 0} 300 | m_RootOrder: 3 301 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 302 | --- !u!1 &1574236047 303 | GameObject: 304 | m_ObjectHideFlags: 0 305 | m_PrefabParentObject: {fileID: 0} 306 | m_PrefabInternal: {fileID: 0} 307 | serializedVersion: 5 308 | m_Component: 309 | - component: {fileID: 1574236049} 310 | - component: {fileID: 1574236048} 311 | m_Layer: 0 312 | m_Name: Academy 313 | m_TagString: Untagged 314 | m_Icon: {fileID: 0} 315 | m_NavMeshLayer: 0 316 | m_StaticEditorFlags: 0 317 | m_IsActive: 1 318 | --- !u!114 &1574236048 319 | MonoBehaviour: 320 | m_ObjectHideFlags: 0 321 | m_PrefabParentObject: {fileID: 0} 322 | m_PrefabInternal: {fileID: 0} 323 | m_GameObject: {fileID: 1574236047} 324 | m_Enabled: 1 325 | m_EditorHideFlags: 0 326 | m_Script: {fileID: 11500000, guid: 9af83cd96d4bc4088a966af174446d1b, type: 3} 327 | m_Name: 328 | m_EditorClassIdentifier: 329 | maxSteps: 0 330 | frameToSkip: 0 331 | waitTime: 0 332 | trainingConfiguration: 333 | width: 80 334 | height: 80 335 | qualityLevel: 0 336 | timeScale: 100 337 | targetFrameRate: 60 338 | inferenceConfiguration: 339 | width: 1024 340 | height: 720 341 | qualityLevel: 1 342 | timeScale: 1 343 | targetFrameRate: 60 344 | defaultResetParameters: [] 345 | episodeCount: 0 346 | done: 0 347 | currentStep: 0 348 | isInference: 0 349 | windowResize: 0 350 | --- !u!4 &1574236049 351 | Transform: 352 | m_ObjectHideFlags: 0 353 | m_PrefabParentObject: {fileID: 0} 354 | m_PrefabInternal: {fileID: 0} 355 | m_GameObject: {fileID: 1574236047} 356 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 357 | m_LocalPosition: {x: 0.71938086, y: 0.27357092, z: 4.1970553} 358 | m_LocalScale: {x: 1, y: 1, z: 1} 359 | m_Children: 360 | - {fileID: 846768604} 361 | m_Father: {fileID: 0} 362 | m_RootOrder: 2 363 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 364 | --- !u!1 &1715640920 365 | GameObject: 366 | m_ObjectHideFlags: 0 367 | m_PrefabParentObject: {fileID: 0} 368 | m_PrefabInternal: {fileID: 0} 369 | serializedVersion: 5 370 | m_Component: 371 | - component: {fileID: 1715640925} 372 | - component: {fileID: 1715640924} 373 | - component: {fileID: 1715640923} 374 | - component: {fileID: 1715640922} 375 | - component: {fileID: 1715640921} 376 | m_Layer: 0 377 | m_Name: Main Camera 378 | m_TagString: MainCamera 379 | m_Icon: {fileID: 0} 380 | m_NavMeshLayer: 0 381 | m_StaticEditorFlags: 0 382 | m_IsActive: 1 383 | --- !u!81 &1715640921 384 | AudioListener: 385 | m_ObjectHideFlags: 0 386 | m_PrefabParentObject: {fileID: 0} 387 | m_PrefabInternal: {fileID: 0} 388 | m_GameObject: {fileID: 1715640920} 389 | m_Enabled: 1 390 | --- !u!124 &1715640922 391 | Behaviour: 392 | m_ObjectHideFlags: 0 393 | m_PrefabParentObject: {fileID: 0} 394 | m_PrefabInternal: {fileID: 0} 395 | m_GameObject: {fileID: 1715640920} 396 | m_Enabled: 1 397 | --- !u!92 &1715640923 398 | Behaviour: 399 | m_ObjectHideFlags: 0 400 | m_PrefabParentObject: {fileID: 0} 401 | m_PrefabInternal: {fileID: 0} 402 | m_GameObject: {fileID: 1715640920} 403 | m_Enabled: 1 404 | --- !u!20 &1715640924 405 | Camera: 406 | m_ObjectHideFlags: 0 407 | m_PrefabParentObject: {fileID: 0} 408 | m_PrefabInternal: {fileID: 0} 409 | m_GameObject: {fileID: 1715640920} 410 | m_Enabled: 1 411 | serializedVersion: 2 412 | m_ClearFlags: 1 413 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 414 | m_NormalizedViewPortRect: 415 | serializedVersion: 2 416 | x: 0 417 | y: 0 418 | width: 1 419 | height: 1 420 | near clip plane: 0.3 421 | far clip plane: 1000 422 | field of view: 60 423 | orthographic: 0 424 | orthographic size: 5 425 | m_Depth: -1 426 | m_CullingMask: 427 | serializedVersion: 2 428 | m_Bits: 4294967295 429 | m_RenderingPath: -1 430 | m_TargetTexture: {fileID: 0} 431 | m_TargetDisplay: 0 432 | m_TargetEye: 3 433 | m_HDR: 1 434 | m_AllowMSAA: 1 435 | m_ForceIntoRT: 0 436 | m_OcclusionCulling: 1 437 | m_StereoConvergence: 10 438 | m_StereoSeparation: 0.022 439 | m_StereoMirrorMode: 0 440 | --- !u!4 &1715640925 441 | Transform: 442 | m_ObjectHideFlags: 0 443 | m_PrefabParentObject: {fileID: 0} 444 | m_PrefabInternal: {fileID: 0} 445 | m_GameObject: {fileID: 1715640920} 446 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 447 | m_LocalPosition: {x: 0, y: 1, z: -10} 448 | m_LocalScale: {x: 1, y: 1, z: 1} 449 | m_Children: [] 450 | m_Father: {fileID: 0} 451 | m_RootOrder: 0 452 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 453 | -------------------------------------------------------------------------------- /Assets/ML-Agents/RatML/Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e81622878c805493fb0e3d0e0141e7c6 3 | timeCreated: 1504127824 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a3740bf890474fc9857a8ec39739a35 3 | folderAsset: yes 4 | timeCreated: 1502223516 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Academy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | /*! \mainpage ML-Agents Index Page 6 | * Welcome to Unity Machine Learning Agents documentation. 7 | */ 8 | 9 | 10 | [System.Serializable] 11 | public class ScreenConfiguration 12 | { 13 | public int width; 14 | public int height; 15 | [Range(0, 5)] 16 | public int qualityLevel; 17 | [Range(1f, 100f)] 18 | public float timeScale; 19 | public int targetFrameRate; 20 | 21 | public ScreenConfiguration(int w, int h, int q, float ts, int tf) 22 | { 23 | width = w; 24 | height = h; 25 | qualityLevel = q; 26 | timeScale = ts; 27 | targetFrameRate = tf; 28 | } 29 | } 30 | 31 | 32 | /** Create a child class to implement InitializeAcademy(), AcademyStep() 33 | * and AcademyReset(). The child class script must be attached to an empty game 34 | * object in your scene, and there can only be one such object within the scene. 35 | */ 36 | public abstract class Academy : MonoBehaviour 37 | { 38 | 39 | [System.Serializable] 40 | private struct ResetParameter 41 | { 42 | public string key; 43 | public float value; 44 | } 45 | 46 | 47 | 48 | [SerializeField] 49 | private int maxSteps; 50 | [SerializeField] 51 | private int frameToSkip; 52 | [SerializeField] 53 | private float waitTime; 54 | [HideInInspector] 55 | public bool isInference = true; 56 | /**< \brief Do not modify : If true, the Academy will use inference 57 | * settings. */ 58 | private bool _isCurrentlyInference; 59 | [SerializeField] 60 | private ScreenConfiguration trainingConfiguration = new ScreenConfiguration(80, 80, 1, 100.0f, 60); 61 | [SerializeField] 62 | private ScreenConfiguration inferenceConfiguration = new ScreenConfiguration(1280, 720, 5, 1.0f, 60); 63 | [SerializeField] 64 | private ResetParameter[] defaultResetParameters; 65 | public Dictionary resetParameters; 66 | /**< \brief Contains a mapping from parameter names to float values. */ 67 | /**< You can specify the Default Reset Parameters in the Inspector of the 68 | * Academy. You can modify these parameters when training with an External 69 | * brain by passing a config dictionary at reset. Reference resetParameters 70 | * in your AcademyReset() or AcademyStep() to modify elements in your 71 | * environment at reset time. */ 72 | 73 | 74 | [HideInInspector] 75 | private List brains = new List(); 76 | 77 | 78 | 79 | ExternalCommand externalCommand; 80 | 81 | private bool acceptingSteps; 82 | private int framesSinceAction; 83 | private bool skippingFrames = true; 84 | [HideInInspector] 85 | public bool done; 86 | /**< \brief The done flag of the Academy. */ 87 | /**< When set to true, the Academy will call AcademyReset() instead of 88 | * AcademyStep() at step time. 89 | * If true, all agents done flags will be set to true.*/ 90 | [HideInInspector] 91 | public int episodeCount; 92 | /**< \brief Increments each time the environment is reset. */ 93 | [HideInInspector] 94 | public int currentStep; 95 | /**< \brief Increments each time a step is taken in the environment. Is 96 | * reset to 0 during AcademyReset(). */ 97 | 98 | public Communicator communicator; 99 | /**< \brief Do not modify : pointer to the communicator currently in 100 | * use by the Academy. */ 101 | 102 | private float timeAtStep; 103 | 104 | 105 | void Awake() 106 | { 107 | resetParameters = new Dictionary(); 108 | foreach (ResetParameter kv in defaultResetParameters) 109 | { 110 | resetParameters[kv.key] = kv.value; 111 | } 112 | 113 | GetBrains(gameObject, brains); 114 | InitializeAcademy(); 115 | 116 | communicator = new ExternalCommunicator(this); 117 | if (!communicator.CommunicatorHandShake()) 118 | { 119 | communicator = null; 120 | } 121 | 122 | foreach (Brain brain in brains) 123 | { 124 | brain.InitializeBrain(); 125 | } 126 | if (communicator != null) 127 | { 128 | communicator.InitializeCommunicator(); 129 | externalCommand = communicator.GetCommand(); 130 | } 131 | 132 | isInference = (communicator == null); 133 | _isCurrentlyInference = !isInference; 134 | done = true; 135 | acceptingSteps = true; 136 | } 137 | 138 | /// Environment specific initialization. 139 | /** 140 | * Implemented in environment-specific child class. 141 | * This method is called once when the environment is loaded. 142 | */ 143 | public virtual void InitializeAcademy() 144 | { 145 | 146 | } 147 | 148 | 149 | private void ConfigureEngine() 150 | { 151 | QualitySettings.vSyncCount = 0; 152 | if ((!isInference)) 153 | { 154 | Screen.SetResolution(trainingConfiguration.width, trainingConfiguration.height, false); 155 | QualitySettings.SetQualityLevel(trainingConfiguration.qualityLevel, true); 156 | Time.timeScale = trainingConfiguration.timeScale; 157 | Application.targetFrameRate = trainingConfiguration.targetFrameRate; 158 | } 159 | else 160 | { 161 | Screen.SetResolution(inferenceConfiguration.width, inferenceConfiguration.height, false); 162 | QualitySettings.SetQualityLevel(inferenceConfiguration.qualityLevel, true); 163 | Time.timeScale = inferenceConfiguration.timeScale; 164 | Application.targetFrameRate = inferenceConfiguration.targetFrameRate; 165 | } 166 | } 167 | 168 | /// Environment specific step logic. 169 | /** 170 | * Implemented in environment-specific child class. 171 | * This method is called at every step. 172 | */ 173 | public virtual void AcademyStep() 174 | { 175 | 176 | } 177 | 178 | /// Environment specific reset logic. 179 | /** 180 | * Implemented in environment-specific child class. 181 | * This method is called everytime the Academy resets (when the global done 182 | * flag is set to true). 183 | */ 184 | public virtual void AcademyReset() 185 | { 186 | 187 | } 188 | 189 | 190 | // Called after AcademyStep(). 191 | internal void Step() 192 | { 193 | // Reset all agents whose flags are set to done. 194 | foreach (Brain brain in brains) 195 | { 196 | // Set all agents to done if academy is done. 197 | if (done) 198 | { 199 | brain.SendDone(); 200 | } 201 | brain.ResetIfDone(); 202 | } 203 | 204 | SendState(); 205 | 206 | foreach (Brain brain in brains) 207 | { 208 | brain.ResetDoneAndReward(); 209 | } 210 | } 211 | 212 | // Called before AcademyReset(). 213 | internal void Reset() 214 | { 215 | currentStep = 0; 216 | episodeCount++; 217 | done = false; 218 | AcademyReset(); 219 | 220 | 221 | foreach (Brain brain in brains) 222 | { 223 | brain.Reset(); 224 | brain.ResetDoneAndReward(); 225 | } 226 | 227 | } 228 | 229 | // Instructs all brains to collect states from their agents. 230 | private void SendState() 231 | { 232 | foreach (Brain brain in brains) 233 | { 234 | brain.SendState(); 235 | } 236 | } 237 | 238 | // Instructs all brains to process states to produce actions. 239 | private void DecideAction() 240 | { 241 | if (communicator != null) 242 | { 243 | communicator.UpdateActions(); 244 | } 245 | 246 | foreach (Brain brain in brains) 247 | { 248 | brain.DecideAction(); 249 | } 250 | 251 | framesSinceAction = 0; 252 | } 253 | 254 | void FixedUpdate() 255 | { 256 | if (acceptingSteps) 257 | { 258 | RunMdp(); 259 | } 260 | } 261 | 262 | // Contains logic for taking steps in environment simulation. 263 | /** Based on presence of communicator, inference mode, and frameSkip, 264 | * decides whether the environment should be stepped or reset. 265 | */ 266 | void RunMdp() 267 | { 268 | if (isInference != _isCurrentlyInference) 269 | { 270 | ConfigureEngine(); 271 | _isCurrentlyInference = isInference; 272 | } 273 | 274 | if ((isInference) && (timeAtStep + waitTime > Time.time)) 275 | { 276 | return; 277 | } 278 | 279 | timeAtStep = Time.time; 280 | framesSinceAction += 1; 281 | 282 | currentStep += 1; 283 | if ((currentStep >= maxSteps) && maxSteps > 0) 284 | { 285 | done = true; 286 | } 287 | 288 | if ((framesSinceAction > frameToSkip) || done) 289 | { 290 | skippingFrames = false; 291 | framesSinceAction = 0; 292 | } 293 | else 294 | { 295 | skippingFrames = true; 296 | } 297 | 298 | 299 | if (skippingFrames == false) 300 | { 301 | 302 | if (communicator != null) 303 | { 304 | if (externalCommand == ExternalCommand.STEP) 305 | { 306 | Step(); 307 | externalCommand = communicator.GetCommand(); 308 | } 309 | if (externalCommand == ExternalCommand.RESET) 310 | { 311 | Dictionary NewResetParameters = communicator.GetResetParameters(); 312 | foreach (KeyValuePair kv in NewResetParameters) 313 | { 314 | resetParameters[kv.Key] = kv.Value; 315 | } 316 | Reset(); 317 | externalCommand = ExternalCommand.STEP; 318 | RunMdp(); 319 | return; 320 | } 321 | if (externalCommand == ExternalCommand.QUIT) 322 | { 323 | Application.Quit(); 324 | return; 325 | } 326 | } 327 | else 328 | { 329 | if (done) 330 | { 331 | Reset(); 332 | RunMdp(); 333 | return; 334 | } 335 | else 336 | { 337 | Step(); 338 | } 339 | } 340 | 341 | DecideAction(); 342 | 343 | } 344 | 345 | 346 | AcademyStep(); 347 | 348 | foreach (Brain brain in brains) 349 | { 350 | brain.Step(); 351 | } 352 | 353 | } 354 | 355 | private static void GetBrains(GameObject gameObject, List brains) 356 | { 357 | var transform = gameObject.transform; 358 | 359 | for (var i = 0; i < transform.childCount; i++) 360 | { 361 | var child = transform.GetChild(i); 362 | var brain = child.GetComponent(); 363 | 364 | if (brain != null) 365 | brains.Add(brain); 366 | } 367 | } 368 | } -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Academy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1fc0029fee784d9cb9854f8912bfd07 3 | timeCreated: 1503613254 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Agent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | /** Generic functions for parent Agent class. 7 | * Contains all logic for Brain-Agent communication and Agent-Environment 8 | * interaction. 9 | */ 10 | public abstract class Agent : MonoBehaviour 11 | { 12 | public Brain brain; 13 | /**< \brief The brain that will control this agent. */ 14 | /**< Use the inspector to drag the desired brain gameObject into 15 | * the Brain field */ 16 | 17 | public List observations; 18 | /**< \brief The list of the cameras the Agent uses as observations. */ 19 | /**< These cameras will be used to generate the observations */ 20 | 21 | public int maxStep; 22 | /**< \brief The number of steps the agent takes before being done. */ 23 | /**< If set to 0, the agent can only be set to done via a script. 24 | * If set to any positive integer, the agent will be set to done after that 25 | * many steps each episode. */ 26 | 27 | public bool resetOnDone = true; 28 | /**< \brief Determines the behaviour of the Agent when done.*/ 29 | /**< If true, the agent will reset when done. 30 | * If not, the agent will remain done, and no longer take actions.*/ 31 | 32 | [HideInInspector] 33 | public float reward; 34 | /**< \brief Describes the reward for the given step of the agent.*/ 35 | /**< It is reset to 0 at the beginning of every step. 36 | * Modify in AgentStep(). 37 | * Should be set to positive to reinforcement desired behavior, and 38 | * set to a negative value to punish undesireable behavior. 39 | * Additionally, the magnitude of the reward should not exceed 1.0 */ 40 | 41 | [HideInInspector] 42 | public bool done; 43 | /**< \brief Whether or not the agent is done*/ 44 | /**< Set to true when the agent has acted in some way which ends the 45 | * episode for the given agent. */ 46 | 47 | [HideInInspector] 48 | public float value; 49 | /**< \brief The current value estimate of the agent */ 50 | /**< When using an External brain, you can pass value estimates to the 51 | * agent at every step using env.Step(actions, values). 52 | * If AgentMonitor is attached to the Agent, this value will be displayed.*/ 53 | 54 | [HideInInspector] 55 | public float CumulativeReward; 56 | /**< \brief Do not modify: This keeps track of the cumulative reward.*/ 57 | 58 | [HideInInspector] 59 | public int stepCounter; 60 | /**< \brief Do not modify: This keeps track of the number of steps taken by 61 | * the agent each episode.*/ 62 | 63 | [HideInInspector] 64 | public float[] agentStoredAction; 65 | /**< \brief Do not modify: This keeps track of the last actions decided by 66 | * the brain.*/ 67 | 68 | [HideInInspector] 69 | public float[] memory; 70 | /**< \brief Do not modify directly: This is used by the brain to store 71 | * information about the previous states of the agent*/ 72 | 73 | [HideInInspector] 74 | public int id; 75 | /**< \brief Do not modify : This is the unique Identifier each agent 76 | * receives at initialization. It is used by the brain to identify 77 | * the agent.*/ 78 | 79 | void OnEnable() 80 | { 81 | id = gameObject.GetInstanceID(); 82 | if (brain != null) 83 | { 84 | brain.agents.Add(id, gameObject.GetComponent()); 85 | if (brain.brainParameters.actionSpaceType == StateType.continuous) 86 | { 87 | agentStoredAction = new float[brain.brainParameters.actionSize]; 88 | } 89 | else 90 | { 91 | agentStoredAction = new float[1]; 92 | } 93 | memory = new float[brain.brainParameters.memorySize]; 94 | } 95 | InitializeAgent(); 96 | } 97 | 98 | void OnDisable() 99 | { 100 | //Remove the agent from the list of agents of the brain 101 | brain.agents.Remove(id); 102 | } 103 | 104 | /// When GiveBrain is called, the agent unsubscribes from its 105 | /// previous brain and subscribes to the one passed in argument. 106 | /** Use this method to provide a brain to the agent via script. 107 | * Do not modify brain directly. 108 | @param b The Brain component the agent will subscribe to.*/ 109 | public void GiveBrain(Brain b) 110 | { 111 | RemoveBrain(); 112 | brain = b; 113 | brain.agents.Add(id, gameObject.GetComponent()); 114 | if (brain.brainParameters.actionSpaceType == StateType.continuous) 115 | { 116 | agentStoredAction = new float[brain.brainParameters.actionSize]; 117 | } 118 | else 119 | { 120 | agentStoredAction = new float[1]; 121 | } 122 | memory = new float[brain.brainParameters.memorySize]; 123 | } 124 | 125 | /// When RemoveBrain is called, the agent unsubscribes from its brain. 126 | /** Use this method to give a brain to an agent via script. 127 | * Do not modify brain directly. 128 | * If an agent does not have a brain, it will not update its actions.*/ 129 | public void RemoveBrain() 130 | { 131 | if (brain != null) 132 | { 133 | brain.agents.Remove(id); 134 | } 135 | } 136 | 137 | /// Initialize the agent with this method 138 | /** Must be implemented in agent-specific child class. 139 | * This method called only once when the agent is enabled. 140 | */ 141 | public virtual void InitializeAgent() 142 | { 143 | 144 | } 145 | 146 | /// Collect the states of the agent with this method 147 | /** Must be implemented in agent-specific child class. 148 | * This method called at every step and collects the state of the agent. 149 | * The lenght of the output must be the same length as the state size field 150 | * in the brain parameters of the brain the agent subscribes to. 151 | * Note : The order of the elements in the state list is important. 152 | * @returns state A list of floats corresponding to the state of the agent. 153 | */ 154 | public virtual List CollectState() 155 | { 156 | List state = new List(); 157 | return state; 158 | } 159 | 160 | /// Defines agent-specific behavior at every step depending on the action. 161 | /** Must be implemented in agent-specific child class. 162 | * Note: If your state is discrete, you need to convert your 163 | * state into a list of float with length 1. 164 | * @param action The action the agent receives from the brain. 165 | */ 166 | public virtual void AgentStep(float[] action) 167 | { 168 | 169 | } 170 | 171 | 172 | /// Defines agent-specific behaviour when done 173 | /** Must be implemented in agent-specific child class. 174 | * Is called when the Agent is done if ResetOneDone is false. 175 | * The agent will remain done. 176 | * You can use this method to remove the agent from the scene. 177 | */ 178 | public virtual void AgentOnDone() 179 | { 180 | 181 | } 182 | 183 | /// Defines agent-specific reset logic 184 | /** Must be implemented in agent-specific child class. 185 | * Is called when the academy is done. 186 | * Is called when the Agent is done if ResetOneDone is true. 187 | */ 188 | public virtual void AgentReset() 189 | { 190 | 191 | } 192 | 193 | /// Do not modify : Is used by the brain to reset the agent. 194 | public void Reset() 195 | { 196 | memory = new float[brain.brainParameters.memorySize]; 197 | CumulativeReward = 0f; 198 | stepCounter = 0; 199 | AgentReset(); 200 | } 201 | 202 | /// Do not modify : Is used by the brain to collect rewards. 203 | public float CollectReward() 204 | { 205 | return reward; 206 | } 207 | 208 | public void SetCumulativeReward() 209 | { 210 | CumulativeReward += reward; 211 | //Debug.Log(reward); 212 | } 213 | 214 | /// Do not modify : Is used by the brain to collect done. 215 | public bool CollectDone() 216 | { 217 | return done; 218 | } 219 | 220 | /// Do not modify : Is used by the brain give new action to the agent. 221 | public void UpdateAction(float[] a) 222 | { 223 | agentStoredAction = a; 224 | } 225 | 226 | /// Do not modify : Is used by the brain to make the agent perform a step. 227 | public void Step() 228 | { 229 | AgentStep(agentStoredAction); 230 | stepCounter += 1; 231 | if ((stepCounter > maxStep) && (maxStep > 0)) 232 | { 233 | done = true; 234 | } 235 | } 236 | 237 | /// Do not modify : Is used by the brain to reset the Reward. 238 | public void ResetReward() 239 | { 240 | reward = 0; 241 | } 242 | 243 | } 244 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Agent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88b6042bc9a5d4aa58d931eae49442e5 3 | timeCreated: 1501802662 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Brain.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c676a8ddf5a5f4f64b35e9ed5028679d 3 | timeCreated: 1503211687 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Communicator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | /** \brief AcademyParameters is a structure containing basic information about the 6 | * training environment. */ 7 | /** The AcademyParameters will be sent via socket at the start of the Environment. 8 | * This structure does not need to be modified. 9 | */ 10 | public struct AcademyParameters 11 | { 12 | public string AcademyName; 13 | /**< \brief The name of the Academy. If the communicator is External, 14 | * it will be the name of the Academy GameObject */ 15 | public string apiNumber; 16 | /**< \brief The API number for the communicator. */ 17 | public Dictionary resetParameters; 18 | /**< \brief The default reset parameters are sent via socket*/ 19 | public List brainNames; 20 | /**< \brief A list of the all the brains names sent via socket*/ 21 | public List brainParameters; 22 | /**< \brief A list of the External brains parameters sent via socket*/ 23 | public List externalBrainNames; 24 | /**< \brief A list of the External brains names sent via socket*/ 25 | } 26 | 27 | public enum ExternalCommand 28 | { 29 | STEP, 30 | RESET, 31 | QUIT 32 | } 33 | 34 | /** 35 | * This is the interface used to generate coordinators. 36 | * This does not need to be modified nor implemented to create a 37 | * Unity environment. 38 | */ 39 | public interface Communicator 40 | { 41 | 42 | /// Implement this method to allow brains to subscribe to the 43 | /// decisions made outside of Unity 44 | void SubscribeBrain(Brain brain); 45 | 46 | /// First contact between Communicator and external process 47 | bool CommunicatorHandShake(); 48 | 49 | /// Implement this method to initialize the communicator 50 | void InitializeCommunicator(); 51 | 52 | /// Implement this method to receive actions from outside of Unity and 53 | /// update the actions of the brains that subscribe 54 | void UpdateActions(); 55 | 56 | /// Implement this method to return the ExternalCommand that 57 | /// was given outside of Unity 58 | ExternalCommand GetCommand(); 59 | 60 | /// Implement this method to return the new dictionary of resetParameters 61 | /// that was given outside of Unity 62 | Dictionary GetResetParameters(); 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Communicator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18600657fd7d241a199e6caf2ba7cceb 3 | timeCreated: 1504820023 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrain.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | /** \brief An interface which defines the functions needed for a CoreBrain. */ 6 | /** There is no need to modify or implement CoreBrain to create a Unity environment. 7 | */ 8 | public interface CoreBrain 9 | { 10 | 11 | /// Implement setBrain so let the coreBrain know what brain is using it 12 | void SetBrain(Brain b); 13 | /// Implement this method to initialize CoreBrain 14 | void InitializeCoreBrain(); 15 | /// Implement this method to define the logic for deciding actions 16 | void DecideAction(); 17 | /// Implement this method to define the logic for sending the actions 18 | void SendState(); 19 | /// Implement this method to define what should be displayed in the brain Inspector 20 | void OnInspector(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrain.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcbf9c1714a8d4b819ce2caa23b2eaf4 3 | timeCreated: 1504070234 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainExternal.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | /// CoreBrain which decides actions via communication with an external system such as Python. 6 | public class CoreBrainExternal : ScriptableObject, CoreBrain 7 | { 8 | 9 | public Brain brain; 10 | /**< Reference to the brain that uses this CoreBrainExternal */ 11 | 12 | ExternalCommunicator coord; 13 | 14 | /// Creates the reference to the brain 15 | public void SetBrain(Brain b) 16 | { 17 | brain = b; 18 | } 19 | 20 | /// Generates the communicator for the Academy if none was present and 21 | /// subscribe to ExternalCommunicator if it was present. 22 | public void InitializeCoreBrain() 23 | { 24 | if (brain.gameObject.transform.parent.gameObject.GetComponent().communicator == null) 25 | { 26 | coord = null; 27 | throw new UnityAgentsException(string.Format("The brain {0} was set to" + 28 | " External mode" + 29 | " but Unity was unable to read the" + 30 | " arguments passed at launch.", brain.gameObject.name)); 31 | } 32 | else if (brain.gameObject.transform.parent.gameObject.GetComponent().communicator is ExternalCommunicator) 33 | { 34 | coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent().communicator; 35 | coord.SubscribeBrain(brain); 36 | } 37 | 38 | } 39 | 40 | /// Uses the communicator to retrieve the actions, memories and values and 41 | /// sends them to the agents 42 | public void DecideAction() 43 | { 44 | if (coord != null) 45 | { 46 | brain.SendActions(coord.GetDecidedAction(brain.gameObject.name)); 47 | brain.SendMemories(coord.GetMemories(brain.gameObject.name)); 48 | brain.SendValues(coord.GetValues(brain.gameObject.name)); 49 | } 50 | } 51 | 52 | /// Uses the communicator to send the states, observations, rewards and 53 | /// dones outside of Unity 54 | public void SendState() 55 | { 56 | if (coord != null) 57 | { 58 | coord.giveBrainInfo(brain); 59 | } 60 | } 61 | 62 | /// Nothing needs to appear in the inspector 63 | public void OnInspector() 64 | { 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainExternal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35813a1be64e144f887d7d5f15b963fa 3 | timeCreated: 1504070319 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainHeuristic.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | /// CoreBrain which decides actions using developer-provided Decision.cs script. 10 | public class CoreBrainHeuristic : ScriptableObject, CoreBrain 11 | { 12 | [SerializeField] 13 | private bool broadcast = true; 14 | 15 | public Brain brain; 16 | /**< Reference to the brain that uses this CoreBrainHeuristic */ 17 | 18 | ExternalCommunicator coord; 19 | 20 | public Decision decision; 21 | /**< Reference to the Decision component used to decide the actions */ 22 | 23 | /// Create the reference to the brain 24 | public void SetBrain(Brain b) 25 | { 26 | brain = b; 27 | } 28 | 29 | /// Create the reference to decision 30 | public void InitializeCoreBrain() 31 | { 32 | decision = brain.gameObject.GetComponent(); 33 | 34 | if ((brain.gameObject.transform.parent.gameObject.GetComponent().communicator == null) 35 | || (!broadcast)) 36 | { 37 | coord = null; 38 | } 39 | else if (brain.gameObject.transform.parent.gameObject.GetComponent().communicator is ExternalCommunicator) 40 | { 41 | coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent().communicator; 42 | coord.SubscribeBrain(brain); 43 | } 44 | } 45 | 46 | /// Uses the Decision Component to decide that action to take 47 | public void DecideAction() 48 | { 49 | if (decision == null) 50 | { 51 | throw new UnityAgentsException("The Brain is set to Heuristic, but no decision script attached to it"); 52 | } 53 | 54 | Dictionary actions = new Dictionary(); 55 | Dictionary new_memories = new Dictionary(); 56 | Dictionary> states = brain.CollectStates(); 57 | Dictionary> observations = brain.CollectObservations(); 58 | Dictionary rewards = brain.CollectRewards(); 59 | Dictionary dones = brain.CollectDones(); 60 | Dictionary old_memories = brain.CollectMemories(); 61 | 62 | foreach (KeyValuePair idAgent in brain.agents) 63 | { 64 | actions.Add(idAgent.Key, decision.Decide( 65 | states[idAgent.Key], 66 | observations[idAgent.Key], 67 | rewards[idAgent.Key], 68 | dones[idAgent.Key], 69 | old_memories[idAgent.Key])); 70 | } 71 | foreach (KeyValuePair idAgent in brain.agents) 72 | { 73 | new_memories.Add(idAgent.Key, decision.MakeMemory( 74 | states[idAgent.Key], 75 | observations[idAgent.Key], 76 | rewards[idAgent.Key], 77 | dones[idAgent.Key], 78 | old_memories[idAgent.Key])); 79 | } 80 | brain.SendActions(actions); 81 | brain.SendMemories(new_memories); 82 | } 83 | 84 | /// Nothing needs to be implemented, the states are collected in DecideAction 85 | public void SendState() 86 | { 87 | if (coord!=null) 88 | { 89 | coord.giveBrainInfo(brain); 90 | } 91 | } 92 | 93 | /// Displays an error if no decision component is attached to the brain 94 | public void OnInspector() 95 | { 96 | #if UNITY_EDITOR 97 | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); 98 | broadcast = EditorGUILayout.Toggle("Broadcast", broadcast); 99 | if (brain.gameObject.GetComponent() == null) 100 | { 101 | EditorGUILayout.HelpBox("You need to add a 'Decision' component to this gameObject", MessageType.Error); 102 | } 103 | #endif 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainHeuristic.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 943466ab374444748a364f9d6c3e2fe2 3 | timeCreated: 1504070366 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainInternal.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | using System.Linq; 10 | 11 | #if ENABLE_TENSORFLOW 12 | using TensorFlow; 13 | #endif 14 | 15 | /// CoreBrain which decides actions using internally embedded TensorFlow model. 16 | public class CoreBrainInternal : ScriptableObject, CoreBrain 17 | { 18 | 19 | [SerializeField] 20 | private bool broadcast = true; 21 | 22 | [System.Serializable] 23 | private struct TensorFlowAgentPlaceholder 24 | { 25 | public enum tensorType 26 | { 27 | Integer, 28 | FloatingPoint} 29 | 30 | ; 31 | 32 | public string name; 33 | public tensorType valueType; 34 | public float minValue; 35 | public float maxValue; 36 | 37 | } 38 | 39 | ExternalCommunicator coord; 40 | 41 | /// Modify only in inspector : Reference to the Graph asset 42 | public TextAsset graphModel; 43 | /// Modify only in inspector : If a scope was used when training the model, specify it here 44 | public string graphScope; 45 | [SerializeField] 46 | /// Modify only in inspector : If your graph takes additional inputs that are fixed you can specify them here. 47 | private TensorFlowAgentPlaceholder[] graphPlaceholders; 48 | /// Modify only in inspector : Name of the placholder of the batch size 49 | public string BatchSizePlaceholderName = "batch_size"; 50 | /// Modify only in inspector : Name of the state placeholder 51 | public string StatePlacholderName = "state"; 52 | /// Modify only in inspector : Name of the recurrent input 53 | public string RecurrentInPlaceholderName = "recurrent_in"; 54 | /// Modify only in inspector : Name of the recurrent output 55 | public string RecurrentOutPlaceholderName = "recurrent_out"; 56 | /// Modify only in inspector : Names of the observations placeholders 57 | public string[] ObservationPlaceholderName; 58 | /// Modify only in inspector : Name of the action node 59 | public string ActionPlaceholderName = "action"; 60 | #if ENABLE_TENSORFLOW 61 | TFGraph graph; 62 | TFSession session; 63 | bool hasRecurrent; 64 | bool hasState; 65 | bool hasBatchSize; 66 | List agentKeys; 67 | int currentBatchSize; 68 | float[,] inputState; 69 | List observationMatrixList; 70 | float[,] inputOldMemories; 71 | #endif 72 | 73 | /// Reference to the brain that uses this CoreBrainInternal 74 | public Brain brain; 75 | 76 | /// Create the reference to the brain 77 | public void SetBrain(Brain b) 78 | { 79 | brain = b; 80 | } 81 | 82 | /// Loads the tensorflow graph model to generate a TFGraph object 83 | public void InitializeCoreBrain() 84 | { 85 | #if ENABLE_TENSORFLOW 86 | #if UNITY_ANDROID 87 | // This needs to ba called only once and will raise an exception if 88 | // there are multiple internal brains 89 | try{ 90 | TensorFlowSharp.Android.NativeBinding.Init(); 91 | } 92 | catch{ 93 | 94 | } 95 | #endif 96 | if ((brain.gameObject.transform.parent.gameObject.GetComponent().communicator == null) 97 | || (!broadcast)) 98 | { 99 | coord = null; 100 | } 101 | else if (brain.gameObject.transform.parent.gameObject.GetComponent().communicator is ExternalCommunicator) 102 | { 103 | coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent().communicator; 104 | coord.SubscribeBrain(brain); 105 | } 106 | 107 | if (graphModel != null) 108 | { 109 | 110 | graph = new TFGraph(); 111 | 112 | graph.Import(graphModel.bytes); 113 | 114 | session = new TFSession(graph); 115 | 116 | if (graph[graphScope + BatchSizePlaceholderName] != null) 117 | { 118 | hasBatchSize = true; 119 | } 120 | if ((graph[graphScope + RecurrentInPlaceholderName] != null) && (graph[graphScope + RecurrentOutPlaceholderName] != null)) 121 | { 122 | hasRecurrent = true; 123 | 124 | } 125 | if (graph[graphScope + StatePlacholderName] != null) 126 | { 127 | hasState = true; 128 | } 129 | } 130 | #endif 131 | } 132 | 133 | 134 | /// Collects information from the agents and store them 135 | public void SendState() 136 | { 137 | #if ENABLE_TENSORFLOW 138 | agentKeys = new List(brain.agents.Keys); 139 | currentBatchSize = brain.agents.Count; 140 | if (currentBatchSize == 0) 141 | { 142 | 143 | if (coord != null) 144 | { 145 | coord.giveBrainInfo(brain); 146 | } 147 | return; 148 | } 149 | 150 | 151 | // Create the state tensor 152 | if (hasState) 153 | { 154 | Dictionary> states = brain.CollectStates(); 155 | inputState = new float[currentBatchSize, brain.brainParameters.stateSize]; 156 | int i = 0; 157 | foreach (int k in agentKeys) 158 | { 159 | List state_list = states[k]; 160 | for (int j = 0; j < brain.brainParameters.stateSize; j++) 161 | { 162 | 163 | inputState[i, j] = state_list[j]; 164 | } 165 | i++; 166 | } 167 | } 168 | 169 | 170 | // Create the observation tensors 171 | observationMatrixList = brain.GetObservationMatrixList(agentKeys); 172 | 173 | // Create the recurrent tensor 174 | if (hasRecurrent) 175 | { 176 | Dictionary old_memories = brain.CollectMemories(); 177 | inputOldMemories = new float[currentBatchSize, brain.brainParameters.memorySize]; 178 | int i = 0; 179 | foreach (int k in agentKeys) 180 | { 181 | float[] m = old_memories[k]; 182 | for (int j = 0; j < brain.brainParameters.memorySize; j++) 183 | { 184 | 185 | inputOldMemories[i, j] = m[j]; 186 | } 187 | i++; 188 | } 189 | } 190 | 191 | 192 | if (coord != null) 193 | { 194 | coord.giveBrainInfo(brain); 195 | } 196 | #endif 197 | } 198 | 199 | 200 | /// Uses the stored information to run the tensorflow graph and generate 201 | /// the actions. 202 | public void DecideAction() 203 | { 204 | #if ENABLE_TENSORFLOW 205 | if (currentBatchSize == 0) 206 | { 207 | return; 208 | } 209 | 210 | var runner = session.GetRunner(); 211 | runner.Fetch(graph[graphScope + ActionPlaceholderName][0]); 212 | 213 | if (hasBatchSize) 214 | { 215 | runner.AddInput(graph[graphScope + BatchSizePlaceholderName][0], new int[] { currentBatchSize }); 216 | } 217 | 218 | foreach (TensorFlowAgentPlaceholder placeholder in graphPlaceholders) 219 | { 220 | try 221 | { 222 | if (placeholder.valueType == TensorFlowAgentPlaceholder.tensorType.FloatingPoint) 223 | { 224 | runner.AddInput(graph[graphScope + placeholder.name][0], new float[] { Random.Range(placeholder.minValue, placeholder.maxValue) }); 225 | } 226 | else if (placeholder.valueType == TensorFlowAgentPlaceholder.tensorType.Integer) 227 | { 228 | runner.AddInput(graph[graphScope + placeholder.name][0], new int[] { Random.Range((int)placeholder.minValue, (int)placeholder.maxValue + 1) }); 229 | } 230 | } 231 | catch 232 | { 233 | throw new UnityAgentsException(string.Format(@"One of the Tensorflow placeholder cound nout be found. 234 | In brain {0}, there are no {1} placeholder named {2}.", 235 | brain.gameObject.name, placeholder.valueType.ToString(), graphScope + placeholder.name)); 236 | } 237 | } 238 | 239 | // Create the state tensor 240 | if (hasState) 241 | { 242 | if (brain.brainParameters.stateSpaceType == StateType.discrete) 243 | { 244 | int[,] discreteInputState = new int[currentBatchSize, 1]; 245 | for (int i = 0; i < currentBatchSize; i++) 246 | { 247 | discreteInputState[i, 0] = (int)inputState[i, 0]; 248 | } 249 | runner.AddInput(graph[graphScope + StatePlacholderName][0], discreteInputState); 250 | } 251 | else 252 | { 253 | runner.AddInput(graph[graphScope + StatePlacholderName][0], inputState); 254 | } 255 | } 256 | 257 | // Create the observation tensors 258 | for (int obs_number = 0; obs_number < brain.brainParameters.cameraResolutions.Length; obs_number++) 259 | { 260 | runner.AddInput(graph[graphScope + ObservationPlaceholderName[obs_number]][0], observationMatrixList[obs_number]); 261 | } 262 | 263 | if (hasRecurrent) 264 | { 265 | runner.AddInput(graph[graphScope + RecurrentInPlaceholderName][0], inputOldMemories); 266 | runner.Fetch(graph[graphScope + RecurrentOutPlaceholderName][0]); 267 | } 268 | 269 | TFTensor[] networkOutput; 270 | try 271 | { 272 | networkOutput = runner.Run(); 273 | } 274 | catch (TFException e) 275 | { 276 | string errorMessage = e.Message; 277 | try 278 | { 279 | errorMessage = string.Format(@"The tensorflow graph needs an input for {0} of type {1}", 280 | e.Message.Split(new string[]{ "Node: " }, 0)[1].Split('=')[0], 281 | e.Message.Split(new string[]{ "dtype=" }, 0)[1].Split(',')[0]); 282 | } 283 | finally 284 | { 285 | throw new UnityAgentsException(errorMessage); 286 | } 287 | 288 | } 289 | 290 | // Create the recurrent tensor 291 | if (hasRecurrent) 292 | { 293 | Dictionary new_memories = new Dictionary(); 294 | 295 | float[,] recurrent_tensor = networkOutput[1].GetValue() as float[,]; 296 | 297 | int i = 0; 298 | foreach (int k in agentKeys) 299 | { 300 | float[] m = new float[brain.brainParameters.memorySize]; 301 | for (int j = 0; j < brain.brainParameters.memorySize; j++) 302 | { 303 | m[j] = recurrent_tensor[i, j]; 304 | } 305 | new_memories.Add(k, m); 306 | i++; 307 | } 308 | 309 | brain.SendMemories(new_memories); 310 | } 311 | 312 | Dictionary actions = new Dictionary(); 313 | 314 | if (brain.brainParameters.actionSpaceType == StateType.continuous) 315 | { 316 | float[,] output = networkOutput[0].GetValue() as float[,]; 317 | int i = 0; 318 | foreach (int k in agentKeys) 319 | { 320 | float[] a = new float[brain.brainParameters.actionSize]; 321 | for (int j = 0; j < brain.brainParameters.actionSize; j++) 322 | { 323 | a[j] = output[i, j]; 324 | } 325 | actions.Add(k, a); 326 | i++; 327 | } 328 | } 329 | else if (brain.brainParameters.actionSpaceType == StateType.discrete) 330 | { 331 | long[,] output = networkOutput[0].GetValue() as long[,]; 332 | int i = 0; 333 | foreach (int k in agentKeys) 334 | { 335 | float[] a = new float[1] { (float)(output[i, 0]) }; 336 | actions.Add(k, a); 337 | i++; 338 | } 339 | } 340 | 341 | brain.SendActions(actions); 342 | 343 | #endif 344 | } 345 | 346 | /// Displays the parameters of the CoreBrainInternal in the Inspector 347 | public void OnInspector() 348 | { 349 | #if ENABLE_TENSORFLOW && UNITY_EDITOR 350 | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); 351 | broadcast = EditorGUILayout.Toggle("Broadcast", broadcast); 352 | SerializedObject serializedBrain = new SerializedObject(this); 353 | GUILayout.Label("Edit the Tensorflow graph parameters here"); 354 | SerializedProperty tfGraphModel = serializedBrain.FindProperty("graphModel"); 355 | serializedBrain.Update(); 356 | EditorGUILayout.ObjectField(tfGraphModel); 357 | serializedBrain.ApplyModifiedProperties(); 358 | 359 | if (graphModel == null) 360 | { 361 | EditorGUILayout.HelpBox("Please provide a tensorflow graph as a bytes file.", MessageType.Error); 362 | } 363 | 364 | 365 | graphScope = EditorGUILayout.TextField("Graph Scope : ", graphScope); 366 | 367 | if (BatchSizePlaceholderName == "") 368 | { 369 | BatchSizePlaceholderName = "batch_size"; 370 | } 371 | BatchSizePlaceholderName = EditorGUILayout.TextField("Batch Size Node Name", BatchSizePlaceholderName); 372 | if (StatePlacholderName == "") 373 | { 374 | StatePlacholderName = "state"; 375 | } 376 | StatePlacholderName = EditorGUILayout.TextField("State Node Name", StatePlacholderName); 377 | if (RecurrentInPlaceholderName == "") 378 | { 379 | RecurrentInPlaceholderName = "recurrent_in"; 380 | } 381 | RecurrentInPlaceholderName = EditorGUILayout.TextField("Recurrent Input Node Name", RecurrentInPlaceholderName); 382 | if (RecurrentOutPlaceholderName == "") 383 | { 384 | RecurrentOutPlaceholderName = "recurrent_out"; 385 | } 386 | RecurrentOutPlaceholderName = EditorGUILayout.TextField("Recurrent Output Node Name", RecurrentOutPlaceholderName); 387 | 388 | if (brain.brainParameters.cameraResolutions != null) 389 | { 390 | if (brain.brainParameters.cameraResolutions.Count() > 0) 391 | { 392 | if (ObservationPlaceholderName == null) 393 | { 394 | ObservationPlaceholderName = new string[brain.brainParameters.cameraResolutions.Count()]; 395 | } 396 | if (ObservationPlaceholderName.Count() != brain.brainParameters.cameraResolutions.Count()) 397 | { 398 | ObservationPlaceholderName = new string[brain.brainParameters.cameraResolutions.Count()]; 399 | } 400 | for (int obs_number = 0; obs_number < brain.brainParameters.cameraResolutions.Count(); obs_number++) 401 | { 402 | if ((ObservationPlaceholderName[obs_number] == "") || (ObservationPlaceholderName[obs_number] == null)) 403 | { 404 | 405 | ObservationPlaceholderName[obs_number] = "observation_" + obs_number; 406 | } 407 | } 408 | SerializedProperty opn = serializedBrain.FindProperty("ObservationPlaceholderName"); 409 | serializedBrain.Update(); 410 | EditorGUILayout.PropertyField(opn, true); 411 | serializedBrain.ApplyModifiedProperties(); 412 | } 413 | } 414 | 415 | if (ActionPlaceholderName == "") 416 | { 417 | ActionPlaceholderName = "action"; 418 | } 419 | ActionPlaceholderName = EditorGUILayout.TextField("Action Node Name", ActionPlaceholderName); 420 | 421 | 422 | 423 | SerializedProperty tfPlaceholders = serializedBrain.FindProperty("graphPlaceholders"); 424 | serializedBrain.Update(); 425 | EditorGUILayout.PropertyField(tfPlaceholders, true); 426 | serializedBrain.ApplyModifiedProperties(); 427 | #endif 428 | } 429 | 430 | } 431 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainInternal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b23992c8eb17439887f5e944bf04a40 3 | timeCreated: 1504070347 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainPlayer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | #if UNITY_EDITOR 6 | using UnityEditor; 7 | #endif 8 | 9 | 10 | /// CoreBrain which decides actions using Player input. 11 | public class CoreBrainPlayer : ScriptableObject, CoreBrain 12 | { 13 | [SerializeField] 14 | private bool broadcast = true; 15 | 16 | [System.Serializable] 17 | private struct DiscretePlayerAction 18 | { 19 | public KeyCode key; 20 | public int value; 21 | } 22 | 23 | [System.Serializable] 24 | private struct ContinuousPlayerAction 25 | { 26 | public KeyCode key; 27 | public int index; 28 | public float value; 29 | } 30 | 31 | ExternalCommunicator coord; 32 | 33 | [SerializeField] 34 | /// Contains the mapping from input to continuous actions 35 | private ContinuousPlayerAction[] continuousPlayerActions; 36 | [SerializeField] 37 | /// Contains the mapping from input to discrete actions 38 | private DiscretePlayerAction[] discretePlayerActions; 39 | [SerializeField] 40 | private int defaultAction = 0; 41 | 42 | /// Reference to the brain that uses this CoreBrainPlayer 43 | public Brain brain; 44 | 45 | /// Create the reference to the brain 46 | public void SetBrain(Brain b) 47 | { 48 | brain = b; 49 | } 50 | 51 | /// Nothing to implement 52 | public void InitializeCoreBrain() 53 | { 54 | if ((brain.gameObject.transform.parent.gameObject.GetComponent().communicator == null) 55 | || (!broadcast)) 56 | { 57 | coord = null; 58 | } 59 | else if (brain.gameObject.transform.parent.gameObject.GetComponent().communicator is ExternalCommunicator) 60 | { 61 | coord = (ExternalCommunicator)brain.gameObject.transform.parent.gameObject.GetComponent().communicator; 62 | coord.SubscribeBrain(brain); 63 | } 64 | } 65 | 66 | /// Uses the continuous inputs or dicrete inputs of the player to 67 | /// decide action 68 | public void DecideAction() 69 | { 70 | if (brain.brainParameters.actionSpaceType == StateType.continuous) 71 | { 72 | float[] action = new float[brain.brainParameters.actionSize]; 73 | foreach (ContinuousPlayerAction cha in continuousPlayerActions) 74 | { 75 | if (Input.GetKey(cha.key)) 76 | { 77 | action[cha.index] = cha.value; 78 | } 79 | } 80 | Dictionary actions = new Dictionary(); 81 | foreach (KeyValuePair idAgent in brain.agents) 82 | { 83 | actions.Add(idAgent.Key, action); 84 | } 85 | brain.SendActions(actions); 86 | } 87 | else 88 | { 89 | float[] action = new float[1] { defaultAction }; 90 | foreach (DiscretePlayerAction dha in discretePlayerActions) 91 | { 92 | if (Input.GetKey(dha.key)) 93 | { 94 | action[0] = (float)dha.value; 95 | break; 96 | } 97 | } 98 | Dictionary actions = new Dictionary(); 99 | foreach (KeyValuePair idAgent in brain.agents) 100 | { 101 | actions.Add(idAgent.Key, action); 102 | } 103 | brain.SendActions(actions); 104 | } 105 | } 106 | 107 | /// Nothing to implement, the Player does not use the state to make 108 | /// decisions 109 | public void SendState() 110 | { 111 | if (coord != null) 112 | { 113 | coord.giveBrainInfo(brain); 114 | } 115 | else 116 | { 117 | //The states are collected in order to debug the CollectStates method. 118 | brain.CollectStates(); 119 | } 120 | } 121 | 122 | /// Displays continuous or discrete input mapping in the inspector 123 | public void OnInspector() 124 | { 125 | #if UNITY_EDITOR 126 | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); 127 | broadcast = EditorGUILayout.Toggle("Broadcast", broadcast); 128 | SerializedObject serializedBrain = new SerializedObject(this); 129 | if (brain.brainParameters.actionSpaceType == StateType.continuous) 130 | { 131 | GUILayout.Label("Edit the continuous inputs for you actions", EditorStyles.boldLabel); 132 | SerializedProperty chas = serializedBrain.FindProperty("continuousPlayerActions"); 133 | serializedBrain.Update(); 134 | EditorGUILayout.PropertyField(chas, true); 135 | serializedBrain.ApplyModifiedProperties(); 136 | if (continuousPlayerActions == null) 137 | { 138 | continuousPlayerActions = new ContinuousPlayerAction[0]; 139 | } 140 | foreach (ContinuousPlayerAction cha in continuousPlayerActions) 141 | { 142 | if (cha.index >= brain.brainParameters.actionSize) 143 | { 144 | EditorGUILayout.HelpBox(string.Format("Key {0} is assigned to index {1} but the action size is only of size {2}" 145 | , cha.key.ToString(), cha.index.ToString(), brain.brainParameters.actionSize.ToString()), MessageType.Error); 146 | } 147 | } 148 | 149 | } 150 | else 151 | { 152 | GUILayout.Label("Edit the discrete inputs for you actions", EditorStyles.boldLabel); 153 | defaultAction = EditorGUILayout.IntField("Default Action", defaultAction); 154 | SerializedProperty dhas = serializedBrain.FindProperty("discretePlayerActions"); 155 | serializedBrain.Update(); 156 | EditorGUILayout.PropertyField(dhas, true); 157 | serializedBrain.ApplyModifiedProperties(); 158 | } 159 | #endif 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/CoreBrainPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41e9bda8f3cf1492fa74926a530f6f70 3 | timeCreated: 1504070375 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Decision.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | /// Generic functions for Decision Interface 6 | public interface Decision 7 | { 8 | /// \brief Implement this method to define the logic of decision making 9 | /// for the CoreBrainHeuristic 10 | /** Given the information about the agent, return a vector of actions. 11 | * @param state The state of the agent 12 | * @param observation The cameras the agent uses 13 | * @param reward The reward the agent had at the previous step 14 | * @param done Weather or not the agent is done 15 | * @param memory The memories stored from the previous step with MakeMemory() 16 | * @return The vector of actions the agent will take at the next step 17 | */ 18 | float[] Decide(List state, List observation, float reward, bool done, float[] memory); 19 | 20 | /// \brief Implement this method to define the logic of memory making for 21 | /// the CoreBrainHeuristic 22 | /** Given the information about the agent, return the new memory vector for the agent. 23 | * @param state The state of the agent 24 | * @param observation The cameras the agent uses 25 | * @param reward The reward the agent had at the previous step 26 | * @param done Weather or not the agent is done 27 | * @param memory The memories stored from the previous step with MakeMemory() 28 | * @return The vector of memories the agent will use at the next step 29 | */ 30 | float[] MakeMemory(List state, List observation, float reward, bool done, float[] memory); 31 | } -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Decision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13e74744309fd4571b76e46fafc6d37f 3 | timeCreated: 1503182472 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/ExternalCommunicator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using Newtonsoft.Json; 6 | using System.Linq; 7 | using System.Net.Sockets; 8 | using System.Text; 9 | 10 | 11 | /// Responsible for communication with Python API. 12 | public class ExternalCommunicator : Communicator 13 | { 14 | 15 | Academy academy; 16 | 17 | Dictionary> current_agents; 18 | 19 | List brains; 20 | 21 | Dictionary hasSentState; 22 | 23 | Dictionary> storedActions; 24 | Dictionary> storedMemories; 25 | Dictionary> storedValues; 26 | 27 | private int comPort; 28 | Socket sender; 29 | byte[] messageHolder; 30 | 31 | const int messageLength = 12000; 32 | 33 | const string api = "API-2"; 34 | 35 | private class StepMessage 36 | { 37 | public string brain_name { get; set; } 38 | 39 | public List agents { get; set; } 40 | 41 | public List states { get; set; } 42 | 43 | public List rewards { get; set; } 44 | 45 | public List actions { get; set; } 46 | 47 | public List memories { get; set; } 48 | 49 | public List dones { get; set; } 50 | } 51 | 52 | private class AgentMessage 53 | { 54 | public Dictionary> action { get; set; } 55 | 56 | public Dictionary> memory { get; set; } 57 | 58 | public Dictionary> value { get; set; } 59 | 60 | } 61 | 62 | private class ResetParametersMessage 63 | { 64 | public Dictionary parameters { get; set; } 65 | 66 | public bool train_model { get; set; } 67 | } 68 | 69 | /// Consrtuctor for the External Communicator 70 | public ExternalCommunicator(Academy aca) 71 | { 72 | academy = aca; 73 | brains = new List(); 74 | current_agents = new Dictionary>(); 75 | 76 | hasSentState = new Dictionary(); 77 | 78 | storedActions = new Dictionary>(); 79 | storedMemories = new Dictionary>(); 80 | storedValues = new Dictionary>(); 81 | } 82 | 83 | /// Adds the brain to the list of brains which have already decided their 84 | /// actions. 85 | public void SubscribeBrain(Brain brain) 86 | { 87 | brains.Add(brain); 88 | hasSentState[brain.gameObject.name] = false; 89 | } 90 | 91 | 92 | public bool CommunicatorHandShake(){ 93 | try 94 | { 95 | ReadArgs(); 96 | } 97 | catch 98 | { 99 | return false; 100 | } 101 | return true; 102 | } 103 | 104 | /// Contains the logic for the initializtation of the socket. 105 | public void InitializeCommunicator() 106 | { 107 | messageHolder = new byte[messageLength]; 108 | 109 | // Create a TCP/IP socket. 110 | sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 111 | sender.Connect("localhost", comPort); 112 | 113 | AcademyParameters accParamerters = new AcademyParameters(); 114 | accParamerters.brainParameters = new List(); 115 | accParamerters.brainNames = new List(); 116 | accParamerters.externalBrainNames = new List(); 117 | accParamerters.apiNumber = api; 118 | foreach (Brain b in brains) 119 | { 120 | accParamerters.brainParameters.Add(b.brainParameters); 121 | accParamerters.brainNames.Add(b.gameObject.name); 122 | if (b.brainType == BrainType.External) 123 | { 124 | accParamerters.externalBrainNames.Add(b.gameObject.name); 125 | } 126 | } 127 | accParamerters.AcademyName = academy.gameObject.name; 128 | accParamerters.resetParameters = academy.resetParameters; 129 | 130 | SendParameters(accParamerters); 131 | } 132 | 133 | /// Listens to the socket for a command and returns the corresponding 134 | /// External Command. 135 | public ExternalCommand GetCommand() 136 | { 137 | int location = sender.Receive(messageHolder); 138 | string message = Encoding.ASCII.GetString(messageHolder, 0, location); 139 | switch (message) 140 | { 141 | case "STEP": 142 | return ExternalCommand.STEP; 143 | case "RESET": 144 | return ExternalCommand.RESET; 145 | case "QUIT": 146 | return ExternalCommand.QUIT; 147 | default: 148 | return ExternalCommand.QUIT; 149 | } 150 | } 151 | 152 | /// Listens to the socket for the new resetParameters 153 | public Dictionary GetResetParameters() 154 | { 155 | sender.Send(Encoding.ASCII.GetBytes("CONFIG_REQUEST")); 156 | ResetParametersMessage resetParams = JsonConvert.DeserializeObject(Receive()); 157 | academy.isInference = !resetParams.train_model; 158 | return resetParams.parameters; 159 | } 160 | 161 | 162 | /// Used to read Python-provided environment parameters 163 | private void ReadArgs() 164 | { 165 | string[] args = System.Environment.GetCommandLineArgs(); 166 | string inputPort = ""; 167 | for (int i = 0; i < args.Length; i++) 168 | { 169 | if (args[i] == "--port") 170 | { 171 | inputPort = args[i + 1]; 172 | } 173 | } 174 | 175 | comPort = int.Parse(inputPort); 176 | } 177 | 178 | /// Sends Academy parameters to external agent 179 | private void SendParameters(AcademyParameters envParams) 180 | { 181 | string envMessage = JsonConvert.SerializeObject(envParams, Formatting.Indented); 182 | sender.Send(Encoding.ASCII.GetBytes(envMessage)); 183 | } 184 | 185 | /// Receives messages from external agent 186 | private string Receive() 187 | { 188 | int location = sender.Receive(messageHolder); 189 | string message = Encoding.ASCII.GetString(messageHolder, 0, location); 190 | return message; 191 | } 192 | 193 | 194 | /// Ends connection and closes environment 195 | private void OnApplicationQuit() 196 | { 197 | sender.Close(); 198 | sender.Shutdown(SocketShutdown.Both); 199 | } 200 | 201 | /// Contains logic for coverting texture into bytearray to send to 202 | /// external agent. 203 | private byte[] TexToByteArray(Texture2D tex) 204 | { 205 | byte[] bytes = tex.EncodeToPNG(); 206 | Object.DestroyImmediate(tex); 207 | Resources.UnloadUnusedAssets(); 208 | return bytes; 209 | } 210 | 211 | private byte[] AppendLength(byte[] input){ 212 | byte[] newArray = new byte[input.Length + 4]; 213 | input.CopyTo(newArray, 4); 214 | System.BitConverter.GetBytes(input.Length).CopyTo(newArray, 0); 215 | return newArray; 216 | } 217 | 218 | /// Collects the information from the brains and sends it accross the socket 219 | public void giveBrainInfo(Brain brain) 220 | { 221 | string brainName = brain.gameObject.name; 222 | current_agents[brainName] = new List(brain.agents.Keys); 223 | List concatenatedStates = new List(); 224 | List concatenatedRewards = new List(); 225 | List concatenatedMemories = new List(); 226 | List concatenatedDones = new List(); 227 | List concatenatedActions = new List(); 228 | Dictionary> collectedObservations = brain.CollectObservations(); 229 | Dictionary> collectedStates = brain.CollectStates(); 230 | Dictionary collectedRewards = brain.CollectRewards(); 231 | Dictionary collectedMemories = brain.CollectMemories(); 232 | Dictionary collectedDones = brain.CollectDones(); 233 | Dictionary collectedActions = brain.CollectActions(); 234 | 235 | foreach (int id in current_agents[brainName]) 236 | { 237 | concatenatedStates = concatenatedStates.Concat(collectedStates[id]).ToList(); 238 | concatenatedRewards.Add(collectedRewards[id]); 239 | concatenatedMemories = concatenatedMemories.Concat(collectedMemories[id].ToList()).ToList(); 240 | concatenatedDones.Add(collectedDones[id]); 241 | concatenatedActions = concatenatedActions.Concat(collectedActions[id].ToList()).ToList(); 242 | } 243 | StepMessage message = new StepMessage() 244 | { 245 | brain_name = brainName, 246 | agents = current_agents[brainName], 247 | states = concatenatedStates, 248 | rewards = concatenatedRewards, 249 | actions = concatenatedActions, 250 | memories = concatenatedMemories, 251 | dones = concatenatedDones 252 | }; 253 | string envMessage = JsonConvert.SerializeObject(message, Formatting.Indented); 254 | sender.Send(AppendLength(Encoding.ASCII.GetBytes(envMessage))); 255 | Receive(); 256 | int i = 0; 257 | foreach (resolution res in brain.brainParameters.cameraResolutions) 258 | { 259 | foreach (int id in current_agents[brainName]) 260 | { 261 | sender.Send(AppendLength(TexToByteArray(brain.ObservationToTex(collectedObservations[id][i], res.width, res.height)))); 262 | Receive(); 263 | } 264 | i++; 265 | } 266 | 267 | hasSentState[brainName] = true; 268 | 269 | if (hasSentState.Values.All(x => x)) 270 | { 271 | // if all the brains listed have sent their state 272 | sender.Send(Encoding.ASCII.GetBytes((academy.done ? "True" : "False"))); 273 | List brainNames = hasSentState.Keys.ToList(); 274 | foreach (string k in brainNames) 275 | { 276 | hasSentState[k] = false; 277 | } 278 | } 279 | 280 | } 281 | 282 | /// Listens for actions, memories, and values and sends them 283 | /// to the corrensponding brains. 284 | public void UpdateActions() 285 | { 286 | // TO MODIFY -------------------------------------------- 287 | sender.Send(Encoding.ASCII.GetBytes("STEPPING")); 288 | string a = Receive(); 289 | AgentMessage agentMessage = JsonConvert.DeserializeObject(a); 290 | 291 | foreach (Brain brain in brains) 292 | { 293 | if (brain.brainType == BrainType.External) 294 | { 295 | string brainName = brain.gameObject.name; 296 | 297 | Dictionary actionDict = new Dictionary(); 298 | for (int i = 0; i < current_agents[brainName].Count; i++) 299 | { 300 | if (brain.brainParameters.actionSpaceType == StateType.continuous) 301 | { 302 | actionDict.Add(current_agents[brainName][i], 303 | agentMessage.action[brainName].GetRange(i * brain.brainParameters.actionSize, brain.brainParameters.actionSize).ToArray()); 304 | } 305 | else 306 | { 307 | actionDict.Add(current_agents[brainName][i], 308 | agentMessage.action[brainName].GetRange(i, 1).ToArray()); 309 | } 310 | } 311 | storedActions[brainName] = actionDict; 312 | 313 | Dictionary memoryDict = new Dictionary(); 314 | for (int i = 0; i < current_agents[brainName].Count; i++) 315 | { 316 | memoryDict.Add(current_agents[brainName][i], 317 | agentMessage.memory[brainName].GetRange(i * brain.brainParameters.memorySize, brain.brainParameters.memorySize).ToArray()); 318 | } 319 | storedMemories[brainName] = memoryDict; 320 | 321 | Dictionary valueDict = new Dictionary(); 322 | for (int i = 0; i < current_agents[brainName].Count; i++) 323 | { 324 | valueDict.Add(current_agents[brainName][i], 325 | agentMessage.value[brainName][i]); 326 | } 327 | storedValues[brainName] = valueDict; 328 | } 329 | 330 | } 331 | } 332 | 333 | /// Returns the actions corrensponding to the brain called brainName that 334 | /// were received throught the socket. 335 | public Dictionary GetDecidedAction(string brainName) 336 | { 337 | return storedActions[brainName]; 338 | } 339 | 340 | /// Returns the memories corrensponding to the brain called brainName that 341 | /// were received throught the socket. 342 | public Dictionary GetMemories(string brainName) 343 | { 344 | return storedMemories[brainName]; 345 | } 346 | 347 | /// Returns the values corrensponding to the brain called brainName that 348 | /// were received throught the socket. 349 | public Dictionary GetValues(string brainName) 350 | { 351 | return storedValues[brainName]; 352 | } 353 | 354 | } 355 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/ExternalCommunicator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9685de855ca1541409f4187c5ab7601d 3 | timeCreated: 1504820023 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Monitor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | using Newtonsoft.Json; 6 | using System.Linq; 7 | 8 | 9 | /** The type of monitor the information must be displayed in. 10 | * corresponds to a slingle rectangle which width is given 11 | * by a float between -1 and 1. (green is positive, red is negative) 12 | * corresponds to n vertical sliders. 13 | * is a text field. 14 | * is a rectangle of fixed length to represent the proportions 15 | * of a list of floats. 16 | */ 17 | public enum MonitorType 18 | { 19 | slider, 20 | hist, 21 | text, 22 | bar 23 | } 24 | 25 | /** Monitor is used to display information. Use the log function to add 26 | * information to your monitor. 27 | */ 28 | public class Monitor : MonoBehaviour 29 | { 30 | 31 | static bool isInstanciated; 32 | static GameObject canvas; 33 | 34 | private struct DisplayValue 35 | { 36 | public float time; 37 | public object value; 38 | public MonitorType monitorDisplayType; 39 | } 40 | 41 | static Dictionary> displayTransformValues; 42 | static private Color[] barColors; 43 | [HideInInspector] 44 | static public float verticalOffset = 3f; 45 | /**< \brief This float represents how high above the target the monitors will be. */ 46 | 47 | static GUIStyle keyStyle; 48 | static GUIStyle valueStyle; 49 | static GUIStyle greenStyle; 50 | static GUIStyle redStyle; 51 | static GUIStyle[] colorStyle; 52 | static bool initialized; 53 | 54 | 55 | /** Use the Monitor.Log static function to attach information to a transform. 56 | * If displayType is , value can be any object. 57 | * If sidplayType is , value must be a float. 58 | * If sidplayType is , value must be a List or Array of floats. 59 | * If sidplayType is , value must be a list or Array of positive floats. 60 | * Note that and caps values between -1 and 1. 61 | * @param key The name of the information you wish to Log. 62 | * @param value The value you want to display. 63 | * @param displayType The type of display. 64 | * @param target The transform you want to attach the information to. 65 | */ 66 | public static void Log( 67 | string key, 68 | object value, 69 | MonitorType displayType = MonitorType.text, 70 | Transform target = null) 71 | { 72 | 73 | 74 | 75 | if (!isInstanciated) 76 | { 77 | InstanciateCanvas(); 78 | isInstanciated = true; 79 | 80 | } 81 | 82 | if (target == null) 83 | { 84 | target = canvas.transform; 85 | } 86 | 87 | if (!displayTransformValues.Keys.Contains(target)) 88 | { 89 | displayTransformValues[target] = new Dictionary(); 90 | } 91 | 92 | Dictionary displayValues = displayTransformValues[target]; 93 | 94 | if (value == null) 95 | { 96 | RemoveValue(target, key); 97 | return; 98 | } 99 | if (!displayValues.ContainsKey(key)) 100 | { 101 | DisplayValue dv = new DisplayValue(); 102 | dv.time = Time.timeSinceLevelLoad; 103 | dv.value = value; 104 | dv.monitorDisplayType = displayType; 105 | displayValues[key] = dv; 106 | while (displayValues.Count > 20) 107 | { 108 | string max = displayValues.Aggregate((l, r) => l.Value.time < r.Value.time ? l : r).Key; 109 | RemoveValue(target, max); 110 | } 111 | } 112 | else 113 | { 114 | DisplayValue dv = displayValues[key]; 115 | dv.value = value; 116 | displayValues[key] = dv; 117 | } 118 | } 119 | 120 | /** Remove a value from a monitor 121 | * @param target The transform to which the information is attached 122 | * @param key The key of the information you want to remove 123 | */ 124 | public static void RemoveValue(Transform target, string key) 125 | { 126 | if (target == null) 127 | { 128 | target = canvas.transform; 129 | } 130 | if (displayTransformValues.Keys.Contains(target)) 131 | { 132 | if (displayTransformValues[target].ContainsKey(key)) 133 | { 134 | displayTransformValues[target].Remove(key); 135 | if (displayTransformValues[target].Keys.Count == 0) 136 | { 137 | displayTransformValues.Remove(target); 138 | } 139 | } 140 | } 141 | 142 | } 143 | 144 | /** Remove all information from a monitor 145 | * @param target The transform to which the information is attached 146 | */ 147 | public static void RemoveAllValues(Transform target) 148 | { 149 | if (target == null) 150 | { 151 | target = canvas.transform; 152 | } 153 | if (displayTransformValues.Keys.Contains(target)) 154 | { 155 | displayTransformValues.Remove(target); 156 | } 157 | 158 | } 159 | 160 | /** Use SetActive to enable or disable the Monitor via script 161 | * @param active Set the Monitor's status to the value of active 162 | */ 163 | public static void SetActive(bool active){ 164 | if (!isInstanciated) 165 | { 166 | InstanciateCanvas(); 167 | isInstanciated = true; 168 | 169 | } 170 | canvas.SetActive(active); 171 | 172 | } 173 | 174 | private static void InstanciateCanvas() 175 | { 176 | canvas = GameObject.Find("AgentMonitorCanvas"); 177 | if (canvas == null) 178 | { 179 | canvas = new GameObject(); 180 | canvas.name = "AgentMonitorCanvas"; 181 | canvas.AddComponent(); 182 | } 183 | displayTransformValues = new Dictionary>(); 184 | 185 | } 186 | 187 | private float[] ToFloatArray(object input) 188 | { 189 | try 190 | { 191 | return JsonConvert.DeserializeObject( 192 | JsonConvert.SerializeObject(input, Formatting.None)); 193 | } 194 | catch 195 | { 196 | } 197 | try 198 | { 199 | return new float[1] 200 | {JsonConvert.DeserializeObject( 201 | JsonConvert.SerializeObject(input, Formatting.None)) 202 | }; 203 | } 204 | catch 205 | { 206 | } 207 | 208 | return new float[0]; 209 | } 210 | 211 | void OnGUI() 212 | { 213 | if (!initialized) 214 | { 215 | Initialize(); 216 | initialized = true; 217 | } 218 | 219 | var toIterate = displayTransformValues.Keys.ToList(); 220 | foreach (Transform target in toIterate) 221 | { 222 | if (target == null) 223 | { 224 | displayTransformValues.Remove(target); 225 | continue; 226 | } 227 | 228 | float widthScaler = (Screen.width / 1000f); 229 | float keyPixelWidth = 100 * widthScaler; 230 | float keyPixelHeight = 20 * widthScaler; 231 | float paddingwidth = 10 * widthScaler; 232 | 233 | float scale = 1f; 234 | Vector2 origin = new Vector3(0, Screen.height); 235 | if (!(target == canvas.transform)) 236 | { 237 | Vector3 cam2obj = target.position - Camera.main.transform.position; 238 | scale = Mathf.Min(1, 20f / (Vector3.Dot(cam2obj, Camera.main.transform.forward))); 239 | Vector3 worldPosition = Camera.main.WorldToScreenPoint(target.position + new Vector3(0, verticalOffset, 0)); 240 | origin = new Vector3(worldPosition.x - keyPixelWidth * scale, Screen.height - worldPosition.y); 241 | } 242 | keyPixelWidth *= scale; 243 | keyPixelHeight *= scale; 244 | paddingwidth *= scale; 245 | keyStyle.fontSize = (int)(keyPixelHeight * 0.8f); 246 | if (keyStyle.fontSize < 2) 247 | { 248 | continue; 249 | } 250 | 251 | 252 | Dictionary displayValues = displayTransformValues[target]; 253 | 254 | int index = 0; 255 | foreach (string key in displayValues.Keys.OrderBy(x => -displayValues[x].time)) 256 | { 257 | keyStyle.alignment = TextAnchor.MiddleRight; 258 | GUI.Label(new Rect(origin.x, origin.y - (index + 1) * keyPixelHeight, keyPixelWidth, keyPixelHeight), key, keyStyle); 259 | if (displayValues[key].monitorDisplayType == MonitorType.text) 260 | { 261 | valueStyle.alignment = TextAnchor.MiddleLeft; 262 | GUI.Label(new Rect( 263 | origin.x + paddingwidth + keyPixelWidth, 264 | origin.y - (index + 1) * keyPixelHeight, 265 | keyPixelWidth, keyPixelHeight), 266 | JsonConvert.SerializeObject(displayValues[key].value, Formatting.None), valueStyle); 267 | 268 | } 269 | else if (displayValues[key].monitorDisplayType == MonitorType.slider) 270 | { 271 | float sliderValue = 0f; 272 | if (displayValues[key].value.GetType() == typeof(float)) 273 | { 274 | sliderValue = (float)displayValues[key].value; 275 | } 276 | else 277 | { 278 | Debug.LogError(string.Format("The value for {0} could not be displayed as " + 279 | "a slider because it is not a number.", key)); 280 | } 281 | 282 | sliderValue = Mathf.Min(1f, sliderValue); 283 | GUIStyle s = greenStyle; 284 | if (sliderValue < 0) 285 | { 286 | sliderValue = Mathf.Min(1f, -sliderValue); 287 | s = redStyle; 288 | } 289 | GUI.Box(new Rect( 290 | origin.x + paddingwidth + keyPixelWidth, 291 | origin.y - (index + 0.9f) * keyPixelHeight, 292 | keyPixelWidth * sliderValue, keyPixelHeight * 0.8f), 293 | GUIContent.none, s); 294 | 295 | } 296 | else if (displayValues[key].monitorDisplayType == MonitorType.hist) 297 | { 298 | float histWidth = 0.15f; 299 | float[] vals = ToFloatArray(displayValues[key].value); 300 | for (int i = 0; i < vals.Length; i++) 301 | { 302 | float value = Mathf.Min(vals[i], 1); 303 | GUIStyle s = greenStyle; 304 | if (value < 0) 305 | { 306 | value = Mathf.Min(1f, -value); 307 | s = redStyle; 308 | } 309 | GUI.Box(new Rect( 310 | origin.x + paddingwidth + keyPixelWidth + (keyPixelWidth * histWidth + paddingwidth / 2) * i, 311 | origin.y - (index + 0.1f) * keyPixelHeight, 312 | keyPixelWidth * histWidth, -keyPixelHeight * value), 313 | GUIContent.none, s); 314 | } 315 | 316 | 317 | } 318 | else if (displayValues[key].monitorDisplayType == MonitorType.bar) 319 | { 320 | float[] vals = ToFloatArray(displayValues[key].value); 321 | float valsSum = 0f; 322 | float valsCum = 0f; 323 | foreach (float f in vals) 324 | { 325 | valsSum += Mathf.Max(f, 0); 326 | } 327 | if (valsSum == 0) 328 | { 329 | Debug.LogError(string.Format("The Monitor value for key {0} must be " 330 | + "a list or array of positive values and cannot be empty.", key)); 331 | } 332 | else 333 | { 334 | for (int i = 0; i < vals.Length; i++) 335 | { 336 | float value = Mathf.Max(vals[i], 0) / valsSum; 337 | GUI.Box(new Rect( 338 | origin.x + paddingwidth + keyPixelWidth + keyPixelWidth * valsCum, 339 | origin.y - (index + 0.9f) * keyPixelHeight, 340 | keyPixelWidth * value, keyPixelHeight * 0.8f), 341 | GUIContent.none, colorStyle[i % colorStyle.Length]); 342 | valsCum += value; 343 | 344 | } 345 | 346 | } 347 | 348 | } 349 | 350 | index++; 351 | } 352 | } 353 | } 354 | 355 | private void Initialize() 356 | { 357 | 358 | keyStyle = GUI.skin.label; 359 | valueStyle = GUI.skin.label; 360 | valueStyle.clipping = TextClipping.Overflow; 361 | valueStyle.wordWrap = false; 362 | 363 | 364 | 365 | barColors = new Color[6]{ Color.magenta, Color.blue, Color.cyan, Color.green, Color.yellow, Color.red }; 366 | colorStyle = new GUIStyle[barColors.Length]; 367 | for (int i = 0; i < barColors.Length; i++) 368 | { 369 | Texture2D texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); 370 | texture.SetPixel(0, 0, barColors[i]); 371 | texture.Apply(); 372 | GUIStyle staticRectStyle = new GUIStyle(); 373 | staticRectStyle.normal.background = texture; 374 | colorStyle[i] = staticRectStyle; 375 | } 376 | greenStyle = colorStyle[3]; 377 | redStyle = colorStyle[5]; 378 | } 379 | 380 | } 381 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/Monitor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e59a31a1cc2f5464d9a61bef0bc9a53b 3 | timeCreated: 1508031727 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/UnityAgentsException.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | using System; 6 | [System.Serializable] 7 | /// Contains exceptions specific to ML-Agents. 8 | public class UnityAgentsException : System.Exception 9 | { 10 | /// When a UnityAgentsException is called, the timeScale is set to 0. 11 | /// The simulation will end since no steps will be taken. 12 | public UnityAgentsException(string message) : base(message) 13 | { 14 | Time.timeScale = 0f; 15 | } 16 | 17 | /// A constructor is needed for serialization when an exception propagates 18 | /// from a remoting server to the client. 19 | protected UnityAgentsException(System.Runtime.Serialization.SerializationInfo info, 20 | System.Runtime.Serialization.StreamingContext context) 21 | { } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/ML-Agents/Scripts/UnityAgentsException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e63e4a66d820245778f9a2abfa5b68e0 3 | timeCreated: 1504131359 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MLScripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d85efa0cf297a4c09a8b078cc2423c38 3 | folderAsset: yes 4 | timeCreated: 1510274623 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/MLScripts/RatAcademy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RatAcademy : Academy { 6 | 7 | public override void AcademyReset() 8 | { 9 | float val; 10 | int episodeLength = resetParameters.TryGetValue("ep_length", out val) ? (int)val - 1: 299; 11 | float startAreaExtents = resetParameters.TryGetValue("start_area_extents", out val) ? val : 0F; 12 | 13 | foreach (var c in GameObject.FindObjectsOfType()) 14 | { 15 | c.maxStep = episodeLength; 16 | c.startAreaExtents = new Vector2(startAreaExtents, startAreaExtents); 17 | } 18 | } 19 | 20 | public override void AcademyStep() 21 | { 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Assets/MLScripts/RatAcademy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98650fde2e20244a0b8868be89c0b0fd 3 | timeCreated: 1503355437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/MLScripts/RatAgent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RatAgent : Agent 6 | { 7 | public Vector2 startAreaExtents = Vector2.zero; 8 | 9 | public int episode; 10 | 11 | public override List CollectState() 12 | { 13 | List state = new List(); 14 | 15 | // Y 16 | state.Add(transform.position.x); // 0 17 | state.Add(transform.position.z); // 1 18 | 19 | // X 20 | state.Add(transform.rotation.eulerAngles.y/180.0f-1.0f); // 2 21 | state.Add(GetComponent().velocity.x); // 3 22 | state.Add(GetComponent().velocity.z); // 4 23 | state.Add(GetComponent().angularVelocity.y); // 5 24 | state.Add(GetComponent().velocity.magnitude); // 6 25 | 26 | // intent 27 | state.Add(GetComponent().observableState.heading); // 7 28 | state.Add(GetComponent().observableState.velocity); // 8 29 | 30 | // aux 31 | state.Add(episode); // 9 32 | return state; 33 | } 34 | 35 | public override void AgentStep(float[] act) 36 | { 37 | 38 | } 39 | 40 | public override void AgentReset() 41 | { 42 | transform.position = new Vector3(Random.Range(-startAreaExtents.x, startAreaExtents.x), 0f, Random.Range(-startAreaExtents.y, startAreaExtents.y)); 43 | transform.rotation = Quaternion.Euler(new Vector3(0f, Random.Range(0f, 360f), 0f)); 44 | GetComponent().velocity = new Vector3(0f, 0f, 0f); 45 | GetComponent().angularVelocity = new Vector3(0f, 0f, 0f); 46 | episode += 1; 47 | } 48 | 49 | public override void AgentOnDone() 50 | { 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assets/MLScripts/RatAgent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bfb0820bedb748fb9fc7e19babc0f74 3 | timeCreated: 1503355437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/MLScripts/RatDecision.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class RatDecision : MonoBehaviour, Decision 6 | { 7 | 8 | public float[] Decide(List state, List observation, float reward, bool done, float[] memory) 9 | { 10 | return new float[0]; 11 | 12 | } 13 | 14 | public float[] MakeMemory(List state, List observation, float reward, bool done, float[] memory) 15 | { 16 | return new float[0]; 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Assets/MLScripts/RatDecision.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65c8216d5b390411faa4bc269741aa21 3 | timeCreated: 1503355437 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54f10a0cf0af944fca8c13c5562316f8 3 | folderAsset: yes 4 | timeCreated: 1509880226 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Prefabs/EnvBox.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_ParentPrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1450769557452336} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1101443147541410 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_PrefabParentObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 5 20 | m_Component: 21 | - component: {fileID: 4692581237062620} 22 | - component: {fileID: 33591994226089414} 23 | - component: {fileID: 65495045736342664} 24 | - component: {fileID: 23027951726401468} 25 | m_Layer: 0 26 | m_Name: Wall 27 | m_TagString: Untagged 28 | m_Icon: {fileID: 0} 29 | m_NavMeshLayer: 0 30 | m_StaticEditorFlags: 0 31 | m_IsActive: 1 32 | --- !u!1 &1163972332666408 33 | GameObject: 34 | m_ObjectHideFlags: 0 35 | m_PrefabParentObject: {fileID: 0} 36 | m_PrefabInternal: {fileID: 100100000} 37 | serializedVersion: 5 38 | m_Component: 39 | - component: {fileID: 4689246614904890} 40 | - component: {fileID: 33152446051909102} 41 | - component: {fileID: 65995361645557632} 42 | - component: {fileID: 23628117890051518} 43 | m_Layer: 0 44 | m_Name: Wall 45 | m_TagString: Untagged 46 | m_Icon: {fileID: 0} 47 | m_NavMeshLayer: 0 48 | m_StaticEditorFlags: 0 49 | m_IsActive: 1 50 | --- !u!1 &1430878874265138 51 | GameObject: 52 | m_ObjectHideFlags: 0 53 | m_PrefabParentObject: {fileID: 0} 54 | m_PrefabInternal: {fileID: 100100000} 55 | serializedVersion: 5 56 | m_Component: 57 | - component: {fileID: 4585454968977602} 58 | - component: {fileID: 33101956626461840} 59 | - component: {fileID: 65619863553033512} 60 | - component: {fileID: 23401905992464080} 61 | m_Layer: 0 62 | m_Name: Wall 63 | m_TagString: Untagged 64 | m_Icon: {fileID: 0} 65 | m_NavMeshLayer: 0 66 | m_StaticEditorFlags: 0 67 | m_IsActive: 1 68 | --- !u!1 &1450769557452336 69 | GameObject: 70 | m_ObjectHideFlags: 0 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | serializedVersion: 5 74 | m_Component: 75 | - component: {fileID: 4269421212497686} 76 | m_Layer: 0 77 | m_Name: EnvBox 78 | m_TagString: Maze 79 | m_Icon: {fileID: 0} 80 | m_NavMeshLayer: 0 81 | m_StaticEditorFlags: 0 82 | m_IsActive: 1 83 | --- !u!1 &1690085097446284 84 | GameObject: 85 | m_ObjectHideFlags: 0 86 | m_PrefabParentObject: {fileID: 0} 87 | m_PrefabInternal: {fileID: 100100000} 88 | serializedVersion: 5 89 | m_Component: 90 | - component: {fileID: 4068427074818528} 91 | - component: {fileID: 33231879787246952} 92 | - component: {fileID: 65987020175626812} 93 | - component: {fileID: 23518263656537814} 94 | m_Layer: 0 95 | m_Name: Wall 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &4068427074818528 102 | Transform: 103 | m_ObjectHideFlags: 1 104 | m_PrefabParentObject: {fileID: 0} 105 | m_PrefabInternal: {fileID: 100100000} 106 | m_GameObject: {fileID: 1690085097446284} 107 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 108 | m_LocalPosition: {x: -10, y: 0, z: 0} 109 | m_LocalScale: {x: 1, y: 1, z: 21} 110 | m_Children: [] 111 | m_Father: {fileID: 4269421212497686} 112 | m_RootOrder: 2 113 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 114 | --- !u!4 &4269421212497686 115 | Transform: 116 | m_ObjectHideFlags: 1 117 | m_PrefabParentObject: {fileID: 0} 118 | m_PrefabInternal: {fileID: 100100000} 119 | m_GameObject: {fileID: 1450769557452336} 120 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 121 | m_LocalPosition: {x: 0, y: 0, z: 0} 122 | m_LocalScale: {x: 1, y: 1, z: 1} 123 | m_Children: 124 | - {fileID: 4692581237062620} 125 | - {fileID: 4585454968977602} 126 | - {fileID: 4068427074818528} 127 | - {fileID: 4689246614904890} 128 | m_Father: {fileID: 0} 129 | m_RootOrder: 0 130 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 131 | --- !u!4 &4585454968977602 132 | Transform: 133 | m_ObjectHideFlags: 1 134 | m_PrefabParentObject: {fileID: 0} 135 | m_PrefabInternal: {fileID: 100100000} 136 | m_GameObject: {fileID: 1430878874265138} 137 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 138 | m_LocalPosition: {x: 0, y: 0, z: -10} 139 | m_LocalScale: {x: 21, y: 1, z: 1} 140 | m_Children: [] 141 | m_Father: {fileID: 4269421212497686} 142 | m_RootOrder: 1 143 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 144 | --- !u!4 &4689246614904890 145 | Transform: 146 | m_ObjectHideFlags: 1 147 | m_PrefabParentObject: {fileID: 0} 148 | m_PrefabInternal: {fileID: 100100000} 149 | m_GameObject: {fileID: 1163972332666408} 150 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 151 | m_LocalPosition: {x: 10, y: 0, z: 0} 152 | m_LocalScale: {x: 1, y: 1, z: 21} 153 | m_Children: [] 154 | m_Father: {fileID: 4269421212497686} 155 | m_RootOrder: 3 156 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 157 | --- !u!4 &4692581237062620 158 | Transform: 159 | m_ObjectHideFlags: 1 160 | m_PrefabParentObject: {fileID: 0} 161 | m_PrefabInternal: {fileID: 100100000} 162 | m_GameObject: {fileID: 1101443147541410} 163 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 164 | m_LocalPosition: {x: 0, y: 0, z: 10} 165 | m_LocalScale: {x: 21, y: 1, z: 1} 166 | m_Children: [] 167 | m_Father: {fileID: 4269421212497686} 168 | m_RootOrder: 0 169 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 170 | --- !u!23 &23027951726401468 171 | MeshRenderer: 172 | m_ObjectHideFlags: 1 173 | m_PrefabParentObject: {fileID: 0} 174 | m_PrefabInternal: {fileID: 100100000} 175 | m_GameObject: {fileID: 1101443147541410} 176 | m_Enabled: 1 177 | m_CastShadows: 1 178 | m_ReceiveShadows: 1 179 | m_MotionVectors: 1 180 | m_LightProbeUsage: 1 181 | m_ReflectionProbeUsage: 1 182 | m_Materials: 183 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 184 | m_StaticBatchInfo: 185 | firstSubMesh: 0 186 | subMeshCount: 0 187 | m_StaticBatchRoot: {fileID: 0} 188 | m_ProbeAnchor: {fileID: 0} 189 | m_LightProbeVolumeOverride: {fileID: 0} 190 | m_ScaleInLightmap: 1 191 | m_PreserveUVs: 1 192 | m_IgnoreNormalsForChartDetection: 0 193 | m_ImportantGI: 0 194 | m_SelectedEditorRenderState: 3 195 | m_MinimumChartSize: 4 196 | m_AutoUVMaxDistance: 0.5 197 | m_AutoUVMaxAngle: 89 198 | m_LightmapParameters: {fileID: 0} 199 | m_SortingLayerID: 0 200 | m_SortingLayer: 0 201 | m_SortingOrder: 0 202 | --- !u!23 &23401905992464080 203 | MeshRenderer: 204 | m_ObjectHideFlags: 1 205 | m_PrefabParentObject: {fileID: 0} 206 | m_PrefabInternal: {fileID: 100100000} 207 | m_GameObject: {fileID: 1430878874265138} 208 | m_Enabled: 1 209 | m_CastShadows: 1 210 | m_ReceiveShadows: 1 211 | m_MotionVectors: 1 212 | m_LightProbeUsage: 1 213 | m_ReflectionProbeUsage: 1 214 | m_Materials: 215 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 216 | m_StaticBatchInfo: 217 | firstSubMesh: 0 218 | subMeshCount: 0 219 | m_StaticBatchRoot: {fileID: 0} 220 | m_ProbeAnchor: {fileID: 0} 221 | m_LightProbeVolumeOverride: {fileID: 0} 222 | m_ScaleInLightmap: 1 223 | m_PreserveUVs: 1 224 | m_IgnoreNormalsForChartDetection: 0 225 | m_ImportantGI: 0 226 | m_SelectedEditorRenderState: 3 227 | m_MinimumChartSize: 4 228 | m_AutoUVMaxDistance: 0.5 229 | m_AutoUVMaxAngle: 89 230 | m_LightmapParameters: {fileID: 0} 231 | m_SortingLayerID: 0 232 | m_SortingLayer: 0 233 | m_SortingOrder: 0 234 | --- !u!23 &23518263656537814 235 | MeshRenderer: 236 | m_ObjectHideFlags: 1 237 | m_PrefabParentObject: {fileID: 0} 238 | m_PrefabInternal: {fileID: 100100000} 239 | m_GameObject: {fileID: 1690085097446284} 240 | m_Enabled: 1 241 | m_CastShadows: 1 242 | m_ReceiveShadows: 1 243 | m_MotionVectors: 1 244 | m_LightProbeUsage: 1 245 | m_ReflectionProbeUsage: 1 246 | m_Materials: 247 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 248 | m_StaticBatchInfo: 249 | firstSubMesh: 0 250 | subMeshCount: 0 251 | m_StaticBatchRoot: {fileID: 0} 252 | m_ProbeAnchor: {fileID: 0} 253 | m_LightProbeVolumeOverride: {fileID: 0} 254 | m_ScaleInLightmap: 1 255 | m_PreserveUVs: 1 256 | m_IgnoreNormalsForChartDetection: 0 257 | m_ImportantGI: 0 258 | m_SelectedEditorRenderState: 3 259 | m_MinimumChartSize: 4 260 | m_AutoUVMaxDistance: 0.5 261 | m_AutoUVMaxAngle: 89 262 | m_LightmapParameters: {fileID: 0} 263 | m_SortingLayerID: 0 264 | m_SortingLayer: 0 265 | m_SortingOrder: 0 266 | --- !u!23 &23628117890051518 267 | MeshRenderer: 268 | m_ObjectHideFlags: 1 269 | m_PrefabParentObject: {fileID: 0} 270 | m_PrefabInternal: {fileID: 100100000} 271 | m_GameObject: {fileID: 1163972332666408} 272 | m_Enabled: 1 273 | m_CastShadows: 1 274 | m_ReceiveShadows: 1 275 | m_MotionVectors: 1 276 | m_LightProbeUsage: 1 277 | m_ReflectionProbeUsage: 1 278 | m_Materials: 279 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 280 | m_StaticBatchInfo: 281 | firstSubMesh: 0 282 | subMeshCount: 0 283 | m_StaticBatchRoot: {fileID: 0} 284 | m_ProbeAnchor: {fileID: 0} 285 | m_LightProbeVolumeOverride: {fileID: 0} 286 | m_ScaleInLightmap: 1 287 | m_PreserveUVs: 1 288 | m_IgnoreNormalsForChartDetection: 0 289 | m_ImportantGI: 0 290 | m_SelectedEditorRenderState: 3 291 | m_MinimumChartSize: 4 292 | m_AutoUVMaxDistance: 0.5 293 | m_AutoUVMaxAngle: 89 294 | m_LightmapParameters: {fileID: 0} 295 | m_SortingLayerID: 0 296 | m_SortingLayer: 0 297 | m_SortingOrder: 0 298 | --- !u!33 &33101956626461840 299 | MeshFilter: 300 | m_ObjectHideFlags: 1 301 | m_PrefabParentObject: {fileID: 0} 302 | m_PrefabInternal: {fileID: 100100000} 303 | m_GameObject: {fileID: 1430878874265138} 304 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 305 | --- !u!33 &33152446051909102 306 | MeshFilter: 307 | m_ObjectHideFlags: 1 308 | m_PrefabParentObject: {fileID: 0} 309 | m_PrefabInternal: {fileID: 100100000} 310 | m_GameObject: {fileID: 1163972332666408} 311 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 312 | --- !u!33 &33231879787246952 313 | MeshFilter: 314 | m_ObjectHideFlags: 1 315 | m_PrefabParentObject: {fileID: 0} 316 | m_PrefabInternal: {fileID: 100100000} 317 | m_GameObject: {fileID: 1690085097446284} 318 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 319 | --- !u!33 &33591994226089414 320 | MeshFilter: 321 | m_ObjectHideFlags: 1 322 | m_PrefabParentObject: {fileID: 0} 323 | m_PrefabInternal: {fileID: 100100000} 324 | m_GameObject: {fileID: 1101443147541410} 325 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 326 | --- !u!65 &65495045736342664 327 | BoxCollider: 328 | m_ObjectHideFlags: 1 329 | m_PrefabParentObject: {fileID: 0} 330 | m_PrefabInternal: {fileID: 100100000} 331 | m_GameObject: {fileID: 1101443147541410} 332 | m_Material: {fileID: 0} 333 | m_IsTrigger: 0 334 | m_Enabled: 1 335 | serializedVersion: 2 336 | m_Size: {x: 1, y: 1, z: 1} 337 | m_Center: {x: 0, y: 0, z: 0} 338 | --- !u!65 &65619863553033512 339 | BoxCollider: 340 | m_ObjectHideFlags: 1 341 | m_PrefabParentObject: {fileID: 0} 342 | m_PrefabInternal: {fileID: 100100000} 343 | m_GameObject: {fileID: 1430878874265138} 344 | m_Material: {fileID: 0} 345 | m_IsTrigger: 0 346 | m_Enabled: 1 347 | serializedVersion: 2 348 | m_Size: {x: 1, y: 1, z: 1} 349 | m_Center: {x: 0, y: 0, z: 0} 350 | --- !u!65 &65987020175626812 351 | BoxCollider: 352 | m_ObjectHideFlags: 1 353 | m_PrefabParentObject: {fileID: 0} 354 | m_PrefabInternal: {fileID: 100100000} 355 | m_GameObject: {fileID: 1690085097446284} 356 | m_Material: {fileID: 0} 357 | m_IsTrigger: 0 358 | m_Enabled: 1 359 | serializedVersion: 2 360 | m_Size: {x: 1, y: 1, z: 1} 361 | m_Center: {x: 0, y: 0, z: 0} 362 | --- !u!65 &65995361645557632 363 | BoxCollider: 364 | m_ObjectHideFlags: 1 365 | m_PrefabParentObject: {fileID: 0} 366 | m_PrefabInternal: {fileID: 100100000} 367 | m_GameObject: {fileID: 1163972332666408} 368 | m_Material: {fileID: 0} 369 | m_IsTrigger: 0 370 | m_Enabled: 1 371 | serializedVersion: 2 372 | m_Size: {x: 1, y: 1, z: 1} 373 | m_Center: {x: 0, y: 0, z: 0} 374 | -------------------------------------------------------------------------------- /Assets/Prefabs/EnvBox.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b647a3dd883944b1bab0e34e1b9199b9 3 | timeCreated: 1509879934 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Prefabs/EnvHex.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83012c022d1454a7a88b95ac008f8b09 3 | timeCreated: 1509879934 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Prefabs/EnvSmallBox.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_ParentPrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1450769557452336} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1101443147541410 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_PrefabParentObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 5 20 | m_Component: 21 | - component: {fileID: 4692581237062620} 22 | - component: {fileID: 33591994226089414} 23 | - component: {fileID: 65495045736342664} 24 | - component: {fileID: 23027951726401468} 25 | m_Layer: 0 26 | m_Name: Wall 27 | m_TagString: Untagged 28 | m_Icon: {fileID: 0} 29 | m_NavMeshLayer: 0 30 | m_StaticEditorFlags: 0 31 | m_IsActive: 1 32 | --- !u!1 &1163972332666408 33 | GameObject: 34 | m_ObjectHideFlags: 0 35 | m_PrefabParentObject: {fileID: 0} 36 | m_PrefabInternal: {fileID: 100100000} 37 | serializedVersion: 5 38 | m_Component: 39 | - component: {fileID: 4689246614904890} 40 | - component: {fileID: 33152446051909102} 41 | - component: {fileID: 65995361645557632} 42 | - component: {fileID: 23628117890051518} 43 | m_Layer: 0 44 | m_Name: Wall 45 | m_TagString: Untagged 46 | m_Icon: {fileID: 0} 47 | m_NavMeshLayer: 0 48 | m_StaticEditorFlags: 0 49 | m_IsActive: 1 50 | --- !u!1 &1430878874265138 51 | GameObject: 52 | m_ObjectHideFlags: 0 53 | m_PrefabParentObject: {fileID: 0} 54 | m_PrefabInternal: {fileID: 100100000} 55 | serializedVersion: 5 56 | m_Component: 57 | - component: {fileID: 4585454968977602} 58 | - component: {fileID: 33101956626461840} 59 | - component: {fileID: 65619863553033512} 60 | - component: {fileID: 23401905992464080} 61 | m_Layer: 0 62 | m_Name: Wall 63 | m_TagString: Untagged 64 | m_Icon: {fileID: 0} 65 | m_NavMeshLayer: 0 66 | m_StaticEditorFlags: 0 67 | m_IsActive: 1 68 | --- !u!1 &1450769557452336 69 | GameObject: 70 | m_ObjectHideFlags: 0 71 | m_PrefabParentObject: {fileID: 0} 72 | m_PrefabInternal: {fileID: 100100000} 73 | serializedVersion: 5 74 | m_Component: 75 | - component: {fileID: 4269421212497686} 76 | m_Layer: 0 77 | m_Name: EnvSmallBox 78 | m_TagString: Maze 79 | m_Icon: {fileID: 0} 80 | m_NavMeshLayer: 0 81 | m_StaticEditorFlags: 0 82 | m_IsActive: 1 83 | --- !u!1 &1690085097446284 84 | GameObject: 85 | m_ObjectHideFlags: 0 86 | m_PrefabParentObject: {fileID: 0} 87 | m_PrefabInternal: {fileID: 100100000} 88 | serializedVersion: 5 89 | m_Component: 90 | - component: {fileID: 4068427074818528} 91 | - component: {fileID: 33231879787246952} 92 | - component: {fileID: 65987020175626812} 93 | - component: {fileID: 23518263656537814} 94 | m_Layer: 0 95 | m_Name: Wall 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &4068427074818528 102 | Transform: 103 | m_ObjectHideFlags: 1 104 | m_PrefabParentObject: {fileID: 0} 105 | m_PrefabInternal: {fileID: 100100000} 106 | m_GameObject: {fileID: 1690085097446284} 107 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 108 | m_LocalPosition: {x: -5, y: 0, z: 0} 109 | m_LocalScale: {x: 1, y: 1, z: 10} 110 | m_Children: [] 111 | m_Father: {fileID: 4269421212497686} 112 | m_RootOrder: 2 113 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 114 | --- !u!4 &4269421212497686 115 | Transform: 116 | m_ObjectHideFlags: 1 117 | m_PrefabParentObject: {fileID: 0} 118 | m_PrefabInternal: {fileID: 100100000} 119 | m_GameObject: {fileID: 1450769557452336} 120 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 121 | m_LocalPosition: {x: 0, y: 0, z: 0} 122 | m_LocalScale: {x: 1, y: 1, z: 1} 123 | m_Children: 124 | - {fileID: 4692581237062620} 125 | - {fileID: 4585454968977602} 126 | - {fileID: 4068427074818528} 127 | - {fileID: 4689246614904890} 128 | m_Father: {fileID: 0} 129 | m_RootOrder: 0 130 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 131 | --- !u!4 &4585454968977602 132 | Transform: 133 | m_ObjectHideFlags: 1 134 | m_PrefabParentObject: {fileID: 0} 135 | m_PrefabInternal: {fileID: 100100000} 136 | m_GameObject: {fileID: 1430878874265138} 137 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 138 | m_LocalPosition: {x: 0, y: 0, z: -4} 139 | m_LocalScale: {x: 10, y: 1, z: 1} 140 | m_Children: [] 141 | m_Father: {fileID: 4269421212497686} 142 | m_RootOrder: 1 143 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 144 | --- !u!4 &4689246614904890 145 | Transform: 146 | m_ObjectHideFlags: 1 147 | m_PrefabParentObject: {fileID: 0} 148 | m_PrefabInternal: {fileID: 100100000} 149 | m_GameObject: {fileID: 1163972332666408} 150 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 151 | m_LocalPosition: {x: 5, y: 0, z: 0} 152 | m_LocalScale: {x: 1, y: 1, z: 10} 153 | m_Children: [] 154 | m_Father: {fileID: 4269421212497686} 155 | m_RootOrder: 3 156 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 157 | --- !u!4 &4692581237062620 158 | Transform: 159 | m_ObjectHideFlags: 1 160 | m_PrefabParentObject: {fileID: 0} 161 | m_PrefabInternal: {fileID: 100100000} 162 | m_GameObject: {fileID: 1101443147541410} 163 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 164 | m_LocalPosition: {x: 0, y: 0, z: 4} 165 | m_LocalScale: {x: 10, y: 1, z: 1} 166 | m_Children: [] 167 | m_Father: {fileID: 4269421212497686} 168 | m_RootOrder: 0 169 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 170 | --- !u!23 &23027951726401468 171 | MeshRenderer: 172 | m_ObjectHideFlags: 1 173 | m_PrefabParentObject: {fileID: 0} 174 | m_PrefabInternal: {fileID: 100100000} 175 | m_GameObject: {fileID: 1101443147541410} 176 | m_Enabled: 1 177 | m_CastShadows: 1 178 | m_ReceiveShadows: 1 179 | m_MotionVectors: 1 180 | m_LightProbeUsage: 1 181 | m_ReflectionProbeUsage: 1 182 | m_Materials: 183 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 184 | m_StaticBatchInfo: 185 | firstSubMesh: 0 186 | subMeshCount: 0 187 | m_StaticBatchRoot: {fileID: 0} 188 | m_ProbeAnchor: {fileID: 0} 189 | m_LightProbeVolumeOverride: {fileID: 0} 190 | m_ScaleInLightmap: 1 191 | m_PreserveUVs: 1 192 | m_IgnoreNormalsForChartDetection: 0 193 | m_ImportantGI: 0 194 | m_SelectedEditorRenderState: 3 195 | m_MinimumChartSize: 4 196 | m_AutoUVMaxDistance: 0.5 197 | m_AutoUVMaxAngle: 89 198 | m_LightmapParameters: {fileID: 0} 199 | m_SortingLayerID: 0 200 | m_SortingLayer: 0 201 | m_SortingOrder: 0 202 | --- !u!23 &23401905992464080 203 | MeshRenderer: 204 | m_ObjectHideFlags: 1 205 | m_PrefabParentObject: {fileID: 0} 206 | m_PrefabInternal: {fileID: 100100000} 207 | m_GameObject: {fileID: 1430878874265138} 208 | m_Enabled: 1 209 | m_CastShadows: 1 210 | m_ReceiveShadows: 1 211 | m_MotionVectors: 1 212 | m_LightProbeUsage: 1 213 | m_ReflectionProbeUsage: 1 214 | m_Materials: 215 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 216 | m_StaticBatchInfo: 217 | firstSubMesh: 0 218 | subMeshCount: 0 219 | m_StaticBatchRoot: {fileID: 0} 220 | m_ProbeAnchor: {fileID: 0} 221 | m_LightProbeVolumeOverride: {fileID: 0} 222 | m_ScaleInLightmap: 1 223 | m_PreserveUVs: 1 224 | m_IgnoreNormalsForChartDetection: 0 225 | m_ImportantGI: 0 226 | m_SelectedEditorRenderState: 3 227 | m_MinimumChartSize: 4 228 | m_AutoUVMaxDistance: 0.5 229 | m_AutoUVMaxAngle: 89 230 | m_LightmapParameters: {fileID: 0} 231 | m_SortingLayerID: 0 232 | m_SortingLayer: 0 233 | m_SortingOrder: 0 234 | --- !u!23 &23518263656537814 235 | MeshRenderer: 236 | m_ObjectHideFlags: 1 237 | m_PrefabParentObject: {fileID: 0} 238 | m_PrefabInternal: {fileID: 100100000} 239 | m_GameObject: {fileID: 1690085097446284} 240 | m_Enabled: 1 241 | m_CastShadows: 1 242 | m_ReceiveShadows: 1 243 | m_MotionVectors: 1 244 | m_LightProbeUsage: 1 245 | m_ReflectionProbeUsage: 1 246 | m_Materials: 247 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 248 | m_StaticBatchInfo: 249 | firstSubMesh: 0 250 | subMeshCount: 0 251 | m_StaticBatchRoot: {fileID: 0} 252 | m_ProbeAnchor: {fileID: 0} 253 | m_LightProbeVolumeOverride: {fileID: 0} 254 | m_ScaleInLightmap: 1 255 | m_PreserveUVs: 1 256 | m_IgnoreNormalsForChartDetection: 0 257 | m_ImportantGI: 0 258 | m_SelectedEditorRenderState: 3 259 | m_MinimumChartSize: 4 260 | m_AutoUVMaxDistance: 0.5 261 | m_AutoUVMaxAngle: 89 262 | m_LightmapParameters: {fileID: 0} 263 | m_SortingLayerID: 0 264 | m_SortingLayer: 0 265 | m_SortingOrder: 0 266 | --- !u!23 &23628117890051518 267 | MeshRenderer: 268 | m_ObjectHideFlags: 1 269 | m_PrefabParentObject: {fileID: 0} 270 | m_PrefabInternal: {fileID: 100100000} 271 | m_GameObject: {fileID: 1163972332666408} 272 | m_Enabled: 1 273 | m_CastShadows: 1 274 | m_ReceiveShadows: 1 275 | m_MotionVectors: 1 276 | m_LightProbeUsage: 1 277 | m_ReflectionProbeUsage: 1 278 | m_Materials: 279 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 280 | m_StaticBatchInfo: 281 | firstSubMesh: 0 282 | subMeshCount: 0 283 | m_StaticBatchRoot: {fileID: 0} 284 | m_ProbeAnchor: {fileID: 0} 285 | m_LightProbeVolumeOverride: {fileID: 0} 286 | m_ScaleInLightmap: 1 287 | m_PreserveUVs: 1 288 | m_IgnoreNormalsForChartDetection: 0 289 | m_ImportantGI: 0 290 | m_SelectedEditorRenderState: 3 291 | m_MinimumChartSize: 4 292 | m_AutoUVMaxDistance: 0.5 293 | m_AutoUVMaxAngle: 89 294 | m_LightmapParameters: {fileID: 0} 295 | m_SortingLayerID: 0 296 | m_SortingLayer: 0 297 | m_SortingOrder: 0 298 | --- !u!33 &33101956626461840 299 | MeshFilter: 300 | m_ObjectHideFlags: 1 301 | m_PrefabParentObject: {fileID: 0} 302 | m_PrefabInternal: {fileID: 100100000} 303 | m_GameObject: {fileID: 1430878874265138} 304 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 305 | --- !u!33 &33152446051909102 306 | MeshFilter: 307 | m_ObjectHideFlags: 1 308 | m_PrefabParentObject: {fileID: 0} 309 | m_PrefabInternal: {fileID: 100100000} 310 | m_GameObject: {fileID: 1163972332666408} 311 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 312 | --- !u!33 &33231879787246952 313 | MeshFilter: 314 | m_ObjectHideFlags: 1 315 | m_PrefabParentObject: {fileID: 0} 316 | m_PrefabInternal: {fileID: 100100000} 317 | m_GameObject: {fileID: 1690085097446284} 318 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 319 | --- !u!33 &33591994226089414 320 | MeshFilter: 321 | m_ObjectHideFlags: 1 322 | m_PrefabParentObject: {fileID: 0} 323 | m_PrefabInternal: {fileID: 100100000} 324 | m_GameObject: {fileID: 1101443147541410} 325 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 326 | --- !u!65 &65495045736342664 327 | BoxCollider: 328 | m_ObjectHideFlags: 1 329 | m_PrefabParentObject: {fileID: 0} 330 | m_PrefabInternal: {fileID: 100100000} 331 | m_GameObject: {fileID: 1101443147541410} 332 | m_Material: {fileID: 0} 333 | m_IsTrigger: 0 334 | m_Enabled: 1 335 | serializedVersion: 2 336 | m_Size: {x: 1, y: 1, z: 1} 337 | m_Center: {x: 0, y: 0, z: 0} 338 | --- !u!65 &65619863553033512 339 | BoxCollider: 340 | m_ObjectHideFlags: 1 341 | m_PrefabParentObject: {fileID: 0} 342 | m_PrefabInternal: {fileID: 100100000} 343 | m_GameObject: {fileID: 1430878874265138} 344 | m_Material: {fileID: 0} 345 | m_IsTrigger: 0 346 | m_Enabled: 1 347 | serializedVersion: 2 348 | m_Size: {x: 1, y: 1, z: 1} 349 | m_Center: {x: 0, y: 0, z: 0} 350 | --- !u!65 &65987020175626812 351 | BoxCollider: 352 | m_ObjectHideFlags: 1 353 | m_PrefabParentObject: {fileID: 0} 354 | m_PrefabInternal: {fileID: 100100000} 355 | m_GameObject: {fileID: 1690085097446284} 356 | m_Material: {fileID: 0} 357 | m_IsTrigger: 0 358 | m_Enabled: 1 359 | serializedVersion: 2 360 | m_Size: {x: 1, y: 1, z: 1} 361 | m_Center: {x: 0, y: 0, z: 0} 362 | --- !u!65 &65995361645557632 363 | BoxCollider: 364 | m_ObjectHideFlags: 1 365 | m_PrefabParentObject: {fileID: 0} 366 | m_PrefabInternal: {fileID: 100100000} 367 | m_GameObject: {fileID: 1163972332666408} 368 | m_Material: {fileID: 0} 369 | m_IsTrigger: 0 370 | m_Enabled: 1 371 | serializedVersion: 2 372 | m_Size: {x: 1, y: 1, z: 1} 373 | m_Center: {x: 0, y: 0, z: 0} 374 | -------------------------------------------------------------------------------- /Assets/Prefabs/EnvSmallBox.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2352b7e27d9b4596b889cfc221a10c3 3 | timeCreated: 1509879934 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Prefabs/Rat.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e38b21fa0bae44385ab88541569f6d73 3 | timeCreated: 1509836168 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/RecordExperiment.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.SceneManagement; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | 8 | public class RecordExperiment : MonoBehaviour 9 | { 10 | public string filename = "experiment"; 11 | public int length = 50000; 12 | public int flushToFileEvery = 10000; 13 | public Controller agent; 14 | 15 | public int screenResolution = 64; 16 | 17 | private int fixedUpdateCounter = 0; 18 | private List entries = new List(); 19 | 20 | void Start() 21 | { 22 | if (agent == null) 23 | agent = GameObject.FindObjectOfType(); 24 | 25 | entries = new List(flushToFileEvery); 26 | 27 | Screen.SetResolution(screenResolution, screenResolution, false); 28 | } 29 | 30 | void FixedUpdate() 31 | { 32 | if (fixedUpdateCounter++ > length) 33 | Application.Quit(); 34 | 35 | if (agent == null) 36 | return; 37 | 38 | entries.Add(agent.observableState); 39 | 40 | if (entries.Count > flushToFileEvery) 41 | { 42 | Save(agent, entries.ToArray()); 43 | entries.Clear(); 44 | } 45 | } 46 | 47 | void Save(Controller src, Controller.ObservableState[] entries) 48 | { 49 | var experiment = new Experiment{ 50 | runSpeed = src.runSpeed, 51 | turnSpeed = src.turnSpeed, 52 | bodyRadius = src.gameObject.GetComponent().bounds.extents.z, 53 | sceneName = SceneManager.GetActiveScene().name, 54 | environmentName = GameObject.FindGameObjectWithTag("Maze").name, 55 | dateTime = DateTime.UtcNow.ToString(), 56 | entries = entries 57 | }; 58 | var json = JsonUtility.ToJson(experiment); 59 | 60 | using (var fs = new FileStream(filename + ".json", FileMode.OpenOrCreate, FileAccess.ReadWrite)) 61 | { 62 | bool newFile = fs.Length == 0; 63 | 64 | if (!newFile) 65 | fs.Seek(-1, SeekOrigin.End); // remove closing bracket, wwe are going to add entry to the array 66 | 67 | using (var writer = new StreamWriter(fs)) 68 | { 69 | if (newFile) 70 | writer.Write("[\n"); 71 | else 72 | writer.Write(",\n"); 73 | writer.Write(json); 74 | writer.Write("]"); 75 | } 76 | } 77 | } 78 | 79 | void OnApplicationQuit() 80 | { 81 | if (agent == null) 82 | return; 83 | 84 | Save(agent, entries.ToArray()); 85 | } 86 | 87 | class Experiment 88 | { 89 | public float runSpeed; 90 | public float turnSpeed; 91 | public float bodyRadius; 92 | public string sceneName; 93 | public string environmentName; 94 | public string dateTime; 95 | public Controller.ObservableState[] entries; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Assets/RecordExperiment.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff5ecb8bb57d04eed9f7ec41eec8cf1a 3 | timeCreated: 1510589271 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/TimeScale.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TimeScale : MonoBehaviour { 6 | 7 | public float timeScale = 100.0f; 8 | public float moreFixedTimeIterations = 1.0f; 9 | 10 | void Start () 11 | { 12 | Time.timeScale = timeScale; 13 | Time.fixedDeltaTime /= moreFixedTimeIterations; 14 | 15 | // if we increase number of FixedUpdate iterations, we can bump up the speed! 16 | foreach (var c in GameObject.FindObjectsOfType()) 17 | { 18 | c.runSpeed *= moreFixedTimeIterations; 19 | c.turnSpeed *= moreFixedTimeIterations; 20 | } 21 | 22 | foreach (var u in GameObject.FindObjectsOfType()) 23 | { 24 | u.decisionFrequency *= moreFixedTimeIterations; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/TimeScale.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d4a95f12a8c84de1ad709eff9bf441b 3 | timeCreated: 1510249319 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UtilityBase.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public abstract class UtilityBase : MonoBehaviour { 5 | 6 | public float priority = 1f; 7 | public float decisionFrequency = 10f; 8 | private double nextUpdate = 0f; 9 | private Vector2 memory = Vector2.zero; 10 | 11 | public Vector2 Control(float[] sensors) 12 | { 13 | Vector2 motors = Vector2.zero; 14 | 15 | int iterations = 0; 16 | nextUpdate -= (double)Time.fixedDeltaTime; 17 | while (nextUpdate < 0.0 && ++iterations <= 10) 18 | { 19 | nextUpdate += 1.0 / (double)decisionFrequency; 20 | motors += DoControl(sensors); 21 | } 22 | if (nextUpdate < 0) 23 | nextUpdate = 0; 24 | 25 | // if decisions were made => store in memory 26 | if (iterations > 0) 27 | memory = motors / iterations; 28 | 29 | // recall last control from memory 30 | return memory; 31 | } 32 | 33 | protected abstract Vector2 DoControl(float[] sensors); 34 | } 35 | -------------------------------------------------------------------------------- /Assets/UtilityBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4591d89d29d54480384610f048973eff 3 | timeCreated: 1509833745 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UtilityExternalControl.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class UtilityExternalControl : UtilityBase { 5 | 6 | void Start() {} 7 | 8 | protected override Vector2 DoControl(float[] sensors) 9 | { 10 | return new Vector2( 11 | Input.GetAxis("Horizontal"), // angular velocity 12 | Input.GetAxis("Vertical")); // forward velocity 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/UtilityExternalControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ab9a7e5e06734ba4bfd76fe19eb8036 3 | timeCreated: 1509833745 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UtilityRandomAttractor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Linq; 3 | 4 | public class UtilityRandomAttractor : UtilityBase 5 | { 6 | public float spawnAttractorWithin = 5f; 7 | 8 | private Vector3 attractor; 9 | private float bodyRadius; 10 | private float lastSensorSum = 0.0f; 11 | 12 | void Start() 13 | { 14 | attractor = transform.position; 15 | bodyRadius = GetComponent().bounds.extents.z; 16 | } 17 | 18 | protected override Vector2 DoControl(float[] sensors) 19 | { 20 | bool requestNewAttractor = false; 21 | var toAttractor = attractor - transform.position; 22 | if (toAttractor.magnitude < bodyRadius) // if reached attractor 23 | requestNewAttractor = true; 24 | 25 | // ALTERNATIVE: maybe better solution would be to check, if attractor is in the direction of the specific blocked sensor 26 | // but it requires to remember direction of the sensors 27 | 28 | if (sensors.Sum() > lastSensorSum) // if things are getting worse 29 | if (!requestNewAttractor && Vector3.Dot(Vector3.Normalize(toAttractor), transform.right) <= 0.1f) // and attractor is in front of us 30 | requestNewAttractor = true; // then attractor is most likely behind the wall, regenerate 31 | lastSensorSum = sensors.Sum(); 32 | 33 | if (requestNewAttractor) 34 | { 35 | do { 36 | var pos2d = Random.insideUnitCircle * Mathf.Max(spawnAttractorWithin, bodyRadius); 37 | toAttractor = new Vector3(pos2d.x, 0, pos2d.y); 38 | } while (toAttractor.magnitude < Mathf.Epsilon); 39 | attractor = transform.position + toAttractor; 40 | } 41 | 42 | var sharpenTurns = 3.0f; 43 | var inputX = Mathf.Clamp(Vector3.Dot(Vector3.Normalize(toAttractor), transform.right) * sharpenTurns, -1f, 1f); 44 | var inputY = Mathf.Clamp01(Mathf.Sqrt(Mathf.Max(0.0f, toAttractor.magnitude - bodyRadius * 0.5f))); // slow down when close to attractor 45 | 46 | return new Vector2( 47 | inputX, // angular velocity 48 | inputY); // forward velocity 49 | } 50 | 51 | void Update() 52 | { 53 | Debug.DrawLine(transform.position, attractor, Color.yellow, 0, false); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/UtilityRandomAttractor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5932c30aa778440dfa666b3fef72b586 3 | timeCreated: 1509833745 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UtilityRandomWalk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Linq; 3 | 4 | public class UtilityRandomWalk : UtilityBase { 5 | 6 | public float twitchiness = 0.7f; 7 | public bool turnAwayFromWalls = true; 8 | 9 | void Start() {} 10 | 11 | protected override Vector2 DoControl(float[] sensors) 12 | { 13 | var leftX = twitchiness; 14 | var rightX = twitchiness; 15 | 16 | // ALTERNATIVE: turnAwayFromWalls could be split into separte Utility 17 | // by bumping up priority to override other utilities 18 | if (turnAwayFromWalls) 19 | { 20 | var n = sensors.Length / 2; 21 | float l = sensors.Take(n).Reverse().Count(s => s < 0.1f); 22 | float r = sensors.Skip(n).Count(s => s < 0.1f); 23 | 24 | leftX = Mathf.Lerp(-1f, 1f, l / n); 25 | rightX = Mathf.Lerp(-1f, 1f, r / n); 26 | 27 | if (-leftX > rightX) 28 | { 29 | leftX = -1f; 30 | rightX = 1f; 31 | } 32 | } 33 | 34 | return new Vector2( 35 | Random.Range(-leftX, rightX), // angular velocity 36 | Random.Range(0, 1f)); // forward velocity 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/UtilityRandomWalk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ad00be10234842f7818dc1ae3437700 3 | timeCreated: 1509833745 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/square.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 8 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.4465934, g: 0.49642956, b: 0.5748249, a: 1} 42 | --- !u!157 &3 43 | LightmapSettings: 44 | m_ObjectHideFlags: 0 45 | serializedVersion: 11 46 | m_GIWorkflowMode: 0 47 | m_GISettings: 48 | serializedVersion: 2 49 | m_BounceScale: 1 50 | m_IndirectOutputScale: 1 51 | m_AlbedoBoost: 1 52 | m_TemporalCoherenceThreshold: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 0 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 9 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_TextureWidth: 1024 61 | m_TextureHeight: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 1 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_LightingDataAsset: {fileID: 0} 92 | m_UseShadowmask: 1 93 | --- !u!196 &4 94 | NavMeshSettings: 95 | serializedVersion: 2 96 | m_ObjectHideFlags: 0 97 | m_BuildSettings: 98 | serializedVersion: 2 99 | agentTypeID: 0 100 | agentRadius: 0.5 101 | agentHeight: 2 102 | agentSlope: 45 103 | agentClimb: 0.4 104 | ledgeDropHeight: 0 105 | maxJumpAcrossDistance: 0 106 | minRegionArea: 2 107 | manualCellSize: 0 108 | cellSize: 0.16666667 109 | manualTileSize: 0 110 | tileSize: 256 111 | accuratePlacement: 0 112 | m_NavMeshData: {fileID: 0} 113 | --- !u!1 &386504329 114 | GameObject: 115 | m_ObjectHideFlags: 0 116 | m_PrefabParentObject: {fileID: 0} 117 | m_PrefabInternal: {fileID: 0} 118 | serializedVersion: 5 119 | m_Component: 120 | - component: {fileID: 386504334} 121 | - component: {fileID: 386504333} 122 | - component: {fileID: 386504332} 123 | - component: {fileID: 386504331} 124 | - component: {fileID: 386504330} 125 | m_Layer: 0 126 | m_Name: Main Camera 127 | m_TagString: MainCamera 128 | m_Icon: {fileID: 0} 129 | m_NavMeshLayer: 0 130 | m_StaticEditorFlags: 0 131 | m_IsActive: 1 132 | --- !u!81 &386504330 133 | AudioListener: 134 | m_ObjectHideFlags: 0 135 | m_PrefabParentObject: {fileID: 0} 136 | m_PrefabInternal: {fileID: 0} 137 | m_GameObject: {fileID: 386504329} 138 | m_Enabled: 1 139 | --- !u!124 &386504331 140 | Behaviour: 141 | m_ObjectHideFlags: 0 142 | m_PrefabParentObject: {fileID: 0} 143 | m_PrefabInternal: {fileID: 0} 144 | m_GameObject: {fileID: 386504329} 145 | m_Enabled: 1 146 | --- !u!92 &386504332 147 | Behaviour: 148 | m_ObjectHideFlags: 0 149 | m_PrefabParentObject: {fileID: 0} 150 | m_PrefabInternal: {fileID: 0} 151 | m_GameObject: {fileID: 386504329} 152 | m_Enabled: 1 153 | --- !u!20 &386504333 154 | Camera: 155 | m_ObjectHideFlags: 0 156 | m_PrefabParentObject: {fileID: 0} 157 | m_PrefabInternal: {fileID: 0} 158 | m_GameObject: {fileID: 386504329} 159 | m_Enabled: 1 160 | serializedVersion: 2 161 | m_ClearFlags: 1 162 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 163 | m_NormalizedViewPortRect: 164 | serializedVersion: 2 165 | x: 0 166 | y: 0 167 | width: 1 168 | height: 1 169 | near clip plane: 0.3 170 | far clip plane: 1000 171 | field of view: 60 172 | orthographic: 0 173 | orthographic size: 5 174 | m_Depth: -1 175 | m_CullingMask: 176 | serializedVersion: 2 177 | m_Bits: 4294967295 178 | m_RenderingPath: -1 179 | m_TargetTexture: {fileID: 0} 180 | m_TargetDisplay: 0 181 | m_TargetEye: 3 182 | m_HDR: 0 183 | m_AllowMSAA: 0 184 | m_ForceIntoRT: 0 185 | m_OcclusionCulling: 1 186 | m_StereoConvergence: 10 187 | m_StereoSeparation: 0.022 188 | m_StereoMirrorMode: 0 189 | --- !u!4 &386504334 190 | Transform: 191 | m_ObjectHideFlags: 0 192 | m_PrefabParentObject: {fileID: 0} 193 | m_PrefabInternal: {fileID: 0} 194 | m_GameObject: {fileID: 386504329} 195 | m_LocalRotation: {x: 0.5, y: -0.5, z: 0.5, w: 0.5} 196 | m_LocalPosition: {x: 0, y: 10, z: 0} 197 | m_LocalScale: {x: 1, y: 1, z: 1} 198 | m_Children: [] 199 | m_Father: {fileID: 0} 200 | m_RootOrder: 0 201 | m_LocalEulerAnglesHint: {x: 90, y: -90, z: 0} 202 | --- !u!114 &862891177 203 | MonoBehaviour: 204 | m_ObjectHideFlags: 0 205 | m_PrefabParentObject: {fileID: 0} 206 | m_PrefabInternal: {fileID: 0} 207 | m_GameObject: {fileID: 0} 208 | m_Enabled: 1 209 | m_EditorHideFlags: 0 210 | m_Script: {fileID: 11500000, guid: 35813a1be64e144f887d7d5f15b963fa, type: 3} 211 | m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone) 212 | m_EditorClassIdentifier: 213 | brain: {fileID: 1712573271} 214 | --- !u!1 &1004586088 215 | GameObject: 216 | m_ObjectHideFlags: 0 217 | m_PrefabParentObject: {fileID: 0} 218 | m_PrefabInternal: {fileID: 0} 219 | serializedVersion: 5 220 | m_Component: 221 | - component: {fileID: 1004586090} 222 | - component: {fileID: 1004586089} 223 | m_Layer: 0 224 | m_Name: Directional Light 225 | m_TagString: Untagged 226 | m_Icon: {fileID: 0} 227 | m_NavMeshLayer: 0 228 | m_StaticEditorFlags: 0 229 | m_IsActive: 1 230 | --- !u!108 &1004586089 231 | Light: 232 | m_ObjectHideFlags: 0 233 | m_PrefabParentObject: {fileID: 0} 234 | m_PrefabInternal: {fileID: 0} 235 | m_GameObject: {fileID: 1004586088} 236 | m_Enabled: 1 237 | serializedVersion: 8 238 | m_Type: 1 239 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 240 | m_Intensity: 1 241 | m_Range: 10 242 | m_SpotAngle: 30 243 | m_CookieSize: 10 244 | m_Shadows: 245 | m_Type: 2 246 | m_Resolution: -1 247 | m_CustomResolution: -1 248 | m_Strength: 1 249 | m_Bias: 0.05 250 | m_NormalBias: 0.4 251 | m_NearPlane: 0.2 252 | m_Cookie: {fileID: 0} 253 | m_DrawHalo: 0 254 | m_Flare: {fileID: 0} 255 | m_RenderMode: 0 256 | m_CullingMask: 257 | serializedVersion: 2 258 | m_Bits: 4294967295 259 | m_Lightmapping: 4 260 | m_AreaSize: {x: 1, y: 1} 261 | m_BounceIntensity: 1 262 | m_ColorTemperature: 6570 263 | m_UseColorTemperature: 0 264 | m_ShadowRadius: 0 265 | m_ShadowAngle: 0 266 | --- !u!4 &1004586090 267 | Transform: 268 | m_ObjectHideFlags: 0 269 | m_PrefabParentObject: {fileID: 0} 270 | m_PrefabInternal: {fileID: 0} 271 | m_GameObject: {fileID: 1004586088} 272 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 273 | m_LocalPosition: {x: 0, y: 3, z: 0} 274 | m_LocalScale: {x: 1, y: 1, z: 1} 275 | m_Children: [] 276 | m_Father: {fileID: 0} 277 | m_RootOrder: 1 278 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 279 | --- !u!1001 &1205731092 280 | Prefab: 281 | m_ObjectHideFlags: 0 282 | serializedVersion: 2 283 | m_Modification: 284 | m_TransformParent: {fileID: 0} 285 | m_Modifications: 286 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 287 | propertyPath: m_LocalPosition.x 288 | value: 0 289 | objectReference: {fileID: 0} 290 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 291 | propertyPath: m_LocalPosition.y 292 | value: 0 293 | objectReference: {fileID: 0} 294 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 295 | propertyPath: m_LocalPosition.z 296 | value: 0 297 | objectReference: {fileID: 0} 298 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 299 | propertyPath: m_LocalRotation.x 300 | value: 0 301 | objectReference: {fileID: 0} 302 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 303 | propertyPath: m_LocalRotation.y 304 | value: 0 305 | objectReference: {fileID: 0} 306 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 307 | propertyPath: m_LocalRotation.z 308 | value: 0 309 | objectReference: {fileID: 0} 310 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 311 | propertyPath: m_LocalRotation.w 312 | value: 1 313 | objectReference: {fileID: 0} 314 | - target: {fileID: 4269421212497686, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 315 | propertyPath: m_RootOrder 316 | value: 4 317 | objectReference: {fileID: 0} 318 | m_RemovedComponents: [] 319 | m_ParentPrefab: {fileID: 100100000, guid: b647a3dd883944b1bab0e34e1b9199b9, type: 2} 320 | m_IsPrefabParent: 0 321 | --- !u!114 &1376321955 322 | MonoBehaviour: 323 | m_ObjectHideFlags: 0 324 | m_PrefabParentObject: {fileID: 0} 325 | m_PrefabInternal: {fileID: 0} 326 | m_GameObject: {fileID: 0} 327 | m_Enabled: 1 328 | m_EditorHideFlags: 0 329 | m_Script: {fileID: 11500000, guid: 943466ab374444748a364f9d6c3e2fe2, type: 3} 330 | m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone) 331 | m_EditorClassIdentifier: 332 | broadcast: 1 333 | brain: {fileID: 1712573271} 334 | --- !u!1001 &1446693703 335 | Prefab: 336 | m_ObjectHideFlags: 0 337 | serializedVersion: 2 338 | m_Modification: 339 | m_TransformParent: {fileID: 0} 340 | m_Modifications: 341 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 342 | propertyPath: m_LocalPosition.x 343 | value: 0 344 | objectReference: {fileID: 0} 345 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 346 | propertyPath: m_LocalPosition.y 347 | value: 0 348 | objectReference: {fileID: 0} 349 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 350 | propertyPath: m_LocalPosition.z 351 | value: 0 352 | objectReference: {fileID: 0} 353 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 354 | propertyPath: m_LocalRotation.x 355 | value: 0 356 | objectReference: {fileID: 0} 357 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 358 | propertyPath: m_LocalRotation.y 359 | value: -0.7071068 360 | objectReference: {fileID: 0} 361 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 362 | propertyPath: m_LocalRotation.z 363 | value: 0 364 | objectReference: {fileID: 0} 365 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 366 | propertyPath: m_LocalRotation.w 367 | value: 0.7071068 368 | objectReference: {fileID: 0} 369 | - target: {fileID: 4301059290638488, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 370 | propertyPath: m_RootOrder 371 | value: 2 372 | objectReference: {fileID: 0} 373 | - target: {fileID: 114563177563919976, guid: e38b21fa0bae44385ab88541569f6d73, 374 | type: 2} 375 | propertyPath: brain 376 | value: 377 | objectReference: {fileID: 1712573271} 378 | m_RemovedComponents: [] 379 | m_ParentPrefab: {fileID: 100100000, guid: e38b21fa0bae44385ab88541569f6d73, type: 2} 380 | m_IsPrefabParent: 0 381 | --- !u!1 &1712573269 382 | GameObject: 383 | m_ObjectHideFlags: 0 384 | m_PrefabParentObject: {fileID: 0} 385 | m_PrefabInternal: {fileID: 0} 386 | serializedVersion: 5 387 | m_Component: 388 | - component: {fileID: 1712573270} 389 | - component: {fileID: 1712573271} 390 | - component: {fileID: 1712573272} 391 | m_Layer: 0 392 | m_Name: Brain 393 | m_TagString: Untagged 394 | m_Icon: {fileID: 0} 395 | m_NavMeshLayer: 0 396 | m_StaticEditorFlags: 0 397 | m_IsActive: 1 398 | --- !u!4 &1712573270 399 | Transform: 400 | m_ObjectHideFlags: 0 401 | m_PrefabParentObject: {fileID: 0} 402 | m_PrefabInternal: {fileID: 0} 403 | m_GameObject: {fileID: 1712573269} 404 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 405 | m_LocalPosition: {x: 0, y: 0, z: 0} 406 | m_LocalScale: {x: 1, y: 1, z: 1} 407 | m_Children: [] 408 | m_Father: {fileID: 1981480331} 409 | m_RootOrder: 0 410 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 411 | --- !u!114 &1712573271 412 | MonoBehaviour: 413 | m_ObjectHideFlags: 0 414 | m_PrefabParentObject: {fileID: 0} 415 | m_PrefabInternal: {fileID: 0} 416 | m_GameObject: {fileID: 1712573269} 417 | m_Enabled: 1 418 | m_EditorHideFlags: 0 419 | m_Script: {fileID: 11500000, guid: c676a8ddf5a5f4f64b35e9ed5028679d, type: 3} 420 | m_Name: 421 | m_EditorClassIdentifier: 422 | brainParameters: 423 | stateSize: 10 424 | actionSize: 1 425 | memorySize: 0 426 | cameraResolutions: [] 427 | actionDescriptions: 428 | - 429 | actionSpaceType: 1 430 | stateSpaceType: 1 431 | brainType: 1 432 | CoreBrains: 433 | - {fileID: 2041855987} 434 | - {fileID: 1376321955} 435 | - {fileID: 862891177} 436 | instanceID: 10370 437 | --- !u!114 &1712573272 438 | MonoBehaviour: 439 | m_ObjectHideFlags: 0 440 | m_PrefabParentObject: {fileID: 0} 441 | m_PrefabInternal: {fileID: 0} 442 | m_GameObject: {fileID: 1712573269} 443 | m_Enabled: 1 444 | m_EditorHideFlags: 0 445 | m_Script: {fileID: 11500000, guid: 65c8216d5b390411faa4bc269741aa21, type: 3} 446 | m_Name: 447 | m_EditorClassIdentifier: 448 | --- !u!1 &1981480329 449 | GameObject: 450 | m_ObjectHideFlags: 0 451 | m_PrefabParentObject: {fileID: 0} 452 | m_PrefabInternal: {fileID: 0} 453 | serializedVersion: 5 454 | m_Component: 455 | - component: {fileID: 1981480331} 456 | - component: {fileID: 1981480330} 457 | m_Layer: 0 458 | m_Name: Academy 459 | m_TagString: Untagged 460 | m_Icon: {fileID: 0} 461 | m_NavMeshLayer: 0 462 | m_StaticEditorFlags: 0 463 | m_IsActive: 1 464 | --- !u!114 &1981480330 465 | MonoBehaviour: 466 | m_ObjectHideFlags: 0 467 | m_PrefabParentObject: {fileID: 0} 468 | m_PrefabInternal: {fileID: 0} 469 | m_GameObject: {fileID: 1981480329} 470 | m_Enabled: 1 471 | m_EditorHideFlags: 0 472 | m_Script: {fileID: 11500000, guid: 98650fde2e20244a0b8868be89c0b0fd, type: 3} 473 | m_Name: 474 | m_EditorClassIdentifier: 475 | maxSteps: 0 476 | frameToSkip: 0 477 | waitTime: 0 478 | isInference: 1 479 | trainingConfiguration: 480 | width: 32 481 | height: 32 482 | qualityLevel: 1 483 | timeScale: 100 484 | targetFrameRate: -1 485 | inferenceConfiguration: 486 | width: 1280 487 | height: 720 488 | qualityLevel: 5 489 | timeScale: 1 490 | targetFrameRate: 60 491 | defaultResetParameters: 492 | - key: ep_length 493 | value: 500 494 | - key: start_area_extents 495 | value: 0 496 | done: 0 497 | episodeCount: 1 498 | currentStep: 0 499 | --- !u!4 &1981480331 500 | Transform: 501 | m_ObjectHideFlags: 0 502 | m_PrefabParentObject: {fileID: 0} 503 | m_PrefabInternal: {fileID: 0} 504 | m_GameObject: {fileID: 1981480329} 505 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 506 | m_LocalPosition: {x: -0.97186565, y: 0.68400264, z: 0.6364465} 507 | m_LocalScale: {x: 1, y: 1, z: 1} 508 | m_Children: 509 | - {fileID: 1712573270} 510 | m_Father: {fileID: 0} 511 | m_RootOrder: 3 512 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 513 | --- !u!114 &2041855987 514 | MonoBehaviour: 515 | m_ObjectHideFlags: 0 516 | m_PrefabParentObject: {fileID: 0} 517 | m_PrefabInternal: {fileID: 0} 518 | m_GameObject: {fileID: 0} 519 | m_Enabled: 1 520 | m_EditorHideFlags: 0 521 | m_Script: {fileID: 11500000, guid: 41e9bda8f3cf1492fa74926a530f6f70, type: 3} 522 | m_Name: (Clone)(Clone)(Clone)(Clone)(Clone)(Clone) 523 | m_EditorClassIdentifier: 524 | broadcast: 1 525 | continuousPlayerActions: [] 526 | discretePlayerActions: [] 527 | defaultAction: 0 528 | brain: {fileID: 1712573271} 529 | -------------------------------------------------------------------------------- /Assets/square.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcfd5d825a9a54b29b0177fe984a00b5 3 | timeCreated: 1509836151 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_EnablePCM: 1 18 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 19 | m_AutoSimulation: 1 20 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_DefaultBehaviorMode: 0 10 | m_SpritePackerMode: 0 11 | m_SpritePackerPaddingPower: 1 12 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 13 | m_ProjectGenerationRootNamespace: 14 | m_UserGeneratedProjectSuffix: 15 | m_CollabEditorSettings: 16 | inProgressEnabled: 1 17 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} 40 | m_PreloadedShaders: [] 41 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 42 | type: 0} 43 | m_CustomRenderPipeline: {fileID: 0} 44 | m_TransparencySortMode: 0 45 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 46 | m_DefaultRenderingPath: 1 47 | m_DefaultMobileRenderingPath: 1 48 | m_TierSettings: [] 49 | m_LightmapStripping: 0 50 | m_FogStripping: 0 51 | m_InstancingStripping: 0 52 | m_LightmapKeepPlain: 1 53 | m_LightmapKeepDirCombined: 1 54 | m_LightmapKeepDynamicPlain: 1 55 | m_LightmapKeepDynamicDirCombined: 1 56 | m_LightmapKeepShadowMask: 1 57 | m_LightmapKeepSubtractive: 1 58 | m_FogKeepLinear: 1 59 | m_FogKeepExp: 1 60 | m_FogKeepExp2: 1 61 | m_AlbedoSwatchInfos: [] 62 | m_LightsUseLinearIntensity: 0 63 | m_LightsUseColorTemperature: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | m_SettingNames: 89 | - Humanoid 90 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AlwaysShowColliders: 0 28 | m_ShowColliderSleep: 1 29 | m_ShowColliderContacts: 0 30 | m_ShowColliderAABB: 0 31 | m_ContactArrowScale: 0.2 32 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 33 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 34 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 35 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 36 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 37 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.1.2p2 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 1 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 1 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 2 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 1 108 | antiAliasing: 0 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 1 112 | billboardsFaceCameraPosition: 1 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 2 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 70 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 2 136 | antiAliasing: 2 137 | softParticles: 1 138 | softVegetation: 1 139 | realtimeReflectionProbes: 1 140 | billboardsFaceCameraPosition: 1 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSM: 5 183 | PSP2: 2 184 | Samsung TV: 2 185 | Standalone: 5 186 | Tizen: 2 187 | Web: 5 188 | WebGL: 3 189 | WiiU: 5 190 | Windows Store Apps: 5 191 | XboxOne: 5 192 | iPhone: 2 193 | tvOS: 2 194 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: 7 | - Maze 8 | layers: 9 | - Default 10 | - TransparentFX 11 | - Ignore Raycast 12 | - 13 | - Water 14 | - UI 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | - 41 | m_SortingLayers: 42 | - name: Default 43 | uniqueID: 0 44 | locked: 0 45 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_Enabled: 0 14 | m_CaptureEditorExceptions: 1 15 | UnityPurchasingSettings: 16 | m_Enabled: 0 17 | m_TestMode: 0 18 | UnityAnalyticsSettings: 19 | m_Enabled: 0 20 | m_InitializeOnStartup: 1 21 | m_TestMode: 0 22 | m_TestEventUrl: 23 | m_TestConfigUrl: 24 | UnityAdsSettings: 25 | m_Enabled: 0 26 | m_InitializeOnStartup: 1 27 | m_TestMode: 0 28 | m_EnabledPlatforms: 4294967295 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rat-rnn 2 | Simulate Rat neural activity in the maze 3 | 4 | Attempt to re-produce results from [ICLR2018: EMERGENCE OF GRID-LIKE REPRESENTATIONS BY TRAINING RECURRENT NEURAL NETWORKS TO PERFORM SPATIAL LOCALIZATION](https://openreview.net/pdf?id=B17JTOe0-) paper. 5 | 6 | 7 | Results so far. Training with LSTM or CTRNN gives comparable results. 8 | 9 | Below are LSTM results after training for 10000 iterations on 1 millions sampless: 10 | * Rat did learn spatial localization (dead reckoning) task well 11 | * Rat performs well under significant noise injected into the network 12 | * However NO grid cells formed in the process :( 13 | 14 | ![paths](images/lstm_paths.png "Dead reckoning results after training for 10000 iterations") 15 | ![paths](images/lstm_neuron_activation.png "Neuron activation after training for 10000 iterations") 16 | ![loss](images/lstm_loss.png "Loss after 10000 iterations") 17 | -------------------------------------------------------------------------------- /images/lstm_loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/rat-rnn/e0e03f6f990fe9eafaaaf8433cd1e164b1b27e7a/images/lstm_loss.png -------------------------------------------------------------------------------- /images/lstm_neuron_activation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/rat-rnn/e0e03f6f990fe9eafaaaf8433cd1e164b1b27e7a/images/lstm_neuron_activation.png -------------------------------------------------------------------------------- /images/lstm_paths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/rat-rnn/e0e03f6f990fe9eafaaaf8433cd1e164b1b27e7a/images/lstm_paths.png -------------------------------------------------------------------------------- /rat_data/data.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/rat-rnn/e0e03f6f990fe9eafaaaf8433cd1e164b1b27e7a/rat_data/data.p -------------------------------------------------------------------------------- /rat_data_rnd/data.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/rat-rnn/e0e03f6f990fe9eafaaaf8433cd1e164b1b27e7a/rat_data_rnd/data.p -------------------------------------------------------------------------------- /unityagents/__init__.py: -------------------------------------------------------------------------------- 1 | from .environment import * 2 | from .brain import * 3 | from .exception import * 4 | from .curriculum import * 5 | -------------------------------------------------------------------------------- /unityagents/brain.py: -------------------------------------------------------------------------------- 1 | class BrainInfo: 2 | def __init__(self, observation, state, memory=None, reward=None, agents=None, local_done=None, action =None): 3 | """ 4 | Describes experience at current step of all agents linked to a brain. 5 | """ 6 | self.observations = observation 7 | self.states = state 8 | self.memories = memory 9 | self.rewards = reward 10 | self.local_done = local_done 11 | self.agents = agents 12 | self.actions = action 13 | 14 | 15 | class BrainParameters: 16 | def __init__(self, brain_name, brain_param): 17 | """ 18 | Contains all brain-specific parameters. 19 | :param brain_name: Name of brain. 20 | :param brain_param: Dictionary of brain parameters. 21 | """ 22 | self.brain_name = brain_name 23 | self.state_space_size = brain_param["stateSize"] 24 | self.number_observations = len(brain_param["cameraResolutions"]) 25 | self.camera_resolutions = brain_param["cameraResolutions"] 26 | self.action_space_size = brain_param["actionSize"] 27 | self.memory_space_size = brain_param["memorySize"] 28 | self.action_descriptions = brain_param["actionDescriptions"] 29 | self.action_space_type = ["discrete", "continuous"][brain_param["actionSpaceType"]] 30 | self.state_space_type = ["discrete", "continuous"][brain_param["stateSpaceType"]] 31 | 32 | def __str__(self): 33 | return '''Unity brain name: {0} 34 | Number of observations (per agent): {1} 35 | State space type: {2} 36 | State space size (per agent): {3} 37 | Action space type: {4} 38 | Action space size (per agent): {5} 39 | Memory space size (per agent): {6} 40 | Action descriptions: {7}'''.format(self.brain_name, 41 | str(self.number_observations), self.state_space_type, 42 | str(self.state_space_size), self.action_space_type, 43 | str(self.action_space_size), 44 | str(self.memory_space_size), 45 | ', '.join(self.action_descriptions)) 46 | -------------------------------------------------------------------------------- /unityagents/curriculum.py: -------------------------------------------------------------------------------- 1 | import json 2 | import numpy as np 3 | 4 | from .exception import UnityEnvironmentException 5 | 6 | 7 | class Curriculum(object): 8 | def __init__(self, location, default_reset_parameters): 9 | """ 10 | Initializes a Curriculum object. 11 | :param location: Path to JSON defining curriculum. 12 | :param default_reset_parameters: Set of reset parameters for environment. 13 | """ 14 | self.lesson_number = 0 15 | self.lesson_length = 0 16 | self.measure_type = None 17 | if location is None: 18 | self.data = None 19 | else: 20 | try: 21 | with open(location) as data_file: 22 | self.data = json.load(data_file) 23 | except FileNotFoundError: 24 | raise UnityEnvironmentException( 25 | "The file {0} could not be found.".format(location)) 26 | except UnicodeDecodeError: 27 | raise UnityEnvironmentException("There was an error decoding {}".format(location)) 28 | self.smoothing_value = 0 29 | for key in ['parameters', 'measure', 'thresholds', 30 | 'min_lesson_length', 'signal_smoothing']: 31 | if key not in self.data: 32 | raise UnityEnvironmentException("{0} does not contain a " 33 | "{1} field.".format(location, key)) 34 | parameters = self.data['parameters'] 35 | self.measure_type = self.data['measure'] 36 | self.max_lesson_number = len(self.data['thresholds']) 37 | for key in parameters: 38 | if key not in default_reset_parameters: 39 | raise UnityEnvironmentException( 40 | "The parameter {0} in Curriculum {1} is not present in " 41 | "the Environment".format(key, location)) 42 | for key in parameters: 43 | if len(parameters[key]) != self.max_lesson_number + 1: 44 | raise UnityEnvironmentException( 45 | "The parameter {0} in Curriculum {1} must have {2} values " 46 | "but {3} were found".format(key, location, 47 | self.max_lesson_number + 1, len(parameters[key]))) 48 | 49 | @property 50 | def measure(self): 51 | return self.measure_type 52 | 53 | def get_lesson_number(self): 54 | return self.lesson_number 55 | 56 | def set_lesson_number(self, value): 57 | self.lesson_length = 0 58 | self.lesson_number = max(0, min(value, self.max_lesson_number)) 59 | 60 | def get_lesson(self, progress): 61 | """ 62 | Returns reset parameters which correspond to current lesson. 63 | :param progress: Measure of progress (either reward or percentage steps completed). 64 | :return: Dictionary containing reset parameters. 65 | """ 66 | if self.data is None or progress is None: 67 | return {} 68 | if self.data["signal_smoothing"]: 69 | progress = self.smoothing_value * 0.1 + 0.9 * progress 70 | self.smoothing_value = progress 71 | self.lesson_length += 1 72 | if self.lesson_number < self.max_lesson_number: 73 | if ((progress > self.data['thresholds'][self.lesson_number]) and 74 | (self.lesson_length > self.data['min_lesson_length'])): 75 | self.lesson_length = 0 76 | self.lesson_number += 1 77 | config = {} 78 | parameters = self.data["parameters"] 79 | for key in parameters: 80 | config[key] = parameters[key][self.lesson_number] 81 | return config 82 | -------------------------------------------------------------------------------- /unityagents/exception.py: -------------------------------------------------------------------------------- 1 | class UnityEnvironmentException(Exception): 2 | """ 3 | Related to errors starting and closing environment. 4 | """ 5 | pass 6 | 7 | 8 | class UnityActionException(Exception): 9 | """ 10 | Related to errors with sending actions. 11 | """ 12 | pass 13 | --------------------------------------------------------------------------------