浏览代码

Merge pull request #4737 from Unity-Technologies/goal-gridworld-sensor

Use GoalSensor in GridWorld
/goal-conditioning
GitHub 4 年前
当前提交
ba21e419
共有 5 个文件被更改,包括 39 次插入6 次删除
  1. 16
      Project/Assets/ML-Agents/Examples/GridWorld/Prefabs/Area.prefab
  2. 18
      Project/Assets/ML-Agents/Examples/GridWorld/Scenes/GridWorld.unity
  3. 4
      Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs
  4. 3
      ml-agents-envs/mlagents_envs/base_env.py
  5. 4
      ml-agents/mlagents/trainers/tests/simple_test_envs.py

16
Project/Assets/ML-Agents/Examples/GridWorld/Prefabs/Area.prefab


- component: {fileID: 114650561397225712}
- component: {fileID: 114889700908650620}
- component: {fileID: 7980686505185502968}
- component: {fileID: 8359584214300847863}
m_Layer: 8
m_Name: Agent
m_TagString: agent

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
VectorObservationSize: 2
VectorObservationSize: 0
NumStackedVectorObservations: 1
VectorActionSize: 05000000
VectorActionDescriptions: []

m_Name:
m_EditorClassIdentifier:
debugCommandLineOverride:
--- !u!114 &8359584214300847863
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1488387672112076}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 163dac4bcbb2f4d8499db2cdcb22a89e, type: 3}
m_Name:
m_EditorClassIdentifier:
observationSize: 1
--- !u!1 &1625008366184734
GameObject:
m_ObjectHideFlags: 0

18
Project/Assets/ML-Agents/Examples/GridWorld/Scenes/GridWorld.unity


- component: {fileID: 125487790}
- component: {fileID: 125487787}
- component: {fileID: 125487791}
- component: {fileID: 125487792}
m_Layer: 8
m_Name: RenderTextureAgent
m_TagString: agent

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
VectorObservationSize: 2
VectorObservationSize: 0
NumStackedVectorObservations: 1
VectorActionSize: 05000000
VectorActionDescriptions: []

m_Grayscale: 0
m_ObservationStacks: 1
m_Compression: 1
--- !u!114 &125487792
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 125487785}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 163dac4bcbb2f4d8499db2cdcb22a89e, type: 3}
m_Name:
m_EditorClassIdentifier:
observationSize: 1
--- !u!1 &260425459
GameObject:
m_ObjectHideFlags: 0

- target: {fileID: 114935253044749092, guid: 5c2bd19e4bbda4991b74387ca5d28156,
type: 3}
propertyPath: m_BrainParameters.VectorObservationSize
value: 2
value: 0
objectReference: {fileID: 0}
- target: {fileID: 114935253044749092, guid: 5c2bd19e4bbda4991b74387ca5d28156,
type: 3}

4
Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs


"masking turned on may not behave optimally when action masking is turned off.")]
public bool maskActions = true;
GoalSensorComponent goalSensor;
public GridGoal gridGoal;

{
Array values = Enum.GetValues(typeof(GridGoal));
int goalNum = (int)gridGoal;
sensor.AddOneHotObservation(goalNum, values.Length);
goalSensor = this.GetComponent<GoalSensorComponent>();
goalSensor.AddGoal(goalNum);
}
public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask)

3
ml-agents-envs/mlagents_envs/base_env.py


class SensorType(Enum):
OBSERVATION = 0
PARAMETERIZATION = 1
GOAL = 1
class _ActionTupleBase(ABC):
"""

4
ml-agents/mlagents/trainers/tests/simple_test_envs.py


continuous_action_size + discrete_action_size
) # to set the goals/positions
self.action_spec = action_spec
self.behavior_spec = BehaviorSpec(self._make_obs_spec(), sensor_types, action_spec)
self.behavior_spec = BehaviorSpec(
self._make_obs_spec(), sensor_types, action_spec
)
self.action_spec = action_spec
self.names = brain_names
self.positions: Dict[str, List[float]] = {}

正在加载...
取消
保存