浏览代码

soccerfives curricula

/soccer-fives
Andrew Cohen 5 年前
当前提交
7d90b042
共有 3 个文件被更改,包括 19 次插入5 次删除
  1. 10
      Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
  2. 6
      Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs
  3. 8
      config/curricula/soccer_fives.yaml

10
Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab


m_BehaviorType: 0
m_BehaviorName: Soccer
m_TeamID: 1
m_useChildSensors: 1
m_UseChildSensors: 1
--- !u!114 &114492261207303438
MonoBehaviour:
m_ObjectHideFlags: 0

vectorActionSpaceType: 0
m_Model: {fileID: 11400000, guid: 9d26b71f04a2d4680a68d8de4f6b62e9, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorType: 1
m_useChildSensors: 1
m_UseChildSensors: 1
--- !u!114 &114850431417842684
MonoBehaviour:
m_ObjectHideFlags: 0

m_BehaviorType: 0
m_BehaviorName: Soccer
m_TeamID: 1
m_useChildSensors: 1
m_UseChildSensors: 1
--- !u!114 &5320024511406682322
MonoBehaviour:
m_ObjectHideFlags: 0

m_BehaviorType: 0
m_BehaviorName: Soccer
m_TeamID: 0
m_useChildSensors: 1
m_UseChildSensors: 1
--- !u!114 &5379409612883756837
MonoBehaviour:
m_ObjectHideFlags: 0

6
Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs


float m_KickPower;
int m_PlayerIndex;
public SoccerFieldArea area;
float m_BallTouch;
[HideInInspector]
public Rigidbody agentRb;

public override void InitializeAgent()
{
base.InitializeAgent();
m_BallTouch = Academy.Instance.FloatProperties.GetPropertyWithDefault("ball_touch", 0);
m_BehaviorParameters = gameObject.GetComponent<BehaviorParameters>();
if (m_BehaviorParameters.m_TeamID == (int)Team.Blue)
{

var force = 2000f * m_KickPower;
if (c.gameObject.CompareTag("ball"))
{
AddReward(.2f * m_BallTouch);
var dir = c.contacts[0].point - transform.position;
dir = dir.normalized;
c.gameObject.GetComponent<Rigidbody>().AddForce(dir * force);

public override void AgentReset()
{
m_BallTouch = Academy.Instance.FloatProperties.GetPropertyWithDefault("ball_touch", 0);
if (team == Team.Purple)
{
transform.rotation = Quaternion.Euler(0f, -90f, 0f);

8
config/curricula/soccer_fives.yaml


SoccerFives:
measure: progress
thresholds: [0.05, 0.1]
min_lesson_length: 100
signal_smoothing: true
parameters:
ball_touch: [1.0, 0.5, 0.0]
正在加载...
取消
保存