浏览代码

added noise to spawns soccer

/ai-summit-exp
Andrew Cohen 4 年前
当前提交
d6528cac
共有 4 个文件被更改,包括 38 次插入18 次删除
  1. 20
      Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
  2. 20
      Project/Assets/ML-Agents/Examples/Soccer/Scenes/SoccerTwos.unity
  3. 10
      Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs
  4. 6
      Project/Assets/ML-Agents/Examples/Soccer/Scripts/SoccerFieldArea.cs

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


m_BehaviorName: SoccerTwos
TeamId: 1
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0
--- !u!114 &114492261207303438
MonoBehaviour:

- wall
- purpleAgent
- blueAgent
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_RaysPerDirection: 10
m_MaxRayDegrees: 75
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:

m_BehaviorName: SoccerTwos
TeamId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0
--- !u!114 &114850431417842684
MonoBehaviour:

- wall
- blueAgent
- purpleAgent
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_RaysPerDirection: 10
m_MaxRayDegrees: 75
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:

m_BehaviorName: SoccerTwos
TeamId: 1
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0
--- !u!114 &5320024511406682322
MonoBehaviour:

- wall
- purpleAgent
- blueAgent
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_RaysPerDirection: 10
m_MaxRayDegrees: 75
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:

m_BehaviorName: SoccerTwos
TeamId: 0
m_UseChildSensors: 1
m_UseChildActuators: 1
m_ObservableAttributeHandling: 0
--- !u!114 &5379409612883756837
MonoBehaviour:

- wall
- blueAgent
- purpleAgent
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_RaysPerDirection: 10
m_MaxRayDegrees: 75
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:

20
Project/Assets/ML-Agents/Examples/Soccer/Scenes/SoccerTwos.unity


m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4444285537983296, guid: 54f3340298537426e96a6cc530e2d5d8, type: 3}
propertyPath: m_LocalPosition.z
value: 1.2
objectReference: {fileID: 0}
- target: {fileID: 4558743310993102, guid: 54f3340298537426e96a6cc530e2d5d8, type: 3}
propertyPath: m_LocalPosition.x
value: 0

- target: {fileID: 4558743310993102, guid: 54f3340298537426e96a6cc530e2d5d8, type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 5643284048999299831, guid: 54f3340298537426e96a6cc530e2d5d8,
type: 3}
propertyPath: m_LocalPosition.x
value: 3.19
objectReference: {fileID: 0}
- target: {fileID: 7843730402782877929, guid: 54f3340298537426e96a6cc530e2d5d8,
type: 3}
propertyPath: m_LocalPosition.z
value: -1.2
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 54f3340298537426e96a6cc530e2d5d8, type: 3}

m_Name:
m_EditorClassIdentifier:
gravityMultiplier: 1
monitorVerticalOffset: 0
reuseCollisionCallbacks: 1
--- !u!114 &1574236051
MonoBehaviour:
m_ObjectHideFlags: 0

blueMaterial: {fileID: 2100000, guid: c9fa44c2c3f8ce74ca39a3355ea42631, type: 2}
randomizePlayersTeamForTraining: 0
agentRunSpeed: 2
strikerPunish: -0.1
strikerReward: 1
goaliePunish: -1
goalieReward: 0.1
--- !u!1001 &1606160104
PrefabInstance:
m_ObjectHideFlags: 0

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


using System;
//using System;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;

if (m_BehaviorParameters.TeamId == (int)Team.Blue)
{
team = Team.Blue;
m_Transform = new Vector3(transform.position.x - 4f, .5f, transform.position.z);
m_Transform = new Vector3(transform.position.x - 3f, .5f, transform.position.z);
m_Transform = new Vector3(transform.position.x + 4f, .5f, transform.position.z);
m_Transform = new Vector3(transform.position.x + 3f, .5f, transform.position.z);
}
if (position == Position.Goalie)
{

timePenalty = 0;
m_BallTouch = m_ResetParams.GetWithDefault("ball_touch", 0);
var randomX = Random.Range(-3.0f, 3.0f);
var randomZ = Random.Range(-0.5f, 0.5f);
transform.position = m_Transform + new Vector3(randomX, 0f, randomZ);
if (team == Team.Purple)
{
transform.rotation = Quaternion.Euler(0f, -90f, 0f);

transform.rotation = Quaternion.Euler(0f, 90f, 0f);
}
transform.position = m_Transform;
agentRb.velocity = Vector3.zero;
agentRb.angularVelocity = Vector3.zero;
SetResetParameters();

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


public void ResetBall()
{
ball.transform.position = ballStartingPos;
var randomX = Random.Range(-2.0f, 2.0f);
var randomZ = Random.Range(-2.0f, 2.0f);
ball.transform.position = ballStartingPos + new Vector3(randomX, 0f, randomZ);
ballRb.velocity = Vector3.zero;
ballRb.angularVelocity = Vector3.zero;

正在加载...
取消
保存