浏览代码

Convert most other scenes to RayPerception sensor (#2916)

/develop-newnormalization
GitHub 5 年前
当前提交
bc5bf388
共有 13 个文件被更改,包括 2315 次插入943 次删除
  1. 161
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Prefabs/FoodCollectorArea.prefab
  2. 6
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs
  3. 693
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/TFModels/FoodCollector.nn
  4. 25
      UnitySDK/Assets/ML-Agents/Examples/Hallway/Prefabs/SymbolFinderArea.prefab
  5. 6
      UnitySDK/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
  6. 1001
      UnitySDK/Assets/ML-Agents/Examples/Hallway/TFModels/Hallway.nn
  7. 52
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab
  8. 16
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs
  9. 1001
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/TFModels/PushBlock.nn
  10. 1
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception.cs
  11. 264
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
  12. 31
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs
  13. 1
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/RayPerceptionSensor.cs

161
UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Prefabs/FoodCollectorArea.prefab


- component: {fileID: 65550728419070768}
- component: {fileID: 54936164982484646}
- component: {fileID: 114374774605792098}
- component: {fileID: 114762047763154270}
- component: {fileID: 114725457980523372}
m_Layer: 0
m_Name: Agent
m_TagString: agent

- component: {fileID: 65905012397919158}
- component: {fileID: 54504078365531932}
- component: {fileID: 114522573150607728}
- component: {fileID: 114416645532260476}
- component: {fileID: 114443152683847924}
m_Layer: 0
m_Name: Agent (1)
m_TagString: agent

- component: {fileID: 65152194455140476}
- component: {fileID: 54961653455021136}
- component: {fileID: 114980787530065684}
- component: {fileID: 114192565006091356}
- component: {fileID: 114986980423924774}
m_Layer: 0
m_Name: Agent (2)
m_TagString: agent

- component: {fileID: 65761952312736034}
- component: {fileID: 54819001862035794}
- component: {fileID: 114878550018296316}
- component: {fileID: 114661830999747712}
- component: {fileID: 114644889237473510}
m_Layer: 0
m_Name: Agent (4)
m_TagString: agent

- component: {fileID: 65367560123033576}
- component: {fileID: 54895479068989492}
- component: {fileID: 114035338027591536}
- component: {fileID: 114821937036444478}
- component: {fileID: 114276061479012222}
m_Layer: 0
m_Name: Agent (3)
m_TagString: agent

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 53
vectorObservationSize: 4
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
vectorActionDescriptions: []

myLaser: {fileID: 1617924810425504}
contribute: 0
useVectorObs: 1
--- !u!114 &114192565006091356
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1601500200010266}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114235147148547996
MonoBehaviour:
m_ObjectHideFlags: 1

myLaser: {fileID: 1045923826166930}
contribute: 0
useVectorObs: 1
--- !u!114 &114276061479012222
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1706274796045088}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor
detectableTags:
- food
- agent
- wall
- badFood
- frozenAgent
raysPerDirection: 3
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 50
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114374774605792098
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 53
vectorObservationSize: 4
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
vectorActionDescriptions: []

m_UseHeuristic: 0
m_BehaviorName: FoodCollector
--- !u!114 &114416645532260476
--- !u!114 &114443152683847924
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
sensorName: RayPerceptionSensor
detectableTags:
- food
- agent
- wall
- badFood
- frozenAgent
raysPerDirection: 3
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 50
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114522573150607728
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 53
vectorObservationSize: 4
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
vectorActionDescriptions: []

myLaser: {fileID: 1421240237750412}
contribute: 0
useVectorObs: 1
--- !u!114 &114661830999747712
--- !u!114 &114644889237473510
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
sensorName: RayPerceptionSensor
detectableTags:
- food
- agent
- wall
- badFood
- frozenAgent
raysPerDirection: 3
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 50
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114711827726849508
MonoBehaviour:
m_ObjectHideFlags: 1

myLaser: {fileID: 1941433838307300}
contribute: 0
useVectorObs: 1
--- !u!114 &114762047763154270
--- !u!114 &114725457980523372
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
--- !u!114 &114821937036444478
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1706274796045088}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor
detectableTags:
- food
- agent
- wall
- badFood
- frozenAgent
raysPerDirection: 3
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 50
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114878550018296316
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 53
vectorObservationSize: 4
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
vectorActionDescriptions: []

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 53
vectorObservationSize: 4
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
vectorActionDescriptions: []

m_UseHeuristic: 0
m_BehaviorName: FoodCollector
--- !u!114 &114986980423924774
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1601500200010266}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor
detectableTags:
- food
- agent
- wall
- badFood
- frozenAgent
raysPerDirection: 3
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 50
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0

6
UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs


public Material frozenMaterial;
public GameObject myLaser;
public bool contribute;
RayPerception3D m_RayPer;
public bool useVectorObs;

m_AgentRb = GetComponent<Rigidbody>();
Monitor.verticalOffset = 1f;
m_MyArea = area.GetComponent<FoodCollectorArea>();
m_RayPer = GetComponent<RayPerception3D>();
m_MyAcademy = FindObjectOfType<FoodCollectorAcademy>();
SetResetParameters();

{
if (useVectorObs)
{
const float rayDistance = 50f;
float[] rayAngles = { 20f, 90f, 160f, 45f, 135f, 70f, 110f };
string[] detectableObjects = { "food", "agent", "wall", "badFood", "frozenAgent" };
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects));
var localVelocity = transform.InverseTransformDirection(m_AgentRb.velocity);
AddVectorObs(localVelocity.x);
AddVectorObs(localVelocity.z);

693
UnitySDK/Assets/ML-Agents/Examples/FoodCollector/TFModels/FoodCollector.nn
文件差异内容过多而无法显示
查看文件

25
UnitySDK/Assets/ML-Agents/Examples/Hallway/Prefabs/SymbolFinderArea.prefab


- component: {fileID: 54112968250075710}
- component: {fileID: 114907778469006590}
- component: {fileID: 114286701363010626}
- component: {fileID: 114569343444552314}
- component: {fileID: 114388598785529460}
m_Layer: 0
m_Name: Agent
m_TagString: agent

symbolO: {fileID: 1453690758295050}
symbolX: {fileID: 1915733999209864}
useVectorObs: 1
--- !u!114 &114569343444552314
--- !u!114 &114388598785529460
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
sensorName: RayPerceptionSensor
detectableTags:
- symbol_O_Goal
- symbol_X_Goal
- symbol_O
- symbol_X
- wall
raysPerDirection: 2
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 12
observationStacks: 3
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114907778469006590
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 36
vectorObservationSize: 1
numStackedVectorObservations: 3
vectorActionSize: 05000000
vectorActionDescriptions: []

6
UnitySDK/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs


public GameObject symbolO;
public GameObject symbolX;
public bool useVectorObs;
RayPerception m_RayPer;
Rigidbody m_AgentRb;
Material m_GroundMaterial;
Renderer m_GroundRenderer;

{
base.InitializeAgent();
m_Academy = FindObjectOfType<HallwayAcademy>();
m_RayPer = GetComponent<RayPerception>();
m_AgentRb = GetComponent<Rigidbody>();
m_GroundRenderer = ground.GetComponent<Renderer>();
m_GroundMaterial = m_GroundRenderer.material;

{
if (useVectorObs)
{
var rayDistance = 12f;
float[] rayAngles = { 20f, 60f, 90f, 120f, 160f };
string[] detectableObjects = { "symbol_O_Goal", "symbol_X_Goal", "symbol_O", "symbol_X", "wall" };
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects));
}
}

1001
UnitySDK/Assets/ML-Agents/Examples/Hallway/TFModels/Hallway.nn
文件差异内容过多而无法显示
查看文件

52
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockArea.prefab


- component: {fileID: 54817351390947638}
- component: {fileID: 114306175693660464}
- component: {fileID: 114505490781873732}
- component: {fileID: 114421647563711602}
- component: {fileID: 114807072692257076}
- component: {fileID: 114451319691753174}
m_Layer: 0
m_Name: Agent
m_TagString: agent

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 70
numStackedVectorObservations: 3
vectorObservationSize: 0
numStackedVectorObservations: 2
vectorActionSize: 07000000
vectorActionDescriptions: []
vectorActionSpaceType: 0

m_BehaviorName: PushBlock
--- !u!114 &114421647563711602
--- !u!114 &114451319691753174
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}

m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
sensorName: OffsetRayPerceptionSensor
detectableTags:
- block
- goal
- wall
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 12
observationStacks: 3
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 1.5
endVerticalOffset: 1.5
--- !u!114 &114505490781873732
MonoBehaviour:
m_ObjectHideFlags: 1

block: {fileID: 1831337770648600}
goalDetect: {fileID: 0}
useVectorObs: 1
--- !u!114 &114807072692257076
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1489716781518988}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor
detectableTags:
- block
- goal
- wall
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 12
observationStacks: 3
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0

16
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs


Rigidbody m_BlockRb; //cached on initialization
Rigidbody m_AgentRb; //cached on initialization
Material m_GroundMaterial; //cached on Awake()
RayPerception m_RayPer;
float[] m_RayAngles = { 0f, 45f, 90f, 135f, 180f, 110f, 70f };
string[] m_DetectableObjects = { "block", "goal", "wall" };
/// <summary>
/// We will be changing the ground material based on success/failue

base.InitializeAgent();
goalDetect = block.GetComponent<GoalDetect>();
goalDetect.agent = this;
m_RayPer = GetComponent<RayPerception>();
// Cache the agent rigidbody
m_AgentRb = GetComponent<Rigidbody>();

m_GroundMaterial = m_GroundRenderer.material;
SetResetParameters();
}
public override void CollectObservations()
{
if (useVectorObs)
{
var rayDistance = 12f;
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, m_DetectableObjects));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, m_DetectableObjects, 1.5f, 1.5f));
}
}
/// <summary>

1001
UnitySDK/Assets/ML-Agents/Examples/PushBlock/TFModels/PushBlock.nn
文件差异内容过多而无法显示
查看文件

1
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception.cs


using System.Collections.Generic;
using UnityEngine;
[Obsolete]
public abstract class RayPerception : MonoBehaviour
{
protected float[] m_PerceptionBuffer;

264
UnitySDK/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab


- component: {fileID: 135232974003521068}
- component: {fileID: 114734187185382186}
- component: {fileID: 114492261207303438}
- component: {fileID: 114692966630797794}
- component: {fileID: 114320493772006642}
- component: {fileID: 114413496910417180}
m_Layer: 13
m_Name: PurpleStriker
m_TagString: purpleAgent

- component: {fileID: 135154818167532598}
- component: {fileID: 114105115387635628}
- component: {fileID: 114698199869072806}
- component: {fileID: 114381244552195858}
- component: {fileID: 114402225209785518}
- component: {fileID: 114691053776668376}
m_Layer: 11
m_Name: BlueGoalie
m_TagString: blueAgent

- component: {fileID: 135208952479003512}
- component: {fileID: 114387866097048300}
- component: {fileID: 114850431417842684}
- component: {fileID: 114965771318032104}
- component: {fileID: 114516244030127556}
- component: {fileID: 114736358897902410}
m_Layer: 13
m_Name: BlueStriker
m_TagString: blueAgent

- component: {fileID: 135133947297127334}
- component: {fileID: 114529615399004778}
- component: {fileID: 114284769194328828}
- component: {fileID: 114724674330921748}
- component: {fileID: 114742734491650780}
- component: {fileID: 114206319503468014}
m_Layer: 11
m_Name: PurpleGoalie
m_TagString: purpleAgent

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 112
vectorObservationSize: 0
numStackedVectorObservations: 1
vectorActionSize: 05000000
vectorActionDescriptions: []

m_UseHeuristic: 0
m_BehaviorName: Goalie
--- !u!114 &114206319503468014
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1890219402901316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleOffsetRayPerceptionSensor
detectableTags:
- ball
- purpleGoal
- blueGoal
- wall
- purpleAgent
- blueAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 1
endVerticalOffset: 1
--- !u!114 &114273807544954564
MonoBehaviour:
m_ObjectHideFlags: 1

agentRole: 1
area: {fileID: 114559182131992928}
agentRb: {fileID: 0}
--- !u!114 &114381244552195858
--- !u!114 &114320493772006642
m_GameObject: {fileID: 1124213441168130}
m_GameObject: {fileID: 1095606497496374}
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
sensorName: PurpleRayPerceptionSensor
detectableTags:
- ball
- purpleGoal
- blueGoal
- wall
- purpleAgent
- blueAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114387866097048300
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 112
vectorObservationSize: 0
numStackedVectorObservations: 1
vectorActionSize: 07000000
vectorActionDescriptions: []

m_UseHeuristic: 0
m_BehaviorName: Striker
--- !u!114 &114402225209785518
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1124213441168130}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueRayPerceptionSensor
detectableTags:
- ball
- blueGoal
- purpleGoal
- wall
- blueAgent
- purpleAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114413496910417180
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1095606497496374}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleOffsetRayPerceptionSensor
detectableTags:
- ball
- purpleGoal
- blueGoal
- wall
- purpleAgent
- blueAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 1
endVerticalOffset: 1
--- !u!114 &114492261207303438
MonoBehaviour:
m_ObjectHideFlags: 1

agentRole: 0
area: {fileID: 114559182131992928}
agentRb: {fileID: 0}
--- !u!114 &114516244030127556
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1131626411948014}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueRayPerceptionSensor
detectableTags:
- ball
- blueGoal
- purpleGoal
- wall
- blueAgent
- purpleAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114529615399004778
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 112
vectorObservationSize: 0
numStackedVectorObservations: 1
vectorActionSize: 05000000
vectorActionDescriptions: []

ballStartingPos: {x: 0, y: 0, z: 0}
goalTextUI: {fileID: 0}
canResetBall: 0
--- !u!114 &114692966630797794
--- !u!114 &114691053776668376
m_GameObject: {fileID: 1095606497496374}
m_GameObject: {fileID: 1124213441168130}
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
sensorName: BlueOffsetRayPerceptionSensor
detectableTags:
- ball
- blueGoal
- purpleGoal
- wall
- blueAgent
- purpleAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 1
endVerticalOffset: 1
--- !u!114 &114698199869072806
MonoBehaviour:
m_ObjectHideFlags: 1

agentRole: 1
area: {fileID: 114559182131992928}
agentRb: {fileID: 0}
--- !u!114 &114724674330921748
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1890219402901316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114734187185382186
MonoBehaviour:
m_ObjectHideFlags: 1

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 112
vectorObservationSize: 0
numStackedVectorObservations: 1
vectorActionSize: 07000000
vectorActionDescriptions: []

m_UseHeuristic: 0
m_BehaviorName: Striker
--- !u!114 &114736358897902410
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1131626411948014}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueOffsetRayPerceptionSensor
detectableTags:
- ball
- blueGoal
- purpleGoal
- wall
- blueAgent
- purpleAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 1
endVerticalOffset: 1
--- !u!114 &114742734491650780
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1890219402901316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleRayPerceptionSensor
detectableTags:
- ball
- purpleGoal
- blueGoal
- wall
- purpleAgent
- blueAgent
raysPerDirection: 3
maxRayDegrees: 90
sphereCastRadius: 0.5
rayLength: 20
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &114850431417842684
MonoBehaviour:
m_ObjectHideFlags: 1

agentRole: 0
area: {fileID: 114559182131992928}
agentRb: {fileID: 0}
--- !u!114 &114965771318032104
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1131626411948014}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!135 &135133947297127334
SphereCollider:
m_ObjectHideFlags: 1

31
UnitySDK/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs


public class AgentSoccer : Agent
{
// Note that that the detectable tags are different for the blue and purple teams. The order is
// * ball
// * own goal
// * opposing goal
// * wall
// * own teammate
// * opposing player
public enum Team
{
Purple,

public Rigidbody agentRb;
SoccerAcademy m_Academy;
Renderer m_AgentRenderer;
RayPerception m_RayPer;
float[] m_RayAngles = { 0f, 45f, 90f, 135f, 180f, 110f, 70f };
string[] m_DetectableObjectsPurple = { "ball", "purpleGoal", "blueGoal",
"wall", "purpleAgent", "blueAgent" };
string[] m_DetectableObjectsBlue = { "ball", "blueGoal", "purpleGoal",
"wall", "blueAgent", "purpleAgent" };
public void ChooseRandomTeam()
{

{
base.InitializeAgent();
m_AgentRenderer = GetComponentInChildren<Renderer>();
m_RayPer = GetComponent<RayPerception>();
m_Academy = FindObjectOfType<SoccerAcademy>();
agentRb = GetComponent<Rigidbody>();
agentRb.maxAngularVelocity = 500;

area.playerStates.Add(playerState);
m_PlayerIndex = area.playerStates.IndexOf(playerState);
playerState.playerIndex = m_PlayerIndex;
}
public override void CollectObservations()
{
var rayDistance = 20f;
string[] detectableObjects;
if (team == Team.Purple)
{
detectableObjects = m_DetectableObjectsPurple;
}
else
{
detectableObjects = m_DetectableObjectsBlue;
}
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, detectableObjects));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, detectableObjects, 1f, 1f));
}
public void MoveAgent(float[] act)

1
UnitySDK/Assets/ML-Agents/Scripts/Sensor/RayPerceptionSensor.cs


using System;
using System.Collections.Generic;
using System.Timers;
using UnityEngine;
namespace MLAgents.Sensor

正在加载...
取消
保存