浏览代码

Added Generic soccer agent for draws

/asymm-envs
Andrew Cohen 5 年前
当前提交
e892cb9a
共有 2 个文件被更改,包括 122 次插入112 次删除
  1. 216
      Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
  2. 18
      Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs

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


m_Model: {fileID: 11400000, guid: 9d26b71f04a2d4680a68d8de4f6b62e9, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: Soccer
m_TeamID: 1
m_useChildSensors: 1
m_BehaviorName: SoccerTwos
TeamId: 1
m_UseChildSensors: 1
--- !u!114 &114492261207303438
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
position: 2
agentRb: {fileID: 0}
--- !u!114 &114320493772006642
MonoBehaviour:

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleRayPerceptionSensor
detectableTags:
m_SensorName: PurpleRayPerceptionSensor
m_DetectableTags:
- ball
- purpleGoal
- blueGoal

raysPerDirection: 5
maxRayDegrees: 60
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!114 &9152743230243588598
MonoBehaviour:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
DecisionPeriod: 5
RepeatAction: 1
TakeActionsBetweenDecisions: 1
offsetStep: 0
--- !u!1 &1100217258374548
GameObject:

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

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
position: 2
agentRb: {fileID: 0}
--- !u!114 &114516244030127556
MonoBehaviour:

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueRayPerceptionSensor
detectableTags:
m_SensorName: BlueRayPerceptionSensor
m_DetectableTags:
- ball
- blueGoal
- purpleGoal

raysPerDirection: 5
maxRayDegrees: 60
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!114 &404683423509059512
MonoBehaviour:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
DecisionPeriod: 5
RepeatAction: 1
TakeActionsBetweenDecisions: 1
offsetStep: 0
--- !u!1 &1141134673700168
GameObject:

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleRayPerceptionSensorReverse
detectableTags:
m_SensorName: PurpleRayPerceptionSensorReverse
m_DetectableTags:
- ball
- purpleGoal
- blueGoal

raysPerDirection: 1
maxRayDegrees: 45
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 1
m_MaxRayDegrees: 45
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!1 &742736642297762088
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueRayPerceptionSensorReverse
detectableTags:
m_SensorName: BlueRayPerceptionSensorReverse
m_DetectableTags:
- ball
- blueGoal
- purpleGoal

raysPerDirection: 1
maxRayDegrees: 45
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 1
m_MaxRayDegrees: 45
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!1 &2016057044266316337
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueRayPerceptionSensorReverse
detectableTags:
m_SensorName: BlueRayPerceptionSensorReverse
m_DetectableTags:
- ball
- blueGoal
- purpleGoal

raysPerDirection: 1
maxRayDegrees: 45
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 1
m_MaxRayDegrees: 45
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!1 &4599713170205044794
GameObject:
m_ObjectHideFlags: 0

m_Model: {fileID: 11400000, guid: 9d26b71f04a2d4680a68d8de4f6b62e9, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: Soccer
m_TeamID: 1
m_useChildSensors: 1
m_BehaviorName: SoccerTwos
TeamId: 1
m_UseChildSensors: 1
--- !u!114 &5320024511406682322
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
position: 2
agentRb: {fileID: 0}
--- !u!114 &1023485123796557062
MonoBehaviour:

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleRayPerceptionSensor
detectableTags:
m_SensorName: PurpleRayPerceptionSensor
m_DetectableTags:
- ball
- purpleGoal
- blueGoal

raysPerDirection: 5
maxRayDegrees: 60
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!114 &8734522883866558980
MonoBehaviour:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
DecisionPeriod: 5
RepeatAction: 1
TakeActionsBetweenDecisions: 1
offsetStep: 0
--- !u!1 &6442519122303792292
GameObject:

m_Model: {fileID: 11400000, guid: 9d26b71f04a2d4680a68d8de4f6b62e9, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: Soccer
m_TeamID: 0
m_useChildSensors: 1
m_BehaviorName: SoccerTwos
TeamId: 0
m_UseChildSensors: 1
--- !u!114 &5379409612883756837
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 2a2688ef4a36349f9aa010020c32d198, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
position: 2
agentRb: {fileID: 0}
--- !u!114 &2562571719799803906
MonoBehaviour:

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: BlueRayPerceptionSensor
detectableTags:
m_SensorName: BlueRayPerceptionSensor
m_DetectableTags:
- ball
- blueGoal
- purpleGoal

raysPerDirection: 5
maxRayDegrees: 60
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 5
m_MaxRayDegrees: 60
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5
--- !u!114 &1018414316889932458
MonoBehaviour:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
DecisionPeriod: 5
RepeatAction: 1
TakeActionsBetweenDecisions: 1
offsetStep: 0
--- !u!1 &8673569163220857793
GameObject:

m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: PurpleRayPerceptionSensorReverse
detectableTags:
m_SensorName: PurpleRayPerceptionSensorReverse
m_DetectableTags:
- ball
- purpleGoal
- blueGoal

raysPerDirection: 1
maxRayDegrees: 45
sphereCastRadius: 0.5
rayLength: 20
rayLayerMask:
m_RaysPerDirection: 1
m_MaxRayDegrees: 45
m_SphereCastRadius: 0.5
m_RayLength: 20
m_RayLayerMask:
observationStacks: 3
m_ObservationStacks: 3
useWorldPositions: 1
startVerticalOffset: 0.5
endVerticalOffset: 0.5
m_StartVerticalOffset: 0.5
m_EndVerticalOffset: 0.5

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


public enum Position
{
Striker,
Goalie
Goalie,
Generic
}
[HideInInspector]

team = Team.Purple;
m_Transform = new Vector3(transform.position.x + 4f, .5f, transform.position.z);
}
if (position == Position.Striker)
{
m_Power = 2000f;
m_LateralSpeed = 0.3f;
}
else if (position == Position.Goalie)
if (position == Position.Goalie)
}
else
{
m_Power = 2000f;
m_LateralSpeed = 0.3f;
}
m_SoccerSettings = FindObjectOfType<SoccerSettings>();
agentRb = GetComponent<Rigidbody>();

public override void OnActionReceived(float[] vectorAction)
{
// Generic gets nothing
if (position == Position.Striker)
{
// Existential penalty for Strikers.

// Existential bonus for Goalies.
AddReward(1f / 3000f);
}
MoveAgent(vectorAction);
}

正在加载...
取消
保存