浏览代码
Merge branch 'develop-superpush-branch-cleanup' into develop-pushcollabonly
/develop/pushcollabonly
Merge branch 'develop-superpush-branch-cleanup' into develop-pushcollabonly
/develop/pushcollabonly
Ervin Teng
4 年前
当前提交
8ef2c390
共有 27 个文件被更改,包括 478 次插入 和 4631 次删除
-
2Project/Assets/ML-Agents/Examples/Hallway/Scenes/Hallway.unity.meta
-
22Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
-
540Project/Assets/ML-Agents/Examples/Sorter/Prefabs/Area.prefab
-
22Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
-
3com.unity.ml-agents/Runtime/Agent.cs
-
1com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
-
2config/ppo/PushBlock.yaml
-
7Project/Assets/ML-Agents/Examples/Hallway/Scenes/HallwayCollab.unity.meta
-
1001Project/Assets/ML-Agents/Examples/Hallway/Scenes/HallwayCollab.unity
-
11Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayCollabAgent.cs.meta
-
204Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayCollabAgent.cs
-
566Project/Assets/ML-Agents/Examples/Hallway/TFModels/HallwayCollab.onnx
-
14Project/Assets/ML-Agents/Examples/Hallway/TFModels/HallwayCollab.onnx.meta
-
455Project/Assets/ML-Agents/Examples/Sorter/Prefabs/NumberBlock (1).prefab
-
7Project/Assets/ML-Agents/Examples/Sorter/Prefabs/NumberBlock (1).prefab.meta
-
7Project/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpCollabArea.prefab.meta
-
1001Project/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpCollabArea.prefab
-
7Project/Assets/ML-Agents/Examples/WallJump/Scenes/WallJumpCollab.unity.meta
-
1001Project/Assets/ML-Agents/Examples/WallJump/Scenes/WallJumpCollab.unity
-
50Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallAreaScoring.cs
-
11Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallAreaScoring.cs.meta
-
11Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpCollabAgent.cs.meta
-
67Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpCollabAgent.cs
-
8Project/Assets/ML-Agents/Examples/Arena-Sequence.meta
-
63config/ppo/WallJumpCollab.yaml
-
26config/ppo/HallwayCollab.yaml
|
|||
fileFormatVersion: 2 |
|||
guid: 71d1487c63f604ff6985cc2f23c7afbf |
|||
guid: d6d6a33ed0e18459a8d61817d600978a |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|
|||
fileFormatVersion: 2 |
|||
guid: d6d6a33ed0e18459a8d61817d600978a |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Project/Assets/ML-Agents/Examples/Hallway/Scenes/HallwayCollab.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: f7451777d89fd47418f0e1c3e2511919 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using Unity.MLAgents; |
|||
using Unity.MLAgents.Actuators; |
|||
using Unity.MLAgents.Sensors; |
|||
|
|||
public class HallwayCollabAgent : HallwayAgent |
|||
{ |
|||
public GameObject symbolSGoal; |
|||
public GameObject symbolS; |
|||
public HallwayCollabAgent teammate; |
|||
public bool isSpotter = true; |
|||
int m_Message = 0; |
|||
|
|||
|
|||
[HideInInspector] |
|||
public int selection = 0; |
|||
|
|||
public override void Initialize() |
|||
{ |
|||
base.Initialize(); |
|||
if (isSpotter) |
|||
{ |
|||
var teamManager = new SimpleMultiAgentGroup(); |
|||
teamManager.RegisterAgent(this); |
|||
teamManager.RegisterAgent(teammate); |
|||
} |
|||
} |
|||
public override void OnEpisodeBegin() |
|||
{ |
|||
m_Message = -1; |
|||
|
|||
var agentOffset = 10f; |
|||
if (isSpotter) |
|||
{ |
|||
agentOffset = -15; |
|||
} |
|||
|
|||
if (!isSpotter) |
|||
{ |
|||
transform.position = new Vector3(0f + Random.Range(-3f, 3f), |
|||
1f, agentOffset + Random.Range(-5f, 5f)) |
|||
+ ground.transform.position; |
|||
transform.rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); |
|||
} |
|||
else |
|||
{ |
|||
transform.position = new Vector3(0f, |
|||
1f, agentOffset) |
|||
+ ground.transform.position; |
|||
transform.rotation = Quaternion.Euler(0f, 0f, 0f); |
|||
} |
|||
|
|||
// Remove the randomness
|
|||
|
|||
m_AgentRb.velocity *= 0f; |
|||
if (isSpotter) |
|||
{ |
|||
var blockOffset = -9f; |
|||
// Only the Spotter has the correct selection
|
|||
selection = Random.Range(0, 3); |
|||
if (selection == 0) |
|||
{ |
|||
symbolO.transform.position = |
|||
new Vector3(0f, 2f, blockOffset) |
|||
+ ground.transform.position; |
|||
symbolX.transform.position = |
|||
new Vector3(0f, -1000f, blockOffset + Random.Range(-5f, 5f)) |
|||
+ ground.transform.position; |
|||
symbolS.transform.position = |
|||
new Vector3(0f, -1000f, blockOffset + Random.Range(-5f, 5f)) |
|||
+ ground.transform.position; |
|||
} |
|||
else if (selection == 1) |
|||
{ |
|||
symbolO.transform.position = |
|||
new Vector3(0f, -1000f, blockOffset + Random.Range(-5f, 5f)) |
|||
+ ground.transform.position; |
|||
symbolX.transform.position = |
|||
new Vector3(0f, 2f, blockOffset) |
|||
+ ground.transform.position; |
|||
symbolS.transform.position = |
|||
new Vector3(0f, -1000f, blockOffset + Random.Range(-5f, 5f)) |
|||
+ ground.transform.position; |
|||
} |
|||
else |
|||
{ |
|||
symbolO.transform.position = |
|||
new Vector3(0f, -1000f, blockOffset + Random.Range(-5f, 5f)) |
|||
+ ground.transform.position; |
|||
symbolX.transform.position = |
|||
new Vector3(0f, -1000f, blockOffset) |
|||
+ ground.transform.position; |
|||
symbolS.transform.position = |
|||
new Vector3(0f, 2f, blockOffset) |
|||
+ ground.transform.position; |
|||
} |
|||
|
|||
var goalPos = Random.Range(0, 7); |
|||
if (goalPos == 0) |
|||
{ |
|||
symbolOGoal.transform.position = new Vector3(7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolXGoal.transform.position = new Vector3(0f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolSGoal.transform.position = new Vector3(-7f, 0.5f, 22.29f) + area.transform.position; |
|||
} |
|||
else if (goalPos == 1) |
|||
{ |
|||
symbolOGoal.transform.position = new Vector3(7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolXGoal.transform.position = new Vector3(-7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolSGoal.transform.position = new Vector3(0f, 0.5f, 22.29f) + area.transform.position; |
|||
} |
|||
else if (goalPos == 2) |
|||
{ |
|||
symbolOGoal.transform.position = new Vector3(-7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolXGoal.transform.position = new Vector3(7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolSGoal.transform.position = new Vector3(0f, 0.5f, 22.29f) + area.transform.position; |
|||
} |
|||
else if (goalPos == 3) |
|||
{ |
|||
symbolOGoal.transform.position = new Vector3(-7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolXGoal.transform.position = new Vector3(0f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolSGoal.transform.position = new Vector3(7f, 0.5f, 22.29f) + area.transform.position; |
|||
} |
|||
else if (goalPos == 4) |
|||
{ |
|||
symbolOGoal.transform.position = new Vector3(0f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolXGoal.transform.position = new Vector3(-7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolSGoal.transform.position = new Vector3(7f, 0.5f, 22.29f) + area.transform.position; |
|||
} |
|||
else |
|||
{ |
|||
symbolOGoal.transform.position = new Vector3(0f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolXGoal.transform.position = new Vector3(7f, 0.5f, 22.29f) + area.transform.position; |
|||
symbolSGoal.transform.position = new Vector3(-7f, 0.5f, 22.29f) + area.transform.position; |
|||
} |
|||
} |
|||
} |
|||
public override void CollectObservations(VectorSensor sensor) |
|||
{ |
|||
if (useVectorObs) |
|||
{ |
|||
sensor.AddObservation(StepCount / (float)MaxStep); |
|||
} |
|||
sensor.AddObservation(toOnehot(m_Message)); |
|||
} |
|||
|
|||
float[] toOnehot(int message) |
|||
{ |
|||
float[] onehot = new float[3]; |
|||
if (message < 0 || message >= 3) |
|||
{ |
|||
return onehot; |
|||
} |
|||
onehot[message] = 1f; |
|||
return onehot; |
|||
} |
|||
|
|||
public void tellAgent(int message) |
|||
{ |
|||
m_Message = message; |
|||
} |
|||
|
|||
public override void OnActionReceived(ActionBuffers actionBuffers) |
|||
{ |
|||
AddReward(-1f / MaxStep); |
|||
if (!isSpotter) |
|||
{ |
|||
MoveAgent(actionBuffers.DiscreteActions); |
|||
} |
|||
|
|||
int comm_act = actionBuffers.DiscreteActions[1]; |
|||
teammate.tellAgent(comm_act); |
|||
// if (isSpotter) // Test
|
|||
// {
|
|||
// teammate.tellAgent(selection);
|
|||
// }
|
|||
} |
|||
|
|||
void OnCollisionEnter(Collision col) |
|||
{ |
|||
if (col.gameObject.CompareTag("symbol_O_Goal") || col.gameObject.CompareTag("symbol_X_Goal") || col.gameObject.CompareTag("symbol_S_Goal")) |
|||
{ |
|||
if (!isSpotter) |
|||
{ |
|||
// Check the ground truth
|
|||
if ((teammate.selection == 0 && col.gameObject.CompareTag("symbol_O_Goal")) || |
|||
(teammate.selection == 1 && col.gameObject.CompareTag("symbol_X_Goal")) || |
|||
(teammate.selection == 2 && col.gameObject.CompareTag("symbol_S_Goal"))) |
|||
{ |
|||
SetReward(1f); |
|||
teammate.SetReward(1f); |
|||
StartCoroutine(GoalScoredSwapGroundMaterial(m_HallwaySettings.goalScoredMaterial, 0.5f)); |
|||
} |
|||
else |
|||
{ |
|||
SetReward(-0.1f); |
|||
teammate.SetReward(-0.1f); |
|||
StartCoroutine(GoalScoredSwapGroundMaterial(m_HallwaySettings.failMaterial, 0.5f)); |
|||
} |
|||
EndEpisode(); |
|||
teammate.EndEpisode(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
pytorch1.7:�� |
|||
Q |
|||
vector_observation22Slice_0"Slice* |
|||
axes@�* |
|||
ends@i�* |
|||
starts@ � |
|||
Q |
|||
vector_observation23Slice_1"Slice* |
|||
axes@�* |
|||
ends@o�* |
|||
starts@i� |
|||
4 |
|||
22 |
|||
2324Concat_2"Concat* |
|||
axis���������� |
|||
� |
|||
24 |
|||
/network_body.linear_encoder.seq_layers.0.weight |
|||
-network_body.linear_encoder.seq_layers.0.bias25Gemm_3"Gemm* |
|||
alpha �?�* |
|||
beta �?�* |
|||
transB� |
|||
|
|||
2526 Sigmoid_4"Sigmoid |
|||
|
|||
25 |
|||
2627Mul_5"Mul |
|||
� |
|||
27 |
|||
/network_body.linear_encoder.seq_layers.2.weight |
|||
-network_body.linear_encoder.seq_layers.2.bias28Gemm_6"Gemm* |
|||
alpha �?�* |
|||
beta �?�* |
|||
transB� |
|||
|
|||
2829 Sigmoid_7"Sigmoid |
|||
|
|||
28 |
|||
2930Mul_8"Mul |
|||
K |
|||
action_masks31Slice_9"Slice* |
|||
axes@�* |
|||
ends@�* |
|||
starts@ � |
|||
L |
|||
action_masks32Slice_10"Slice* |
|||
axes@�* |
|||
ends@�* |
|||
starts@� |
|||
� |
|||
30 |
|||
5action_model._discrete_distribution.branches.0.weight |
|||
3action_model._discrete_distribution.branches.0.bias33Gemm_11"Gemm* |
|||
alpha �?�* |
|||
beta �?�* |
|||
transB� |
|||
134Constant_12"Constant* |
|||
value*J ��� |
|||
|
|||
31 |
|||
3435Mul_13"Mul |
|||
136Constant_14"Constant* |
|||
value*J �?� |
|||
|
|||
35 |
|||
3637Add_15"Add |
|||
|
|||
33 |
|||
3138Mul_16"Mul |
|||
139Constant_17"Constant* |
|||
value*J ��L� |
|||
|
|||
37 |
|||
3940Mul_18"Mul |
|||
|
|||
38 |
|||
4041Sub_19"Sub |
|||
* |
|||
4142 |
|||
Softmax_20"Softmax* |
|||
axis� |
|||
� |
|||
30 |
|||
5action_model._discrete_distribution.branches.1.weight |
|||
3action_model._discrete_distribution.branches.1.bias43Gemm_21"Gemm* |
|||
alpha �?�* |
|||
beta �?�* |
|||
transB� |
|||
144Constant_22"Constant* |
|||
value*J ��� |
|||
|
|||
32 |
|||
4445Mul_23"Mul |
|||
146Constant_24"Constant* |
|||
value*J �?� |
|||
|
|||
45 |
|||
4647Add_25"Add |
|||
|
|||
43 |
|||
3248Mul_26"Mul |
|||
149Constant_27"Constant* |
|||
value*J ��L� |
|||
|
|||
47 |
|||
4950Mul_28"Mul |
|||
|
|||
48 |
|||
5051Sub_29"Sub |
|||
* |
|||
5152 |
|||
Softmax_30"Softmax* |
|||
axis� |
|||
153Constant_31"Constant* |
|||
value*J���3� |
|||
|
|||
42 |
|||
5354Add_32"Add |
|||
|
|||
5455Log_33"Log |
|||
156Constant_34"Constant* |
|||
value*J���3� |
|||
|
|||
52 |
|||
5657Add_35"Add |
|||
|
|||
5758Log_36"Log |
|||
: |
|||
55 |
|||
58discrete_actions Concat_37"Concat* |
|||
axis� |
|||
0 |
|||
55 |
|||
58action Concat_38"Concat* |
|||
axis� |
|||
<memory_sizeConstant_39"Constant* |
|||
value* |
|||
J �torch-jit-export*OB3action_model._discrete_distribution.branches.0.biasJ���
��;ۺ���#�;�U<*��B5action_model._discrete_distribution.branches.0.weightJ�`�����=�}{<�'0���_];�{�:��*����� 鼦G <>�ջ�����ܗ��P��C�_<Yj����ֺǟ����;��w���ʼr�O��y�<���e��;��케X�<Bhļ8d�;�+<����滯����d���V�ê�<Vp��s����;�^6�"X�|��G;D<��4�����kB�;�5k���$=���� |
|||
e<�V��<�D;<�[^;d=*��r����m<13�]m}5[�v���������֝<��ϼ�Jռ��<�]�����<����C)�eж��R�n��3G<̲X�Lz$uǻ���<�5n��;λ5�;����q��T��������94&�����t!�<Y��==F���;B>���6���x��{�:��뺁S���%�뼛�=�,�<�༘�ۼ&��$����v�;@�:��D<:c��ŗ��?Ĝ<� ���� �::AԼW_*���6�>��o��:V���� �����<�%�hD����=<+-�=�ۄ��G=ͣ<|=��=��= �����v�<� �=���==Ͻ�Wy�݆ʼ���=UbI=���=`)�<�Ѡ��5���{�<�҉=��J=��(�I�E=�of���=OK=��q;��p���g�t��=��?=�8o��K�<[k�;fs
�RT��]�c<s���R��]����=����>=����y1 ���м�`D=�� |
|||
=vU��A(=AQ�=ԚJ=
���!���>h�ἐlۼEॽ�a)=ڒ�����<wؘ=����f�p0�<��5=� h��Ț�K��������
=|�<�!�=� |
|||
&�~6�=mO����j<|Tg�#f|=��(�4�=�.�#<�7[ >���D�<#낽:�����˼ӭ<qq��}�����=����+Դ�6:��i7�f$5=(P;�S<�K�{�=�w���h�W]���� =_jg�%y=�V=L+<���<�Ӏ=�������<z=迼=+�=�<�k�����=�R��d˃�MRu�� y�T��<����k�;<罻���<^ͼg2<�q���:t�;����&�<{��<C2?�����m��^�Sc��*���H��������<2�U���k��R�'\3<Q�H=B;��伓�H��b<U� �P���`��,�<�) |
|||
�if��o"�<��Ҽr3�:��ֻ��f<���:���=<?�=�R���9�;p*�<]Y.���������4d�3r�G������۬���`��\�0<����>=#��;= �|<��K�X�Ir4�sd¼�*<��'c=�)�<G<7��<�>���o=�,���=jo'�po�<#��^v< ��;;��<� |
|||
6��`e�l�<oJ�?��<%��<c���pIo=g���>���m�<���;������<�/�eG+�D�J=d |
|||
<�.{<�z¼�ؼ���`�<~��<$'����^� ���;�5�������̼���<rT`�D�|;r\<R2��@A$���>��0ͻځ���1�,��;�B=�F <�� |
|||
�;��=�#���굼��;ת =z|`=�=��»�U����F=�ʊ��m�=�$�<C�H�2�p���M=��qC��}���i��Bک<֣?�DH<�S���r6���o�H��=v�^����(m�B |
|||
�=�Pټꧽ�^�{��=���1�[=O��=�+�=�O�=��e<'(6�2��;����m�<j��=H��<Yf�=���=�i^=J=�ω� ��9:��l�<�d�=�-�=Jwr��K����=Xy����}=����A�=(�p=�"��J꒽���<����HЍ��҄=r�>��=���=���=M�=�M ���=(���8s=�;��=E�����=)���2Ľ�]e=T� |
|||
��|=G��=}���C�<�<�=�懽�\>�%=X ��gAN=�}��]��Ǡa=�?<��S<��<)'f<}�x<r�'=s
==�ɺ�@l��0X�#���ׄ4��W���á=ө�����=��n<r�N=�S0����_=����r,�$w�=߹�;
�_��j��ܛ��7�^=[�-<d���A{ǽI8��[�P�][�=V=�<�Ґ�)�A��~���/�V@>=�ʪ=<�,3o=��:����,�=Be�=��-V��>H=��)=���H�#z�;�U<ӌ=c���QҦ=��*�p�h=`i*�Q�=�փ<?+���ݎ��Ô<%�<t�4=*Uq=`,�=ߢ������nR��t�<96�<{���U@�:i0"=��=���=�`�*ڽ����i�q=�Ƽ��Q�;o�=�!��C6=����A������`X�=� H=��=2D�=6:���u�d���YF̼�,��)VŽ�!ǽHI1�`Nz�z�I��~:=f��z��n�"�e>:���=v���ܑ� |
|||
��|%�=8�=[ap���x=��|���
=TZ���̠�ͱ�=��=��8�J|��?�]�<))k="T��0o��/���q�=$=N�=��C=�E�=�f=���T=Uj>��
���ཐ&��� μsb����==rk��J��*CB3action_model._discrete_distribution.branches.1.biasJЕ?�Е?<*��B5action_model._discrete_distribution.branches.1.weightJ����f�<�m����;øP<��<��;�x����;�#����<��<1���軝 |
|||
���Ԗ<�4<�� ��(����;�V��"}{<j�~��ze���A=s���,<C ��G"=��?�mu<Q~�<NU�<a���\��(?<���;��Q?;��ڼ��/<Y7N;��~��|�����<bE�;4E��$D���D��ɰ<�6��j�����;�������!�;o*<=��������3k�<䍖;ӑ ;��v<{����~<������#;F�������":��+5;�/&��<�<W�x<�^Y<Y��FOm<�J�<���~�=�ą��nѻWoϹ6xl:%�<��<�꼻=��<+��<�Z����_<1����0&L�G��_��(�l��Q�<<1'���!��+�����<�oǼ\�;ל�;�!�f_�����;Vx<��;�L�:9)�<%Z�;�&��Ѡ<D�r;D[漨�F<���#~�<�r�;��$<?���Mژ�-*���.�;[�?��;���<���5)�T`Ѽ]�<Jd<
��;e�ü������W<m��;&2+�K����,�8� �`ѱ�X�;�\Ӱ�;[�;�J�<�<���*�9s7��������L�s��A�ټ/AѼ���<���;���˷�L��P�;�ܫ<��Z�<O��:$<�.W;����z�<����e�A�;��� R��c6z<��X<�����";
�!<)/�0>1<������x<��<�/���j�:�+����;�懼�z/=_<Z�<p+Լ��]<������$>�:����a��+�<�B�;,���Q�W�@<f��0��;�X��҄���w�ɯ�� �<����kn��^X��{��E�<�==�^�<@x�<v��9 r�� ��P����U<�5�<Rސ<G���=�ja;b ���.<�O�<�;������U�;���86
=�k��i���y�<[?���;8J��]j����`�<���<U�<*Baction_output_shapeJ �@*(Bdiscrete_action_output_shapeJ �@*!Bis_continuous_controlJ *��B-network_body.linear_encoder.seq_layers.0.biasJ�B�#=ŌE=��<�$c=�U =g�1<��V=C�=��9=h�=Űn��N<C� =�r=B.K=g袺~G)=t<�!�;_z%;T <�Y��G=���<��*�cf;���<�S:<�["=�Z�<�N�<��$=`��<ɷ�<;�<�#t<���;�k��%#=!A=��H<^b�<l�ݻ �=�a%<�R�<��<�����3=(�<R@�Y�*<ɨ1<tDH;e[�< �<>�<�'�<��=�'�;�hM<��&=��Z<I��<ٳ� �=��;�#=�&�<��< |