vincentpierre
7 年前
当前提交
7bcbe871
共有 48 个文件被更改,包括 5201 次插入 和 0 次删除
-
9unity-environment/Assets/ML-Agents/Examples/Drone.meta
-
9unity-environment/Assets/ML-Agents/Examples/Spider.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Drone/Drone.unity
-
8unity-environment/Assets/ML-Agents/Examples/Drone/Drone.unity.meta
-
9unity-environment/Assets/ML-Agents/Examples/Drone/Resources.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Drone/Resources/DroneAndTarget.prefab
-
9unity-environment/Assets/ML-Agents/Examples/Drone/Resources/DroneAndTarget.prefab.meta
-
9unity-environment/Assets/ML-Agents/Examples/Drone/Scripts.meta
-
18unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/DroneAcademy.cs
-
12unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/DroneAcademy.cs.meta
-
161unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/DroneAgent.cs
-
12unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/DroneAgent.cs.meta
-
23unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/DroneEngine.cs
-
12unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/DroneEngine.cs.meta
-
36unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/RandomDecision.cs
-
12unity-environment/Assets/ML-Agents/Examples/Drone/Scripts/RandomDecision.cs.meta
-
9unity-environment/Assets/ML-Agents/Examples/Drone/TFModels.meta
-
157unity-environment/Assets/ML-Agents/Examples/Drone/TFModels/drone.bytes
-
8unity-environment/Assets/ML-Agents/Examples/Drone/TFModels/drone.bytes.meta
-
9unity-environment/Assets/ML-Agents/Examples/Spider/Resources.meta
-
76unity-environment/Assets/ML-Agents/Examples/Spider/Resources/Checker.mat
-
9unity-environment/Assets/ML-Agents/Examples/Spider/Resources/Checker.mat.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Spider/Resources/Spider.prefab
-
9unity-environment/Assets/ML-Agents/Examples/Spider/Resources/Spider.prefab.meta
-
9unity-environment/Assets/ML-Agents/Examples/Spider/Scripts.meta
-
19unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/CameraFollow.cs
-
12unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/CameraFollow.cs.meta
-
19unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderAcademy.cs
-
12unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderAcademy.cs.meta
-
249unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderAgentConfigurable.cs
-
12unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderAgentConfigurable.cs.meta
-
19unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderBodyContact.cs
-
12unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderBodyContact.cs.meta
-
21unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderLegContact.cs
-
12unity-environment/Assets/ML-Agents/Examples/Spider/Scripts/SpiderLegContact.cs.meta
-
9unity-environment/Assets/ML-Agents/Examples/Spider/TFModels.meta
-
253unity-environment/Assets/ML-Agents/Examples/Spider/TFModels/spider.bytes
-
8unity-environment/Assets/ML-Agents/Examples/Spider/TFModels/spider.bytes.meta
-
908unity-environment/Assets/ML-Agents/Examples/Spider/spider.unity
-
8unity-environment/Assets/ML-Agents/Examples/Spider/spider.unity.meta
|
|||
fileFormatVersion: 2 |
|||
guid: c0b10575a57c74679ae18b844a412e0b |
|||
folderAsset: yes |
|||
timeCreated: 1509574928 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0efc731e39fd04495bee94884abad038 |
|||
folderAsset: yes |
|||
timeCreated: 1509574928 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Drone/Drone.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 32e3a6aea0c9d40ab8f537d159393543 |
|||
timeCreated: 1509051376 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 33b484619864e41c4bc44a8be9f6df69 |
|||
folderAsset: yes |
|||
timeCreated: 1509237691 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Drone/Resources/DroneAndTarget.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: ec0359cba4f134f9f9b326d811c9f167 |
|||
timeCreated: 1509055921 |
|||
licenseType: Free |
|||
NativeFormatImporter: |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: a11635cdfc0774675b6872705a0be574 |
|||
folderAsset: yes |
|||
timeCreated: 1509051365 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class DroneAcademy : Academy { |
|||
|
|||
public override void AcademyReset() |
|||
{ |
|||
|
|||
|
|||
} |
|||
|
|||
public override void AcademyStep() |
|||
{ |
|||
|
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9f2554dba3c7f4de0a0534b1650d462b |
|||
timeCreated: 1509054426 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class DroneAgent : Agent { |
|||
[Header("Specific to Drone")] |
|||
Transform body; |
|||
Rigidbody rb; |
|||
public Transform target; |
|||
|
|||
public DroneEngine[] engines; |
|||
public float maxPower = 30; |
|||
public DroneAcademy aca; |
|||
|
|||
|
|||
float[] pastValues; |
|||
Dictionary<GameObject, Vector3> transformsPosition; |
|||
Dictionary<GameObject, Quaternion> transformsRotation; |
|||
|
|||
public override void InitializeAgent() |
|||
{ |
|||
body = gameObject.transform.Find("Body"); |
|||
rb = body.gameObject.GetComponent<Rigidbody>(); |
|||
pastValues = new float[6]; |
|||
transformsPosition = new Dictionary<GameObject, Vector3> (); |
|||
transformsRotation = new Dictionary<GameObject, Quaternion> (); |
|||
Transform[] allChildren = GetComponentsInChildren<Transform>(); |
|||
foreach (Transform child in allChildren) { |
|||
transformsPosition [child.gameObject] = child.position; |
|||
transformsRotation [child.gameObject] = child.rotation; |
|||
} |
|||
foreach (DroneEngine e in engines) |
|||
{ |
|||
e.maxPower = maxPower; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
public override List<float> CollectState() |
|||
{ |
|||
List<float> state = new List<float>(); |
|||
|
|||
state.Add(body.position.x - target.position.x); |
|||
state.Add(body.position.y - target.position.y); |
|||
state.Add(body.position.z - target.position.z); |
|||
// state.Add(body.rotation.x);
|
|||
// state.Add(body.rotation.y);
|
|||
// state.Add(body.rotation.z);
|
|||
// state.Add(body.rotation.w);
|
|||
Vector3 rot = body.rotation.eulerAngles; |
|||
state.Add((rot.x+180)%360-180f); |
|||
state.Add((rot.y+180)%360-180f); |
|||
state.Add((rot.z+180)%360-180f); |
|||
state.Add(body.forward.x); |
|||
state.Add(body.forward.y); |
|||
state.Add(body.forward.z); |
|||
state.Add(body.right.x); |
|||
state.Add(body.right.y); |
|||
state.Add(body.right.z); |
|||
|
|||
state.Add(rb.velocity.x); |
|||
state.Add(rb.velocity.y); |
|||
state.Add(rb.velocity.z); |
|||
|
|||
Vector3 angularVel = rb.angularVelocity; |
|||
angularVel.x = ((angularVel.x + 180) % 360 - 180f); |
|||
angularVel.y = ((angularVel.y + 180) % 360 - 180f); |
|||
angularVel.z = ((angularVel.z + 180) % 360 - 180f); |
|||
state.Add(angularVel.x); |
|||
state.Add(angularVel.y); |
|||
state.Add(angularVel.z); |
|||
|
|||
state.Add((rb.velocity.x - pastValues[0]) / Time.fixedDeltaTime); |
|||
pastValues[0] = rb.velocity.x; |
|||
state.Add((rb.velocity.y - pastValues[1]) / Time.fixedDeltaTime); |
|||
pastValues[1] = rb.velocity.y; |
|||
state.Add((rb.velocity.z - pastValues[2]) / Time.fixedDeltaTime); |
|||
pastValues[2] = rb.velocity.z; |
|||
|
|||
state.Add((angularVel.x - pastValues[3]) / Time.fixedDeltaTime); |
|||
pastValues[3] = angularVel.x; |
|||
state.Add((angularVel.y - pastValues[4]) / Time.fixedDeltaTime); |
|||
pastValues[4] = angularVel.y; |
|||
state.Add((angularVel.z - pastValues[5]) / Time.fixedDeltaTime); |
|||
pastValues[5] = angularVel.z; |
|||
|
|||
// state.Add(target.position.x - body.position.x);
|
|||
// state.Add(target.position.y - body.position.y);
|
|||
// state.Add(target.position.z - body.position.z);
|
|||
|
|||
return state; |
|||
} |
|||
|
|||
public override void AgentStep(float[] act) |
|||
{ |
|||
Monitor.Log("Action", act, MonitorType.bar, body); |
|||
|
|||
for(int i = 0; i<4 ; i++) |
|||
{ |
|||
act[i] = Mathf.Max(-1f, Mathf.Min(act[i], 1f)); |
|||
} |
|||
|
|||
for(int i = 0; i<4 ; i++) |
|||
{ |
|||
engines[i].powerMultiplier = act[i]; |
|||
} |
|||
if ((target.position - body.position).magnitude > 100f) |
|||
{ |
|||
done = true; |
|||
reward = -1f; |
|||
} |
|||
else if ((target.position - body.position).magnitude < aca.resetParameters["targetSize"]) |
|||
{ |
|||
// done = true;
|
|||
reward = 1f; |
|||
} |
|||
|
|||
else |
|||
{ |
|||
// reward = Mathf.Exp(-(target.position - body.position).magnitude / 10f);
|
|||
float thrustPenalty = act[0]*act[0] + act[1]*act[1] + act[2]*act[2] +act[3]*act[3]; |
|||
reward = (0f |
|||
// + (100f - (target.position - body.position).magnitude) / 100f
|
|||
+Mathf.Exp(-(target.position - body.position).magnitude / 10f) / 2f |
|||
// + Mathf.Max(-1f, Mathf.Min(Vector3.Dot(rb.velocity, (target.position - body.position).normalized)/100f, 1f))
|
|||
// - Mathf.Max(rb.velocity.magnitude - 2f, 0f)
|
|||
// -0.01f * thrustPenalty
|
|||
// +0.01f* Vector3.Dot(body.up, new Vector3(0,1,0))
|
|||
); |
|||
} |
|||
Monitor.Log(gameObject.transform.parent.gameObject.name, reward, MonitorType.slider); |
|||
Monitor.Log("Reward", reward, MonitorType.slider, body); |
|||
|
|||
} |
|||
|
|||
public override void AgentReset() |
|||
{ |
|||
Transform[] allChildren = GetComponentsInChildren<Transform>(); |
|||
foreach (Transform child in allChildren) { |
|||
if ((child.gameObject.name.Contains("Drone")) |
|||
) |
|||
{ |
|||
continue; |
|||
} |
|||
child.position = transformsPosition [child.gameObject]; |
|||
child.rotation = transformsRotation [child.gameObject]; |
|||
child.gameObject.GetComponent<Rigidbody> ().velocity = default(Vector3); |
|||
child.gameObject.GetComponent<Rigidbody> ().angularVelocity = default(Vector3); |
|||
} |
|||
target.position = new Vector3(Random.value * 2 - 1, Random.value * 2 - 1, Random.value * 2 - 1) * 20; |
|||
target.localScale = new Vector3(1, 1, 1) * 2 * aca.resetParameters["targetSize"]; |
|||
|
|||
} |
|||
|
|||
public override void AgentOnDone() |
|||
{ |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6fb2aa0f3450d4721a1abc32f62525c4 |
|||
timeCreated: 1509053135 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class DroneEngine : MonoBehaviour { |
|||
|
|||
public float maxPower; |
|||
[HideInInspector] |
|||
public float powerMultiplier; |
|||
|
|||
Rigidbody rb; |
|||
Transform tr; |
|||
|
|||
void Start(){ |
|||
rb = gameObject.GetComponent<Rigidbody>(); |
|||
tr = gameObject.transform; |
|||
} |
|||
|
|||
void FixedUpdate(){ |
|||
powerMultiplier = Mathf.Max(-1f, Mathf.Min(powerMultiplier, 1f)); |
|||
rb.AddForce(tr.up * maxPower * powerMultiplier); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a0cc7a16b42c04d81b8ec5582338eb44 |
|||
timeCreated: 1509052415 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class RandomDecision : MonoBehaviour, Decision { |
|||
|
|||
|
|||
|
|||
public float[] Decide(List<float> state, List<Camera> observation, float reward, bool done, float[] memory) |
|||
{ |
|||
if (gameObject.GetComponent<Brain>().brainParameters.actionSpaceType == StateType.continuous) |
|||
{ |
|||
int actionSize = gameObject.GetComponent<Brain>().brainParameters.actionSize; |
|||
float[] result = new float[actionSize]; |
|||
for (int i = 0; i < actionSize; i++) |
|||
{ |
|||
result[i] = Random.value * 2 - 1; |
|||
} |
|||
return result; |
|||
} |
|||
else |
|||
{ |
|||
int actionSize = gameObject.GetComponent<Brain>().brainParameters.actionSize; |
|||
float[] result = new float[1]; |
|||
result[0] = (float)Random.Range(0, actionSize); |
|||
return result; |
|||
} |
|||
|
|||
} |
|||
|
|||
public float[] MakeMemory(List<float> state, List<Camera> observation, float reward, bool done, float[] memory) |
|||
{ |
|||
return new float[0]; |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 11b876dbed8b249e6ae9d924408ff13d |
|||
timeCreated: 1509055523 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 34473894985a24054b061bc80ddd54dc |
|||
folderAsset: yes |
|||
timeCreated: 1509468950 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
|
|||
? |
|||
statePlaceholder* |
|||
dtype0* |
|||
shape:��������� |
|||
�0 |
|||
dense/kernelConst* |
|||
dtype0*�0 |
|||
value�0B�0@"�0�tA�������<�E>#��=>.��.) |
|||
��C��g�=\�;g���k�=�8��O;>�] ����<�H=ڨ>��6��rE���,�=+�x>
�=v3`=�>��H틽�z.���>O��=��],O=���=Ys���a2���̽6zu>���>͗Q<o9=+�> |
|||
W>v���4���a�R7�=�~������e��=�*��=��>���=���g�����=�8�9D�=� <�_
>�ni>��><]=���>'>�&���'���A>z�-�����M���б�:��=��]>@ޢ�d͇>���<������=�����I>�m��ff���w9>�僾��h�U�Z�>z=�� >\{>��=6֠=���=�u��!R�>3�F>|�2>h`=�����5��u=�A����>י�0ذ��U�|ܖ��pl<�ˤ<TNI��S=>����N^�c��=W�'� �Q>.�J�x�=�(��>�켼��a>�jF>_J�=��^>�O>��ƾGp>wJ�>���<9�>>�G�c�<�ڗb�8nS�3>�=!�Q=_����r��k�=�\�>ܐ>�%>��>H>>m����c�$����x������~~��'"=QX=����4��ذ>�߰<b8<�=���>��;�}��Q�[����=�溼�*�>�i$>n`�~5b�ݍq�y�>s��>��;���>?��=�~��on��A"�=V�(>���>�����U��RJ=u8I>��?<��]���Ͻ᥀�;(���V�Y-�>[z��
]~���<[x>P���`�,�,M�=�&���I�%�=*驽,�=3��> |
|||
r<7�z=@�l>�M�=_�=�V@�JX;�W�=L0�a�[>)��>
�E�KY�>�L�����](�
B6>���[k1�������m>JF��X�L���>v��!e����y>�)����=x��f�����=��8>�a.�i]нCP\�۷�=4D>�#���sC��a����A�k�t�:�� �m�@D�H�>�q������z�=�I{����=Je���>�k�<���� ®�BZs�z�N��R�=���>7�>Ħ�����C=���<�Gr��b����1>f�<�3�=.qG>����Y=�3���ľ~O�����='NP>��D��?v��1�<d�;��=��Ž5\�zs��ϽlÂ��->��G>s�/��h�=W�i>Y{}>C����5�=.�.�)r��s�����<!�'�X<{�=!��>�U�=���>�S<�2ܽt���v|C���Լ��G��y�>+�>�j�= �>/=�_>���|��h �<{�,�"41����h/��p���4>}W=���<79Y=�Z�=;�~>K�2�Ld�=��]���U=�O��q>��:>,�=��>�.7���W�����|=e���=+��<ż���*T>�\�B:[<�"��
=ܽ�r�=f�齏P�=�q��D>#��=���(N!>@�D>`p=�/�>��)�$�>�@F>�fe>cF >9!�<�ޫ<�W�>�E��s���b�n�>9�Ƚ����k�>��={�X�ˁ�<�a߽�l���M����=L�n>�\G��i�;d�ξ���=��$>�����`��CNj<1 |
|||
>�M����<%p�=���>�>�<��齅�>���>(=c>�>����"�Z���G>%���?Q�%�-�O =hb_='��=�+�,8ý$��T�C�3I6=
��;w��0l��i9h�<������=�=ȚG;gy߽d��;O@�[ ~������un��ީ��*^���.��B����=qrL=C�=>h����a�=Z������= ����sQ=���=�F}��v�=E�λ��<�QK>�a&�31>��~����WH[�w¸<��N<Z�?>ң >6�d>��'�1>�Վ�R\�=�?���y>{zf���w�q�>���=���<�8�=��g>0�y>H->�!�>���$�$>�����>m ߽an�l��>��>�h���� �2=U9����=IS⽈g_:I*t�%U��9A����<����� �<�$>l�ٽ`�W�:1�J�O��V�~�5>h(�>��b�s��#��>�l�>�<t�\>�'�� >6��M)�z �>��`>W?9���4�<h�������7>�?��<&ս���@���}Z�<r=��>L��=�;���57=i���v���+&�=�L�>���>��3>�_��/_Ӿ�5ü��>C�>��->���#�>�>;d���$�=���>PkϾ9�>Uџ���v>��/�a,C�A;��#E��ӿ;�T���ڹ���<��=L0b>��[��,�>wB=��[>�s��c�p��k���G9n>!�<�]྇H`>W��������%>\��=�>AO�={�,=�%O>���!{>>��R��I��:��� |
|||
�����0��>��]>�]>�xs>�Ś�r{j>��\����<��>�q��^m>���=��ƾK���h�=�'�>ޞ4>�{c>�6�>c+J�@8���Jr>�7P> �<�"�>X���:H����͚�fs�=���-=��L넽)Dż���>*�i>��t��a�>Ej?>�H�>��\��*�<g�>H_>{G��^�=����<���;Fd>�C��~/a����xp0��@>P�=���=3�{>B�������b<͠Լ��6�"*���!��L��O���M�E�����P��=h�>D����p���X�O>��e>,�>��=�
�>�B�H�3>W����c�����-V7���f<_��=�8�>j��=(d��z�q��= �y�� (>!ש�0㹽 |
|||
��>�|�����=7->�GS�zj�� ��/W>L����\1�uNJ>�
�=Ԑ�>'�A>$�w���V��=��L>�+>��v�M+[�.Wm�����a>|� ��{9�~�ē+�u͆>���=�|(�:ƍ����=u�#>��y=��+>� ����{<]�>]����9P�s�>�;Q>��i�a�>,��>�O~�3w>�Ǿ<��b>_g>T�)��bZ>Z���� |
|||
��c�=�%�=��>V�*�&�=���Ve�=��:>V9�-&�<� 4�!o:�M0>o�/�7>��Ӿ�$��_>�aK>�~m��2�#M�G =�S�����=��=K"�>�f>v���x���r��v.�(2!�6��<�Z����>P����I=�j�E�о��:<�y>��q< |