浏览代码

Max steps in Area Controller

/develop/cubewars/splashdamage
Ervin Teng 4 年前
当前提交
ab34724e
共有 3 个文件被更改,包括 45 次插入6 次删除
  1. 16
      Project/Assets/ML-Agents/Examples/CubeWars/Prefabs/CubeWarArea.prefab
  2. 33
      Project/Assets/ML-Agents/Examples/CubeWars/Scripts/CubeWarArea.cs
  3. 2
      Project/Assets/ML-Agents/Examples/CubeWars/Scripts/SmallCubeAgent.cs

16
Project/Assets/ML-Agents/Examples/CubeWars/Prefabs/CubeWarArea.prefab


largeAgents:
- {fileID: 0}
range: 1
MaxEnvironmentSteps: 10000
--- !u!1 &3952752091333818756
GameObject:
m_ObjectHideFlags: 0

propertyPath: role
value: 2
objectReference: {fileID: 0}
- target: {fileID: 5940168890073970201, guid: 4dd35c7381e7445c99133a34a83e21db,
type: 3}
propertyPath: MaxStep
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8081094897351109481, guid: 4dd35c7381e7445c99133a34a83e21db,
type: 3}
propertyPath: m_LocalPosition.x

propertyPath: role
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5940168890073970201, guid: 4dd35c7381e7445c99133a34a83e21db,
type: 3}
propertyPath: MaxStep
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8081094897351109481, guid: 4dd35c7381e7445c99133a34a83e21db,
type: 3}
propertyPath: m_LocalPosition.x

propertyPath: largeAgent
value:
objectReference: {fileID: 5707177387575911509}
- target: {fileID: 5940168890073970201, guid: 4dd35c7381e7445c99133a34a83e21db,
type: 3}
propertyPath: MaxStep
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8081094897351109481, guid: 4dd35c7381e7445c99133a34a83e21db,
type: 3}
propertyPath: m_LocalPosition.x

33
Project/Assets/ML-Agents/Examples/CubeWars/Scripts/CubeWarArea.cs


public float range;
private CubeWarsTeamManager m_SmallTeamManager;
private CubeWarsTeamManager m_LargeTeamManager;
[Header("Max Environment Steps")] public int MaxEnvironmentSteps = 10000;
private int m_ResetTimer = 0;
void Start()

}
}
void FixedUpdate()
{
m_ResetTimer += 1;
if (m_ResetTimer > MaxEnvironmentSteps)
{
ResetAllAgents();
m_ResetTimer = 0;
}
}
public void ResetAllAgents()
{
foreach (var smallAgent in smallAgents)
{
smallAgent.EndEpisode();
smallAgent.gameObject.SetActive(true);
}
foreach (var largeAgent in largeAgents)
{
largeAgent.EndEpisode();
}
}
public void AgentDied()
{
bool smallAlive = false;

}
if (!smallAlive)
{
Debug.Log("Big Agent Wins");
smallAgent.EndEpisode();
largeAgent.EndEpisode();
ResetAllAgents();
Debug.Log("Small Agents Win");
smallAgent.EndEpisode();
largeAgent.EndEpisode();
ResetAllAgents();
}
}
}

2
Project/Assets/ML-Agents/Examples/CubeWars/Scripts/SmallCubeAgent.cs


else // Dead
{
m_Dead = true;
EndEpisode();
gameObject.SetActive(false);
gameObject.tag = "DeadSmallAgent";
myBody.GetComponentInChildren<Renderer>().material = deadMaterial;

public override void OnEpisodeBegin()
{
gameObject.SetActive(true);
m_HitPoints = m_HitPointsTotal;
HealthStatus();
m_Dead = false;

正在加载...
取消
保存