浏览代码

Merge commit 'f7fa7f78e472b59b77ca941a52c82164921e198c' into develop-zombieteammanager-disableagent

/develop/zombieteammanager/disableagent
Ervin Teng 4 年前
当前提交
9c69297d
共有 3 个文件被更改,包括 47 次插入50 次删除
  1. 38
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/2ZombieVs3AgentsPushBlock.unity
  2. 2
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/SimpleNPC.cs
  3. 57
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/ZombiePushBlockDeathEnvController.cs

38
Project/Assets/ML-Agents/Examples/PushBlock/Scenes/2ZombieVs3AgentsPushBlock.unity


m_GameObject: {fileID: 180376172}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.8199997, y: 1, z: -1.43}
m_LocalScale: {x: 2, y: 0.75, z: 2}
m_LocalScale: {x: 4, y: 0.75, z: 4}
m_Children: []
m_Father: {fileID: 35422107}
m_RootOrder: 6

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 9a4ea4894b7fb49859cfa9c16652b207, type: 3}
m_Model: {fileID: 11400000, guid: 2c785861dab4f42309917b4d04e2c8e7, type: 3}
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 9a4ea4894b7fb49859cfa9c16652b207, type: 3}
m_Model: {fileID: 11400000, guid: 95c3b98e2aad84cefbd6f82ee7805789, type: 3}
GroupId: 1
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 2
m_BehaviorName:
TeamId: 0
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 9a4ea4894b7fb49859cfa9c16652b207, type: 3}
m_Model: {fileID: 11400000, guid: 95c3b98e2aad84cefbd6f82ee7805789, type: 3}
GroupId: 1
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 2
m_BehaviorName:
TeamId: 0
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 2
m_BehaviorName:
TeamId: 0
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 0
m_BehaviorName: PushBlock
TeamId: 0
GroupId: 2
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 0
m_BehaviorName: PushBlock
TeamId: 0
GroupId: 2
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 0
m_BehaviorName: PushBlock
TeamId: 0
GroupId: 3
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 9a4ea4894b7fb49859cfa9c16652b207, type: 3}
m_Model: {fileID: 11400000, guid: 95c3b98e2aad84cefbd6f82ee7805789, type: 3}
GroupId: 1
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_GameObject: {fileID: 997359139}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.8199997, y: 1, z: -1.43}
m_LocalScale: {x: 2, y: 0.75, z: 2}
m_LocalScale: {x: 4, y: 0.75, z: 4}
m_Children: []
m_Father: {fileID: 1056693890}
m_RootOrder: 6

m_BehaviorType: 0
m_BehaviorName: PushBlock
TeamId: 0
GroupId: 2
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_BehaviorType: 0
m_BehaviorName: PushBlock
TeamId: 0
GroupId: 3
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_GameObject: {fileID: 1906676962}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.8199997, y: 1, z: -1.43}
m_LocalScale: {x: 2, y: 0.75, z: 2}
m_LocalScale: {x: 4, y: 0.75, z: 4}
m_Children: []
m_Father: {fileID: 2124347356}
m_RootOrder: 6

m_BehaviorType: 0
m_BehaviorName: PushBlock
TeamId: 0
GroupId: 3
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 9a4ea4894b7fb49859cfa9c16652b207, type: 3}
m_Model: {fileID: 11400000, guid: 2c785861dab4f42309917b4d04e2c8e7, type: 3}
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

StartingRot: {x: 0, y: 0, z: 0, w: 0}
Rb: {fileID: 0}
UseRandomAgentRotation: 1
UseRandomAgentPosition: 1
UseRandomAgentPosition: 0
UseRandomBlockRotation: 1
UseRandomBlockPosition: 1
--- !u!1 &1257456948449766

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 9a4ea4894b7fb49859cfa9c16652b207, type: 3}
m_Model: {fileID: 11400000, guid: 2c785861dab4f42309917b4d04e2c8e7, type: 3}
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

m_GameObject: {fileID: 8120829477783372687}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.8199997, y: 1, z: -1.43}
m_LocalScale: {x: 2, y: 0.75, z: 2}
m_LocalScale: {x: 4, y: 0.75, z: 4}
m_Children: []
m_Father: {fileID: 4006991767121726}
m_RootOrder: 6

m_BehaviorType: 2
m_BehaviorName:
TeamId: 0
GroupId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0

2
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/SimpleNPC.cs


public void SetRandomWalkSpeed()
{
walkSpeed = Random.Range(1f, 7f);
walkSpeed = Random.Range(6f, 7f);
}
}

57
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/ZombiePushBlockDeathEnvController.cs


public void KillAgent(Collision col, Transform t)
{
print($"zombie {t.name} ate {col.collider.name}");
//End Episode
foreach (var item in AgentsList)
{
if (!item.Agent)
{
return;
}
}
//Disable killed Agent
foreach (var item in AgentsList)
{

item.Agent.frozen = true;
item.Rb.constraints |= RigidbodyConstraints.FreezePositionY;
item.Col.enabled = false;
break;
// //End Episode
// foreach (var item in ZombiesList)
// {
// if (item.Agent.transform == t)
// {
// item.Agent.gameObject.SetActive(false);
// break;
// }
// }
bool allZombiesDead = true;
// Kill zombies
foreach (var item in ZombiesList)
{
if (item.Agent.transform == t)
{
item.Agent.gameObject.SetActive(false);
//break;
}
if (item.Agent.gameObject.activeSelf)
{
allZombiesDead = false;
}
}
// If all zombies dead, unfreeze block
if (allZombiesDead)
{
foreach (var item in BlocksList)
{
// Unfreeze block's motion when zombies are killed
item.Rb.constraints &= RigidbodyConstraints.FreezePositionX;
item.Rb.constraints &= RigidbodyConstraints.FreezePositionZ;
}
}
}

public void ZombieTouchedBlock()
{
//Give Agent Rewards
foreach (var item in AgentsList)
{
item.Agent.AddReward(-1);
}
// foreach (var item in AgentsList)
// {
// item.Agent.AddReward(-1);
// }
// Swap ground material for a bit to indicate we scored.
StartCoroutine(GoalScoredSwapGroundMaterial(m_PushBlockSettings.failMaterial, 0.5f));
ResetScene();

item.Rb.velocity = Vector3.zero;
item.Rb.angularVelocity = Vector3.zero;
item.T.gameObject.SetActive(true);
// Freeze block's motion until zombies are killed
item.Rb.constraints |= RigidbodyConstraints.FreezePositionX;
item.Rb.constraints |= RigidbodyConstraints.FreezePositionZ;
}
//End Episode
foreach (var item in ZombiesList)

正在加载...
取消
保存