浏览代码

added freezeblock action

/hh-develop-walljump_rnd
Hunter 5 年前
当前提交
5d2ba29d
共有 10 个文件被更改,包括 1012 次插入928 次删除
  1. 5
      UnitySDK/Assets/ML-Agents/Examples/Builder/Brains/BuilderGrabLearning.asset
  2. 5
      UnitySDK/Assets/ML-Agents/Examples/Builder/Brains/BuilderGrabPlayer.asset
  3. 872
      UnitySDK/Assets/ML-Agents/Examples/Builder/Prefabs/BuilderArea.prefab
  4. 962
      UnitySDK/Assets/ML-Agents/Examples/Builder/Scenes/Builder.unity
  5. 1
      UnitySDK/Assets/ML-Agents/Examples/Builder/Scripts/BuilderAcademy.cs
  6. 89
      UnitySDK/Assets/ML-Agents/Examples/Builder/Scripts/BuilderAgent.cs
  7. 1
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/AgentCubeGroundCheck.cs
  8. 1
      UnitySDK/ProjectSettings/TagManager.asset
  9. 2
      UnitySDK/csharp_timers.json
  10. 2
      csharp_timers.json

5
UnitySDK/Assets/ML-Agents/Examples/Builder/Brains/BuilderGrabLearning.asset


m_Name: BuilderGrabLearning
m_EditorClassIdentifier:
brainParameters:
vectorObservationSize: 116
vectorObservationSize: 85
vectorActionSize: 03000000030000000200000002000000
vectorActionSize: 0300000003000000020000000200000002000000
-
-
-
-

5
UnitySDK/Assets/ML-Agents/Examples/Builder/Brains/BuilderGrabPlayer.asset


m_Name: BuilderGrabPlayer
m_EditorClassIdentifier:
brainParameters:
vectorObservationSize: 116
vectorObservationSize: 85
vectorActionSize: 03000000030000000200000002000000
vectorActionSize: 0300000003000000020000000200000002000000
-
-
-
-

872
UnitySDK/Assets/ML-Agents/Examples/Builder/Prefabs/BuilderArea.prefab
文件差异内容过多而无法显示
查看文件

962
UnitySDK/Assets/ML-Agents/Examples/Builder/Scenes/Builder.unity
文件差异内容过多而无法显示
查看文件

1
UnitySDK/Assets/ML-Agents/Examples/Builder/Scripts/BuilderAcademy.cs


public Material failMaterial;
public Material grabbedMaterial;
public Material notGrabbedMaterial;
public Material frozenMaterial;
public float heightRewardCoeff = .01f;
}

89
UnitySDK/Assets/ML-Agents/Examples/Builder/Scripts/BuilderAgent.cs


m_agentMovement = FindObjectOfType<AgentCubeMovement>();
m_RayPer = GetComponent<RayPerception>();
m_Configuration = Random.Range(0, 5);
m_DetectableObjects = new[] { "block" };
m_DetectableObjects = new[] { "block", "frozenBlock"};
m_SpawnAreaBounds = spawnArea.GetComponent<Collider>().bounds;
m_GroundRenderer = ground.GetComponent<Renderer>();
m_AgentRb = GetComponent<Rigidbody>();

GrabBlock();
}
}
var freezeBlockAction = (int)act[4];
if (freezeBlockAction == 1)
{
if(grabbingItem)
{
grabbedItemRb.isKinematic = true;
grabbedItemRb.gameObject.tag = "frozenBlock";
grabbedItemRb.transform.SetParent(m_AreaTransform);
grabbedItemRb.transform.GetComponent<Renderer>().material = m_Academy.frozenMaterial;
grabbedItemCol.enabled = true;
grabbingItem = false;
}
else
{
RaycastHit hit;
if (Physics.Raycast(m_AgentRb.position, transform.forward, out hit, 1f))
{
var rb = hit.transform.GetComponent<Rigidbody>();
var col = hit.collider;
if (hit.collider.gameObject.CompareTag("block")) //need to freeez
{
//freeze block
rb.isKinematic = true;
rb.gameObject.tag = "frozenBlock";
rb.transform.SetParent(m_AreaTransform);
rb.transform.GetComponent<Renderer>().material = m_Academy.frozenMaterial;
col.enabled = true;
}
else if(hit.collider.gameObject.CompareTag("frozenBlock")) //need to unfreeze
{
//unfreeze block
rb.isKinematic = false;
rb.gameObject.tag = "block";
rb.transform.SetParent(m_AreaTransform);
rb.transform.GetComponent<Renderer>().material = m_Academy.notGrabbedMaterial;
col.enabled = true;
}
}
// GrabBlock();
}
}

}
}
void FreezeBlock(Rigidbody rb)
{
}
bool AllBlockOnPlatform()
{
foreach (var item in buildingBlocksList)

GrabBlock();
}
}
if (Input.GetKeyDown(KeyCode.F))
{
if(grabbingItem)
{
grabbedItemRb.isKinematic = true;
grabbedItemRb.gameObject.tag = "frozenBlock";
grabbedItemRb.transform.SetParent(m_AreaTransform);
grabbedItemRb.transform.GetComponent<Renderer>().material = m_Academy.frozenMaterial;
grabbedItemCol.enabled = true;
grabbingItem = false;
}
else
{
RaycastHit hit;
if (Physics.Raycast(m_AgentRb.position, transform.forward, out hit, 1f))
{
var rb = hit.transform.GetComponent<Rigidbody>();
var col = hit.collider;
if (hit.collider.gameObject.CompareTag("block")) //need to freeez
{
//freeze block
rb.isKinematic = true;
rb.gameObject.tag = "frozenBlock";
rb.transform.SetParent(m_AreaTransform);
rb.transform.GetComponent<Renderer>().material = m_Academy.frozenMaterial;
col.enabled = true;
}
else if (hit.collider.gameObject.CompareTag("frozenBlock")) //need to unfreeze
{
//unfreeze block
rb.isKinematic = false;
rb.gameObject.tag = "block";
rb.transform.SetParent(m_AreaTransform);
rb.transform.GetComponent<Renderer>().material = m_Academy.notGrabbedMaterial;
col.enabled = true;
}
}
}
}
}
public override void AgentAction(float[] vectorAction, string textAction)

RaycastHit hit;
if (Physics.Raycast(m_AgentRb.position, transform.forward, out hit, 1f))
{
if (hit.collider.gameObject.CompareTag("block"))
if (hit.collider.gameObject.CompareTag("block") || hit.collider.gameObject.CompareTag("frozenBlock"))
{
hit.rigidbody.isKinematic = true;
hit.transform.SetParent(transform);

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


{
if (col != null && col.transform != transform &&
(col.CompareTag("walkableSurface") ||
col.CompareTag("frozenBlock") ||
col.CompareTag("block")))
{
isGrounded = true; //then we're grounded

1
UnitySDK/ProjectSettings/TagManager.asset


- purpleAgent
- purpleGoal
- hazard
- frozenBlock
layers:
- Default
- TransparentFX

2
UnitySDK/csharp_timers.json


{"count":1,"self":159.04896,"total":159.115523,"children":{"AgentResetIfDone":{"count":76,"self":0.007153,"total":0.007153,"children":null},"AgentSendState":{"count":76,"self":0.01151,"total":0.026241999999999998,"children":{"CollectObservations":{"count":26,"self":0.014731999999999999,"total":0.014731999999999999,"children":null}}},"BrainDecideAction":{"count":76,"self":0.0063419999999999995,"total":0.0063419999999999995,"children":null},"AcademyStep":{"count":76,"self":0.004124,"total":0.004124,"children":null},"AgentAct":{"count":76,"self":0.014031,"total":0.014031,"children":null}}}
{"count":1,"self":31.903792,"total":32.463443,"children":{"AgentResetIfDone":{"count":1534,"self":0.10846399999999999,"total":0.10846399999999999,"children":null},"AgentSendState":{"count":1534,"self":0.107942,"total":0.19156399999999998,"children":{"CollectObservations":{"count":512,"self":0.083622,"total":0.083622,"children":null}}},"BrainDecideAction":{"count":1534,"self":0.072592999999999991,"total":0.072592999999999991,"children":null},"AcademyStep":{"count":1534,"self":0.073549,"total":0.073549,"children":null},"AgentAct":{"count":1534,"self":0.106849,"total":0.106849,"children":null}}}

2
csharp_timers.json


{"count":1,"self":12.6202968,"total":13.332101999999999,"children":{"AgentResetIfDone":{"count":597,"self":0.008901,"total":0.008901,"children":null},"AgentSendState":{"count":597,"self":0.125016,"total":0.663338,"children":{"CollectObservations":{"count":12537,"self":0.538322,"total":0.538322,"children":null}}},"BrainDecideAction":{"count":597,"self":0.037295999999999996,"total":0.037295999999999996,"children":null}}}
{"count":1,"self":1387.9455744,"total":12462.863405999999,"children":{"AgentResetIfDone":{"count":566609,"self":6.9580959999999994,"total":6.9580959999999994,"children":null},"AgentSendState":{"count":566609,"self":45.215696,"total":208.764177,"children":{"CollectObservations":{"count":3966270,"self":163.54847999999998,"total":163.54847999999998,"children":null}}},"BrainDecideAction":{"count":566609,"self":10580.1064448,"total":10580.106154,"children":null},"AcademyStep":{"count":566609,"self":4.3853599999999995,"total":4.3853599999999995,"children":null},"AgentAct":{"count":566609,"self":274.699392,"total":274.69939,"children":null}}}
正在加载...
取消
保存