浏览代码

kind of working

/hh-develop-pushblockcollab
HH 4 年前
当前提交
cf38ef7c
共有 3 个文件被更改,包括 55 次插入109 次删除
  1. 114
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockCollab.unity
  2. 20
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentCollab.cs
  3. 30
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushBlockEnvController.cs

114
Project/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockCollab.unity


- component: {fileID: 261815314}
- component: {fileID: 261815322}
- component: {fileID: 261815321}
- component: {fileID: 261815320}
- component: {fileID: 261815323}
- component: {fileID: 261815319}
- component: {fileID: 261815318}

serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &261815320
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 261815313}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dea8c4f2604b947e6b7b97750dde87ca, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 5000
ground: {fileID: 1500989827241484}
area: {fileID: 1125451440611342}
areaBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
goal: {fileID: 1441514604925936}
block: {fileID: 1831339105991534}
goalDetect: {fileID: 0}
useVectorObs: 1
--- !u!114 &261815321
MonoBehaviour:
m_ObjectHideFlags: 0

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 70db47ab276e44fe0beb677ff8d69382, type: 3}
m_Model: {fileID: 0}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: PushBlock

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 0
goal: {fileID: 1441514604925936}
block: {fileID: 0}
MaxStep: 5000
useVectorObs: 0
useVectorObs: 1
--- !u!1001 &269719766
PrefabInstance:
m_ObjectHideFlags: 0

m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_Constraints: 80
m_CollisionDetection: 0
--- !u!23 &1102546558
MeshRenderer:

areaBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
ground: {fileID: 0}
area: {fileID: 0}
ground: {fileID: 1500989827241484}
area: {fileID: 1125451440611342}
- Agent: {fileID: 0}
- Agent: {fileID: 1489717564321787}
- Agent: {fileID: 0}
- Agent: {fileID: 261815323}
BlocksLists:
- T: {fileID: 0}
BlocksList:
- T: {fileID: 4491956747235670}
- T: {fileID: 0}
- T: {fileID: 1102546555}
UseRandomAgentRotation: 0
UseRandomAgentPosition: 0
UseRandomAgentRotation: 1
UseRandomAgentPosition: 1
UseRandomBlockPosition: 0
UseRandomBlockPosition: 1
--- !u!1 &1257456948449766
GameObject:
m_ObjectHideFlags: 0

tagToDetect: block
onTriggerEnterEvent:
m_PersistentCalls:
m_Calls: []
onTriggerStayEvent:
m_PersistentCalls:
m_Calls: []
onTriggerExitEvent:
m_PersistentCalls:
m_Calls: []
onCollisionEnterEvent:
m_PersistentCalls:
m_Mode: 1
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine

m_BoolArgument: 0
m_CallState: 2
onTriggerStayEvent:
m_PersistentCalls:
m_Calls: []
onTriggerExitEvent:
m_PersistentCalls:
m_Calls: []
onCollisionEnterEvent:
m_PersistentCalls:
m_Calls: []
onCollisionStayEvent:
m_PersistentCalls:
m_Calls: []

- component: {fileID: 4188186536186108}
- component: {fileID: 54817352185271872}
- component: {fileID: 114306174327856710}
- component: {fileID: 114505491593959730}
- component: {fileID: 1489717564321787}
- component: {fileID: 65880097045731894}
- component: {fileID: 114807074011938370}

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 0
goal: {fileID: 1441514604925936}
block: {fileID: 0}
MaxStep: 5000
useVectorObs: 0
useVectorObs: 1
--- !u!1 &1500989827241484
GameObject:
m_ObjectHideFlags: 0

m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 112
m_Constraints: 80
m_CollisionDetection: 0
--- !u!54 &54817352185271872
Rigidbody:

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1441514604925936}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 2500, y: 300, z: 400}

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 70db47ab276e44fe0beb677ff8d69382, type: 3}
m_Model: {fileID: 0}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: PushBlock

rayMissColor: {r: 1, g: 1, b: 1, a: 1}
m_StartVerticalOffset: 1.5
m_EndVerticalOffset: 1.5
--- !u!114 &114505491593959730
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1489717564321786}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dea8c4f2604b947e6b7b97750dde87ca, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 5000
ground: {fileID: 1500989827241484}
area: {fileID: 1125451440611342}
areaBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
goal: {fileID: 1441514604925936}
block: {fileID: 1831339105991534}
goalDetect: {fileID: 0}
useVectorObs: 1
--- !u!114 &114807074011938370
MonoBehaviour:
m_ObjectHideFlags: 0

20
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentCollab.cs


PushBlockSettings m_PushBlockSettings;
/// <summary>
/// The goal to push the block to.
/// </summary>
public GameObject goal;
/// <summary>
/// The block to be pushed to the goal.
/// </summary>
public GameObject block;
// /// <summary>
// /// The goal to push the block to.
// /// </summary>
// public GameObject goal;
//
// /// <summary>
// /// The block to be pushed to the goal.
// /// </summary>
// public GameObject block;
/// <summary>
/// Detects when the block touches the goal.

public override void Initialize()
{
goalDetect = block.GetComponent<GoalDetect>();
// goalDetect = block.GetComponent<GoalDetect>();
// goalDetect.agent = this;
// Cache the agent rigidbody

30
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushBlockEnvController.cs


private int m_NumberOfRemainingBlocks;
void Awake()
void Start()
{
m_NumberOfRemainingBlocks = BlocksList.Count;

/// <summary>
/// Called when the agent moves the block into the goal.
/// </summary>
public void ScoredAGoal(float f)
public void ScoredAGoal(Collider col)
if (m_NumberOfRemainingBlocks == 0) //done
{
}
else
{
}
item.Agent.EndEpisode();
//Reset assets
ResetScene();
if (done)
{
//Reset assets
ResetScene();
}
}
Quaternion GetRandomRot()

//Random platform rot
area.transform.rotation = GetRandomRot();
//End Episode
foreach (var item in AgentsList)
{
if (!item.Agent)
{
return;
}
item.Agent.EndEpisode();
}
//Reset Agents
foreach (var item in AgentsList)
{

正在加载...
取消
保存