浏览代码

add individual rewards

/develop/cubewars/splashdamage
Andrew Cohen 4 年前
当前提交
75754dd3
共有 2 个文件被更改,包括 18 次插入12 次删除
  1. 2
      Project/Assets/ML-Agents/Examples/CubeWars/Scripts/LargeCubeAgent.cs
  2. 28
      Project/Assets/ML-Agents/Examples/CubeWars/Scripts/SmallCubeAgent.cs

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


{
if (hit.collider.gameObject.CompareTag("StrongSmallAgent") || hit.collider.gameObject.CompareTag("WeakSmallAgent"))
{
hit.collider.gameObject.GetComponent<SmallCubeAgent>().HitAgent(.5f);
hit.collider.gameObject.GetComponent<SmallCubeAgent>().HitAgent(.4f);
AddReward(.1f);
}
else if (hit.collider.gameObject.CompareTag("StrongLargeAgent") || hit.collider.gameObject.CompareTag("WeakLargeAgent"))

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


m_Damage = 0f;
m_Heal = .7f;
m_MoveSpeed = 10f;
m_turnSpeed = 150f;
m_TurnSpeed = 150f;
m_Cooldown = .2f;
}
else if (role == Role.DPS)

m_Heal = 0f;
m_MoveSpeed = 10f;
m_turnSpeed = 200f;
m_TurnSpeed = 200f;
m_Cooldown = .25f;
}
else if (role == Role.Tank)

m_Heal = .2f;
m_MoveSpeed = 6f;
m_turnSpeed = 100f;
m_TurnSpeed = 100f;
m_Cooldown = .4f;
}

Vector3 dirToSelf = transform.position - m_LargeAgent.transform.position;
float angle = Vector3.Dot(m_LargeAgent.transform.forward.normalized, dirToSelf.normalized);
sensor.AddObservation(angle);
if (m_Dead)
{
AddReward(-.001f * m_Bonus);
}
}
public Color32 ToColor(int hexVal)

if (hit.collider.gameObject.CompareTag("StrongSmallAgent") || hit.collider.gameObject.CompareTag("WeakSmallAgent"))
{
hit.collider.gameObject.GetComponent<SmallCubeAgent>().HealAgent(m_Heal);
if (role == Role.Healer)
{
AddReward(.05f);
}
AddReward(.1f + .4f * m_Bonus);
if (role == Role.DPS)
{
AddReward(.1f);
}
else if (role == Role.Tank)
{
AddReward(.05f);
}
}
myLaser.isFired = true;
}

}
else // Dead
{
// AddReward(-.1f * m_Bonus);
m_Dead = true;
EndEpisode();
gameObject.SetActive(false);

m_Dead = false;
m_Shoot = false;
m_ShootTime = -.5f;
//m_Bonus = Academy.Instance.FloatProperties.GetPropertyWithDefault("bonus", 0);
m_Bonus = .2f;//SideChannelUtils.GetSideChannel<FloatPropertiesChannel>().GetPropertyWithDefault("bonus", 0);
m_AgentRb.velocity = Vector3.zero;
float smallRange = 50f * m_MyArea.range;

正在加载...
取消
保存