Chris Elion
4 年前
当前提交
1038d4de
共有 12 个文件被更改,包括 2263 次插入 和 0 次删除
-
1Project/Packages/manifest.json
-
10Project/ProjectSettings/ProjectSettings.asset
-
8Project/Assets/ML-Agents/Examples/CamTest.meta
-
1001Project/Assets/ML-Agents/Examples/CamTest/CamTest.onnx
-
15Project/Assets/ML-Agents/Examples/CamTest/CamTest.onnx.meta
-
1001Project/Assets/ML-Agents/Examples/CamTest/CamTest.unity
-
7Project/Assets/ML-Agents/Examples/CamTest/CamTest.unity.meta
-
115Project/Assets/ML-Agents/Examples/CamTest/CamTestAgent.prefab
-
7Project/Assets/ML-Agents/Examples/CamTest/CamTestAgent.prefab.meta
-
87Project/Assets/ML-Agents/Examples/CamTest/TestDecisionRequester.cs
-
11Project/Assets/ML-Agents/Examples/CamTest/TestDecisionRequester.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: f6a0bb0d122954d2e88e2d97563afd76 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Project/Assets/ML-Agents/Examples/CamTest/CamTest.onnx
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: c77af5fc4b2154a66ab6a02e05e178f5 |
|||
ScriptedImporter: |
|||
fileIDToRecycleName: |
|||
11400000: main obj |
|||
11400002: model data |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 683b6cb6d0a474744822c888b46772c9, type: 3} |
|||
optimizeModel: 1 |
|||
forceArbitraryBatchSize: 1 |
|||
treatErrorsAsWarnings: 0 |
|||
importMode: 1 |
1001
Project/Assets/ML-Agents/Examples/CamTest/CamTest.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 10a5cc455accc4fc9be1f3f32b636be8 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &5980327471525392170 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 5980327471525392342} |
|||
- component: {fileID: 5980327471525392169} |
|||
- component: {fileID: 5980327471525392168} |
|||
- component: {fileID: 5980327471525392171} |
|||
- component: {fileID: 5980327471525392343} |
|||
m_Layer: 0 |
|||
m_Name: CamTestAgent |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &5980327471525392342 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5980327471525392170} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &5980327471525392169 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5980327471525392170} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 5d1c4e0b1822b495aa52bc52839ecb30, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_BrainParameters: |
|||
VectorObservationSize: 0 |
|||
NumStackedVectorObservations: 1 |
|||
m_ActionSpec: |
|||
m_NumContinuousActions: 1 |
|||
BranchSizes: |
|||
VectorActionSize: 01000000 |
|||
VectorActionDescriptions: [] |
|||
VectorActionSpaceType: 1 |
|||
hasUpgradedBrainParametersWithActionSpec: 1 |
|||
m_Model: {fileID: 11400000, guid: c77af5fc4b2154a66ab6a02e05e178f5, type: 3} |
|||
m_InferenceDevice: 2 |
|||
m_BehaviorType: 0 |
|||
m_BehaviorName: My Behavior |
|||
TeamId: 0 |
|||
m_UseChildSensors: 1 |
|||
m_UseChildActuators: 1 |
|||
m_ObservableAttributeHandling: 0 |
|||
--- !u!114 &5980327471525392168 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5980327471525392170} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 88b6042bc9a5d4aa58d931eae49442e5, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
agentParameters: |
|||
maxStep: 0 |
|||
hasUpgradedFromAgentParameters: 1 |
|||
MaxStep: 0 |
|||
--- !u!114 &5980327471525392171 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5980327471525392170} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 282f342c2ab144bf38be65d4d0c4e07d, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_Camera: {fileID: 0} |
|||
m_SensorName: CameraSensor |
|||
m_Width: 84 |
|||
m_Height: 84 |
|||
m_Grayscale: 0 |
|||
m_ObservationStacks: 1 |
|||
m_Compression: 1 |
|||
--- !u!114 &5980327471525392343 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5980327471525392170} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 3a5c9d521e5ef4759a8246a07d52221e, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
DecisionPeriod: 5 |
|||
TakeActionsBetweenDecisions: 1 |
|
|||
fileFormatVersion: 2 |
|||
guid: 6b632162d3b5b4dc9a5eacac08ebc1c4 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using Unity.MLAgents; |
|||
|
|||
public class TestDecisionRequester : MonoBehaviour |
|||
{ |
|||
public enum SteppingMode |
|||
{ |
|||
StepAllAgentsEvery5Frames = 0, |
|||
Step2AgentsEachFrame = 1 |
|||
} |
|||
|
|||
public SteppingMode Mode = SteppingMode.StepAllAgentsEvery5Frames; |
|||
private int StepCount = 0; |
|||
private Agent[] m_Agents; |
|||
private double[] m_RunningAverageMs = new double[2]; |
|||
private int[] m_RunningCount = new int[2]; |
|||
|
|||
static double s_TicksToMilliseconds = 1e-4; // 100 ns per tick
|
|||
|
|||
private void Awake() |
|||
{ |
|||
m_Agents = FindObjectsOfType<Agent>(); |
|||
Academy.Instance.AutomaticSteppingEnabled = false; |
|||
} |
|||
|
|||
private void FixedUpdate() |
|||
{ |
|||
if (Mode == SteppingMode.StepAllAgentsEvery5Frames) |
|||
{ |
|||
if ((StepCount % 5) == 0) |
|||
{ |
|||
for (var i = 0; i < m_Agents.Length; i++) |
|||
{ |
|||
m_Agents[i].RequestDecision(); |
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
for (var i = 0; i < m_Agents.Length; i++) |
|||
{ |
|||
if (i % 5 == StepCount % 5) |
|||
{ |
|||
m_Agents[i].RequestDecision(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
var startTicks = DateTime.Now.Ticks; |
|||
Academy.Instance.EnvironmentStep(); |
|||
var afterTicks = DateTime.Now.Ticks; |
|||
// Update
|
|||
{ |
|||
var elapsedMs = s_TicksToMilliseconds * (afterTicks - startTicks); |
|||
m_RunningCount[(int)Mode]++; |
|||
if (m_RunningCount[(int)Mode] == 1) |
|||
{ |
|||
m_RunningAverageMs[(int)Mode] = elapsedMs; |
|||
} |
|||
else |
|||
{ |
|||
m_RunningAverageMs[(int)Mode] = m_RunningAverageMs[(int)Mode] + (elapsedMs - m_RunningAverageMs[(int)Mode]) / m_RunningCount[(int)Mode]; |
|||
} |
|||
} |
|||
|
|||
|
|||
StepCount++; |
|||
if (StepCount % 1000 == 0) |
|||
{ |
|||
// Switch mode
|
|||
Mode = (Mode == SteppingMode.StepAllAgentsEvery5Frames) |
|||
? SteppingMode.Step2AgentsEachFrame |
|||
: SteppingMode.StepAllAgentsEvery5Frames; |
|||
|
|||
Debug.Log($"Average Academy Step:" + |
|||
$"\n\tStep2AgentsEachFrame: {m_RunningAverageMs[(int)SteppingMode.Step2AgentsEachFrame]} ms" + |
|||
$"\n\tStepAllAgentsEvery5Frames: {m_RunningAverageMs[(int)SteppingMode.StepAllAgentsEvery5Frames]} ms" |
|||
); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7ab2c1d17d3484b3aac5381badc3acf6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue