浏览代码
Revamp Crawler & Walker (#841)
Revamp Crawler & Walker (#841)
* Revamps agent code for walker and crawler environments to use shared JointDriveController system. * Crawler has been reworked to be very cute. * Crawler & Walker environments have been reworked to be visually consistent. * Added Dynamic Crawler scene. * All scenes re-trained and new models added. * Documentation changes./develop-generalizationTraining-TrainerController
GitHub
7 年前
当前提交
c9c9e147
共有 104 个文件被更改,包括 11335 次插入 和 3314 次删除
-
1.gitignore
-
13docs/Learning-Environment-Examples.md
-
999docs/images/crawler.png
-
999docs/images/walker.png
-
7python/trainer_config.yaml
-
5unity-environment/Assets/ML-Agents/Examples/Crawler.meta
-
2unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs.meta
-
881unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
-
5unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab.meta
-
2unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts.meta
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs
-
5unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs.meta
-
5unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels.meta
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Agent.mat.meta
-
15unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat
-
4unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Black.mat.meta
-
4unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Block.mat.meta
-
6unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/BlueAgent.mat
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerGoal.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerMany.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerRectangle.mat.meta
-
16unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerSquare.mat
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/FailGround.mat.meta
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Goal.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Grass.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ground.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Obstacle.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/SuccessGround.mat.meta
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/UIDefault.mat.meta
-
12unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat
-
4unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat.meta
-
32unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs.meta
-
132unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerAgent.prefab
-
935unity-environment/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
-
6unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs
-
237unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
-
985unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes
-
2unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes.meta
-
1unity-environment/ProjectSettings/EditorBuildSettings.asset
-
14unity-environment/ProjectSettings/ProjectSettings.asset
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Materials.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab.meta
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes.meta
-
269unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
-
13unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes
-
7unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes
-
7unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.mat.meta
-
3unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png
-
84unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png.meta
-
195unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd
-
84unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.mat.meta
-
58unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs
-
11unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs.meta
-
178unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs
-
11unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs.meta
-
40unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs
-
11unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs.meta
-
76unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat
-
8unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat.meta
-
180unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab.meta
-
76unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.mat
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.mat
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.mat.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
-
7unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity.meta
-
12unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs.meta
-
19unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs
-
12unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs.meta
-
21unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs
-
12unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs.meta
-
137unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs
999
docs/images/crawler.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
999
docs/images/walker.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: f156237910cf946e78a82c48410fef52 |
|||
guid: 3aea709eb8dc04856aaa6d93573fb0df |
|||
timeCreated: 1517447132 |
|||
licenseType: Free |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
881
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 3db4283e33af74336bfedb01d0e011bf |
|||
timeCreated: 1508548205 |
|||
licenseType: Free |
|||
guid: 0e8a62cb7c8f0483ebd12046bae9ca05 |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4a3b975c6f9424f52aa1d7b9b87b6e1a |
|||
guid: 0b737d19c4232404389d1325808e5b4d |
|||
timeCreated: 1508478093 |
|||
licenseType: Free |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 260483cdfc6b14e26823a02f23bd8baa |
|||
timeCreated: 1506189720 |
|||
licenseType: Pro |
|||
mainObjectFileID: 2100000 |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: edd958d75ed1448138de86f3335ea4fa |
|||
timeCreated: 1497123463 |
|||
licenseType: Pro |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: f4abcb290251940948a31b349a6f9995 |
|||
timeCreated: 1506379314 |
|||
licenseType: Pro |
|||
mainObjectFileID: 2100000 |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 624b24bbec31f44babfb57ef2dfbc537 |
|||
timeCreated: 1506189863 |
|||
licenseType: Pro |
|||
mainObjectFileID: 2100000 |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 463606e709fd24f29ac1096d0aade647 |
|||
timeCreated: 1503267725 |
|||
licenseType: Free |
|||
mainObjectFileID: 2100000 |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 214660f4189b04cada2137381f5c3607 |
|||
timeCreated: 1497379290 |
|||
licenseType: Pro |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
935
unity-environment/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
985
unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 6f158a795796a47a68104cc5eff941a1 |
|||
guid: 8d3f9a4b927984343b18c82559165047 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1b2e258570af540139c1ef84be60b3ea |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 0058b366f9d6d44a3ba35beb06b0174b |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 1b9d167a4e71146a883212e4f08bda88 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 60c86839d191546c9bf58ce6a2824987 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using MLAgents; |
|||
|
|||
[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
|
|||
public class CrawlerAgent : Agent |
|||
{ |
|||
[Header("Target To Walk Towards")] [Space(10)] |
|||
public Transform target; |
|||
|
|||
public Transform ground; |
|||
public bool detectTargets; |
|||
public bool respawnTargetWhenTouched; |
|||
public float targetSpawnRadius; |
|||
|
|||
[Header("Body Parts")] [Space(10)] public Transform body; |
|||
public Transform leg0Upper; |
|||
public Transform leg0Lower; |
|||
public Transform leg1Upper; |
|||
public Transform leg1Lower; |
|||
public Transform leg2Upper; |
|||
public Transform leg2Lower; |
|||
public Transform leg3Upper; |
|||
public Transform leg3Lower; |
|||
|
|||
[Header("Joint Settings")] [Space(10)] JointDriveController jdController; |
|||
Vector3 dirToTarget; |
|||
float movingTowardsDot; |
|||
float facingDot; |
|||
|
|||
[Header("Reward Functions To Use")] [Space(10)] |
|||
public bool rewardMovingTowardsTarget; // Agent should move towards target
|
|||
|
|||
public bool rewardFacingTarget; // Agent should face the target
|
|||
public bool rewardUseTimePenalty; // Hurry up
|
|||
|
|||
[Header("Foot Grounded Visualization")] [Space(10)] |
|||
public bool useFootGroundedVisualization; |
|||
|
|||
public MeshRenderer foot0; |
|||
public MeshRenderer foot1; |
|||
public MeshRenderer foot2; |
|||
public MeshRenderer foot3; |
|||
public Material groundedMaterial; |
|||
public Material unGroundedMaterial; |
|||
bool isNewDecisionStep; |
|||
int currentDecisionStep; |
|||
|
|||
public override void InitializeAgent() |
|||
{ |
|||
jdController = GetComponent<JointDriveController>(); |
|||
currentDecisionStep = 1; |
|||
|
|||
//Setup each body part
|
|||
jdController.SetupBodyPart(body); |
|||
jdController.SetupBodyPart(leg0Upper); |
|||
jdController.SetupBodyPart(leg0Lower); |
|||
jdController.SetupBodyPart(leg1Upper); |
|||
jdController.SetupBodyPart(leg1Lower); |
|||
jdController.SetupBodyPart(leg2Upper); |
|||
jdController.SetupBodyPart(leg2Lower); |
|||
jdController.SetupBodyPart(leg3Upper); |
|||
jdController.SetupBodyPart(leg3Lower); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// We only need to change the joint settings based on decision freq.
|
|||
/// </summary>
|
|||
public void IncrementDecisionTimer() |
|||
{ |
|||
if (currentDecisionStep == agentParameters.numberOfActionsBetweenDecisions |
|||
|| agentParameters.numberOfActionsBetweenDecisions == 1) |
|||
{ |
|||
currentDecisionStep = 1; |
|||
isNewDecisionStep = true; |
|||
} |
|||
else |
|||
{ |
|||
currentDecisionStep++; |
|||
isNewDecisionStep = false; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Add relevant information on each body part to observations.
|
|||
/// </summary>
|
|||
public void CollectObservationBodyPart(BodyPart bp) |
|||
{ |
|||
var rb = bp.rb; |
|||
AddVectorObs(bp.groundContact.touchingGround ? 1 : 0); // Whether the bp touching the ground
|
|||
AddVectorObs(rb.velocity); |
|||
AddVectorObs(rb.angularVelocity); |
|||
|
|||
if (bp.rb.transform != body) |
|||
{ |
|||
Vector3 localPosRelToBody = body.InverseTransformPoint(rb.position); |
|||
AddVectorObs(localPosRelToBody); |
|||
AddVectorObs(bp.currentXNormalizedRot); // Current x rot
|
|||
AddVectorObs(bp.currentYNormalizedRot); // Current y rot
|
|||
AddVectorObs(bp.currentZNormalizedRot); // Current z rot
|
|||
AddVectorObs(bp.currentStrength / jdController.maxJointForceLimit); |
|||
} |
|||
} |
|||
|
|||
public override void CollectObservations() |
|||
{ |
|||
jdController.GetCurrentJointForces(); |
|||
// Normalize dir vector to help generalize
|
|||
AddVectorObs(dirToTarget.normalized); |
|||
|
|||
// Forward & up to help with orientation
|
|||
AddVectorObs(body.transform.position.y); |
|||
AddVectorObs(body.forward); |
|||
AddVectorObs(body.up); |
|||
foreach (var bodyPart in jdController.bodyPartsDict.Values) |
|||
{ |
|||
CollectObservationBodyPart(bodyPart); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Agent touched the target
|
|||
/// </summary>
|
|||
public void TouchedTarget() |
|||
{ |
|||
AddReward(1f); |
|||
if (respawnTargetWhenTouched) |
|||
{ |
|||
GetRandomTargetPos(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Moves target to a random position within specified radius.
|
|||
/// </summary>
|
|||
public void GetRandomTargetPos() |
|||
{ |
|||
Vector3 newTargetPos = Random.insideUnitSphere * targetSpawnRadius; |
|||
newTargetPos.y = 5; |
|||
target.position = newTargetPos + ground.position; |
|||
} |
|||
|
|||
public override void AgentAction(float[] vectorAction, string textAction) |
|||
{ |
|||
if (detectTargets) |
|||
{ |
|||
foreach (var bodyPart in jdController.bodyPartsDict.Values) |
|||
{ |
|||
if (bodyPart.targetContact && !IsDone() && bodyPart.targetContact.touchingTarget) |
|||
{ |
|||
TouchedTarget(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Update pos to target
|
|||
dirToTarget = target.position - jdController.bodyPartsDict[body].rb.position; |
|||
|
|||
// If enabled the feet will light up green when the foot is grounded.
|
|||
// This is just a visualization and isn't necessary for function
|
|||
if (useFootGroundedVisualization) |
|||
{ |
|||
foot0.material = jdController.bodyPartsDict[leg0Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
foot1.material = jdController.bodyPartsDict[leg1Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
foot2.material = jdController.bodyPartsDict[leg2Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
foot3.material = jdController.bodyPartsDict[leg3Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
} |
|||
|
|||
// Joint update logic only needs to happen when a new decision is made
|
|||
if (isNewDecisionStep) |
|||
{ |
|||
// The dictionary with all the body parts in it are in the jdController
|
|||
var bpDict = jdController.bodyPartsDict; |
|||
|
|||
int i = -1; |
|||
// Pick a new target joint rotation
|
|||
bpDict[leg0Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg1Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg2Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg3Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg0Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
bpDict[leg1Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
bpDict[leg2Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
bpDict[leg3Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
|
|||
// Update joint strength
|
|||
bpDict[leg0Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg1Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg2Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg3Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg0Lower].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg1Lower].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg2Lower].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg3Lower].SetJointStrength(vectorAction[++i]); |
|||
} |
|||
|
|||
// Set reward for this step according to mixture of the following elements.
|
|||
if (rewardMovingTowardsTarget) |
|||
{ |
|||
RewardFunctionMovingTowards(); |
|||
} |
|||
|
|||
if (rewardFacingTarget) |
|||
{ |
|||
RewardFunctionFacingTarget(); |
|||
} |
|||
|
|||
if (rewardUseTimePenalty) |
|||
{ |
|||
RewardFunctionTimePenalty(); |
|||
} |
|||
|
|||
IncrementDecisionTimer(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Reward moving towards target & Penalize moving away from target.
|
|||
/// </summary>
|
|||
void RewardFunctionMovingTowards() |
|||
{ |
|||
movingTowardsDot = Vector3.Dot(jdController.bodyPartsDict[body].rb.velocity, dirToTarget.normalized); |
|||
AddReward(0.03f * movingTowardsDot); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Reward facing target & Penalize facing away from target
|
|||
/// </summary>
|
|||
void RewardFunctionFacingTarget() |
|||
{ |
|||
facingDot = Vector3.Dot(dirToTarget.normalized, body.forward); |
|||
AddReward(0.01f * facingDot); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Existential penalty for time-contrained tasks.
|
|||
/// </summary>
|
|||
void RewardFunctionTimePenalty() |
|||
{ |
|||
AddReward(-0.001f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Loop over body parts and reset them to initial conditions.
|
|||
/// </summary>
|
|||
public override void AgentReset() |
|||
{ |
|||
if (dirToTarget != Vector3.zero) |
|||
{ |
|||
transform.rotation = Quaternion.LookRotation(dirToTarget); |
|||
} |
|||
|
|||
foreach (var bodyPart in jdController.bodyPartsDict.Values) |
|||
{ |
|||
bodyPart.Reset(bodyPart); |
|||
} |
|||
|
|||
isNewDecisionStep = true; |
|||
currentDecisionStep = 1; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2f37c30a5e8d04117947188818902ef3 |
|||
timeCreated: 1525902546 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 310a6ef92323640b48a7342988a69466 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 24ef4b74625ba4c53b782ec33ad9f7d6 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: DarkGridFloor |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 200, y: 100} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3} |
|||
m_Scale: {x: 200, y: 100} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0, g: 0.7255683, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: f79af4fbbccd341578da68fd5d3c7e0d |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: LightGridFloor |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 150, y: 5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: 9f297c7b7df5644da8b28a9b44692230, type: 3} |
|||
m_Scale: {x: 150, y: 5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.735849, g: 0.735849, b: 0.735849, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c6faed37a5e84a94aa60c2eb61dd263 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: LightGridFloorSquare |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 5, y: 5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: 9f297c7b7df5644da8b28a9b44692230, type: 3} |
|||
m_Scale: {x: 5, y: 5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.735849, g: 0.735849, b: 0.735849, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 97796528aca714d159b1093f49bca242 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: White |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0.107 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.8962264, g: 0.8962264, b: 0.8962264, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: d633725e980bb4ac5b0dd309bad3702f |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
3
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: eb3fbc74cf5a94322bfcd3a9136f2d57 |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
externalObjects: {} |
|||
serializedVersion: 5 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- serializedVersion: 2 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
195
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 9f297c7b7df5644da8b28a9b44692230 |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
externalObjects: {} |
|||
serializedVersion: 5 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- serializedVersion: 2 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: groundGreen |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.64005125, g: 0.755, b: 0.517175, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: cca885103c98844ffb5fdbf5b869f2b1 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: groundGrey |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 200, y: 100} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 200, y: 100} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.56766325, g: 0.6431373, b: 0.38652548, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 45a6675c4c7774fbdaf694dff79b2f7a |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: groundRed |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0.703, g: 0.30088398, b: 0.30088398, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: bba9559f82e584fb4b490985a8fc3747 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
//This script lets you change time scale during training. It is not a required script for this demo to function
|
|||
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace MLAgents |
|||
{ |
|||
|
|||
public class AdjustTrainingTimescale : MonoBehaviour { |
|||
|
|||
// Update is called once per frame
|
|||
void Update () |
|||
{ |
|||
|
|||
if (Input.GetKeyDown(KeyCode.Alpha1)) |
|||
{ |
|||
Time.timeScale = 1f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha2)) |
|||
{ |
|||
Time.timeScale = 2f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha3)) |
|||
{ |
|||
Time.timeScale = 3f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha4)) |
|||
{ |
|||
Time.timeScale = 4f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha5)) |
|||
{ |
|||
Time.timeScale = 5f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha6)) |
|||
{ |
|||
Time.timeScale = 6f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha7)) |
|||
{ |
|||
Time.timeScale = 7f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha8)) |
|||
{ |
|||
Time.timeScale = 8f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha9)) |
|||
{ |
|||
Time.timeScale = 9f; |
|||
} |
|||
if (Input.GetKeyDown(KeyCode.Alpha0)) |
|||
{ |
|||
Time.timeScale *= 2f; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3d6f3eab3776b4fb79724ac4216dfd7b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace MLAgents |
|||
{ |
|||
/// <summary>
|
|||
/// Used to store relevant information for acting and learning for each body part in agent.
|
|||
/// </summary>
|
|||
[System.Serializable] |
|||
public class BodyPart |
|||
{ |
|||
[Header("Body Part Info")] [Space(10)] public ConfigurableJoint joint; |
|||
public Rigidbody rb; |
|||
[HideInInspector] public Vector3 startingPos; |
|||
[HideInInspector] public Quaternion startingRot; |
|||
|
|||
[Header("Ground & Target Contact")] [Space(10)] |
|||
public GroundContact groundContact; |
|||
|
|||
public TargetContact targetContact; |
|||
|
|||
[HideInInspector] public JointDriveController thisJDController; |
|||
|
|||
[Header("Current Joint Settings")] [Space(10)] |
|||
public Vector3 currentEularJointRotation; |
|||
|
|||
[HideInInspector] public float currentStrength; |
|||
public float currentXNormalizedRot; |
|||
public float currentYNormalizedRot; |
|||
public float currentZNormalizedRot; |
|||
|
|||
[Header("Other Debug Info")] [Space(10)] |
|||
public Vector3 currentJointForce; |
|||
|
|||
public float currentJointForceSqrMag; |
|||
public Vector3 currentJointTorque; |
|||
public float currentJointTorqueSqrMag; |
|||
public AnimationCurve jointForceCurve = new AnimationCurve(); |
|||
public AnimationCurve jointTorqueCurve = new AnimationCurve(); |
|||
|
|||
/// <summary>
|
|||
/// Reset body part to initial configuration.
|
|||
/// </summary>
|
|||
public void Reset(BodyPart bp) |
|||
{ |
|||
bp.rb.transform.position = bp.startingPos; |
|||
bp.rb.transform.rotation = bp.startingRot; |
|||
bp.rb.velocity = Vector3.zero; |
|||
bp.rb.angularVelocity = Vector3.zero; |
|||
if (bp.groundContact) |
|||
{ |
|||
bp.groundContact.touchingGround = false; |
|||
} |
|||
|
|||
if (bp.targetContact) |
|||
{ |
|||
bp.targetContact.touchingTarget = false; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Apply torque according to defined goal `x, y, z` angle and force `strength`.
|
|||
/// </summary>
|
|||
public void SetJointTargetRotation(float x, float y, float z) |
|||
{ |
|||
x = (x + 1f) * 0.5f; |
|||
y = (y + 1f) * 0.5f; |
|||
z = (z + 1f) * 0.5f; |
|||
|
|||
var xRot = Mathf.Lerp(joint.lowAngularXLimit.limit, joint.highAngularXLimit.limit, x); |
|||
var yRot = Mathf.Lerp(-joint.angularYLimit.limit, joint.angularYLimit.limit, y); |
|||
var zRot = Mathf.Lerp(-joint.angularZLimit.limit, joint.angularZLimit.limit, z); |
|||
|
|||
currentXNormalizedRot = |
|||
Mathf.InverseLerp(joint.lowAngularXLimit.limit, joint.highAngularXLimit.limit, xRot); |
|||
currentYNormalizedRot = Mathf.InverseLerp(-joint.angularYLimit.limit, joint.angularYLimit.limit, yRot); |
|||
currentZNormalizedRot = Mathf.InverseLerp(-joint.angularZLimit.limit, joint.angularZLimit.limit, zRot); |
|||
|
|||
joint.targetRotation = Quaternion.Euler(xRot, yRot, zRot); |
|||
currentEularJointRotation = new Vector3(xRot, yRot, zRot); |
|||
} |
|||
|
|||
public void SetJointStrength(float strength) |
|||
{ |
|||
var rawVal = (strength + 1f) * 0.5f * thisJDController.maxJointForceLimit; |
|||
var jd = new JointDrive |
|||
{ |
|||
positionSpring = thisJDController.maxJointSpring, |
|||
positionDamper = thisJDController.jointDampen, |
|||
maximumForce = rawVal |
|||
}; |
|||
joint.slerpDrive = jd; |
|||
currentStrength = jd.maximumForce; |
|||
} |
|||
} |
|||
|
|||
public class JointDriveController : MonoBehaviour |
|||
{ |
|||
[Header("Joint Drive Settings")] [Space(10)] |
|||
public float maxJointSpring; |
|||
|
|||
public float jointDampen; |
|||
public float maxJointForceLimit; |
|||
float facingDot; |
|||
|
|||
[HideInInspector] public Dictionary<Transform, BodyPart> bodyPartsDict = new Dictionary<Transform, BodyPart>(); |
|||
|
|||
[HideInInspector] public List<BodyPart> bodyPartsList = new List<BodyPart>(); |
|||
|
|||
/// <summary>
|
|||
/// Create BodyPart object and add it to dictionary.
|
|||
/// </summary>
|
|||
public void SetupBodyPart(Transform t) |
|||
{ |
|||
BodyPart bp = new BodyPart |
|||
{ |
|||
rb = t.GetComponent<Rigidbody>(), |
|||
joint = t.GetComponent<ConfigurableJoint>(), |
|||
startingPos = t.position, |
|||
startingRot = t.rotation |
|||
}; |
|||
bp.rb.maxAngularVelocity = 100; |
|||
|
|||
// Add & setup the ground contact script
|
|||
bp.groundContact = t.GetComponent<GroundContact>(); |
|||
if (!bp.groundContact) |
|||
{ |
|||
bp.groundContact = t.gameObject.AddComponent<GroundContact>(); |
|||
bp.groundContact.agent = gameObject.GetComponent<Agent>(); |
|||
} |
|||
else |
|||
{ |
|||
bp.groundContact.agent = gameObject.GetComponent<Agent>(); |
|||
} |
|||
|
|||
// Add & setup the target contact script
|
|||
bp.targetContact = t.GetComponent<TargetContact>(); |
|||
if (!bp.targetContact) |
|||
{ |
|||
bp.targetContact = t.gameObject.AddComponent<TargetContact>(); |
|||
} |
|||
|
|||
bp.thisJDController = this; |
|||
bodyPartsDict.Add(t, bp); |
|||
bodyPartsList.Add(bp); |
|||
} |
|||
|
|||
public void GetCurrentJointForces() |
|||
{ |
|||
foreach (var bodyPart in bodyPartsDict.Values) |
|||
{ |
|||
if (bodyPart.joint) |
|||
{ |
|||
bodyPart.currentJointForce = bodyPart.joint.currentForce; |
|||
bodyPart.currentJointForceSqrMag = bodyPart.joint.currentForce.magnitude; |
|||
bodyPart.currentJointTorque = bodyPart.joint.currentTorque; |
|||
bodyPart.currentJointTorqueSqrMag = bodyPart.joint.currentTorque.magnitude; |
|||
if (Application.isEditor) |
|||
{ |
|||
if (bodyPart.jointForceCurve.length > 1000) |
|||
{ |
|||
bodyPart.jointForceCurve = new AnimationCurve(); |
|||
} |
|||
|
|||
if (bodyPart.jointTorqueCurve.length > 1000) |
|||
{ |
|||
bodyPart.jointTorqueCurve = new AnimationCurve(); |
|||
} |
|||
|
|||
bodyPart.jointForceCurve.AddKey(Time.time, bodyPart.currentJointForceSqrMag); |
|||
bodyPart.jointTorqueCurve.AddKey(Time.time, bodyPart.currentJointTorqueSqrMag); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1b29724baddfa457da6eeab446fa49ca |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace MLAgents |
|||
{ |
|||
/// <summary>
|
|||
/// This class contains logic for locomotion agents with joints which might make contact with a target.
|
|||
/// By attaching this as a component to those joints, their contact with the ground can be used as
|
|||
/// an observation for that agent.
|
|||
/// </summary>
|
|||
[DisallowMultipleComponent] |
|||
public class TargetContact : MonoBehaviour |
|||
{ |
|||
[Header("Detect Targets")] public bool touchingTarget; |
|||
private const string Target = "target"; // Tag on target object.
|
|||
|
|||
/// <summary>
|
|||
/// Check for collision with a target.
|
|||
/// </summary>
|
|||
void OnCollisionEnter(Collision col) |
|||
{ |
|||
if (col.transform.CompareTag(Target)) |
|||
{ |
|||
touchingTarget = true; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Check for end of ground collision and reset flag appropriately.
|
|||
/// </summary>
|
|||
void OnCollisionExit(Collision other) |
|||
{ |
|||
if (other.transform.CompareTag(Target)) |
|||
{ |
|||
touchingTarget = false; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5086c435d3e8b44ffa8262a5c124661f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: LightGridFloorWalker |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 200, y: 75} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: 9f297c7b7df5644da8b28a9b44692230, type: 3} |
|||
m_Scale: {x: 200, y: 75} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 1 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 1, g: 1, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 11fc213bb7ed74bfaadd6ac3a2ca6213 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1001 &100100000 |
|||
Prefab: |
|||
m_ObjectHideFlags: 1 |
|||
serializedVersion: 2 |
|||
m_Modification: |
|||
m_TransformParent: {fileID: 0} |
|||
m_Modifications: [] |
|||
m_RemovedComponents: [] |
|||
m_ParentPrefab: {fileID: 0} |
|||
m_RootGameObject: {fileID: 1278435835893344} |
|||
m_IsPrefabParent: 1 |
|||
--- !u!1 &1004696678722388 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
serializedVersion: 5 |
|||
m_Component: |
|||
- component: {fileID: 4445455656062608} |
|||
- component: {fileID: 108207800777520784} |
|||
m_Layer: 0 |
|||
m_Name: Point Light |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!1 &1278435835893344 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
serializedVersion: 5 |
|||
m_Component: |
|||
- component: {fileID: 4160558395918834} |
|||
- component: {fileID: 33482419447541750} |
|||
- component: {fileID: 65421899250293674} |
|||
- component: {fileID: 23182017856683736} |
|||
- component: {fileID: 54584795304850826} |
|||
m_Layer: 0 |
|||
m_Name: TARGET |
|||
m_TagString: target |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &4160558395918834 |
|||
Transform: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1278435835893344} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 1000, y: 4, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: |
|||
- {fileID: 4445455656062608} |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!4 &4445455656062608 |
|||
Transform: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1004696678722388} |
|||
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: 4160558395918834} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!23 &23182017856683736 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1278435835893344} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 0 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RenderingLayerMask: 4294967295 |
|||
m_Materials: |
|||
- {fileID: 2100000, guid: edd958d75ed1448138de86f3335ea4fa, type: 2} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_PreserveUVs: 1 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 0 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
--- !u!33 &33482419447541750 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1278435835893344} |
|||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!54 &54584795304850826 |
|||
Rigidbody: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1278435835893344} |
|||
serializedVersion: 2 |
|||
m_Mass: 5 |
|||
m_Drag: 0 |
|||
m_AngularDrag: 0.05 |
|||
m_UseGravity: 1 |
|||
m_IsKinematic: 0 |
|||
m_Interpolate: 0 |
|||
m_Constraints: 0 |
|||
m_CollisionDetection: 0 |
|||
--- !u!65 &65421899250293674 |
|||
BoxCollider: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1278435835893344} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Size: {x: 1, y: 1, z: 1} |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
--- !u!108 &108207800777520784 |
|||
Light: |
|||
m_ObjectHideFlags: 1 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 100100000} |
|||
m_GameObject: {fileID: 1004696678722388} |
|||
m_Enabled: 1 |
|||
serializedVersion: 8 |
|||
m_Type: 2 |
|||
m_Color: {r: 1, g: 0.85834146, b: 0.472, a: 1} |
|||
m_Intensity: 2 |
|||
m_Range: 15 |
|||
m_SpotAngle: 30 |
|||
m_CookieSize: 10 |
|||
m_Shadows: |
|||
m_Type: 0 |
|||
m_Resolution: -1 |
|||
m_CustomResolution: -1 |
|||
m_Strength: 1 |
|||
m_Bias: 0.05 |
|||
m_NormalBias: 0.4 |
|||
m_NearPlane: 0.2 |
|||
m_Cookie: {fileID: 0} |
|||
m_DrawHalo: 0 |
|||
m_Flare: {fileID: 0} |
|||
m_RenderMode: 1 |
|||
m_CullingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
m_Lightmapping: 4 |
|||
m_AreaSize: {x: 1, y: 1} |
|||
m_BounceIntensity: 1 |
|||
m_ColorTemperature: 6570 |
|||
m_UseColorTemperature: 0 |
|||
m_ShadowRadius: 0 |
|||
m_ShadowAngle: 0 |
|
|||
fileFormatVersion: 2 |
|||
guid: fc8825060dab14c40a9a5dd609ca217b |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 94dced9d2186d4a76b970fb18ef6d7a6 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: DarkGridFloorMovingTargetCrawler |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 5, y: 5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3} |
|||
m_Scale: {x: 5, y: 5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 1, g: 1, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 82789c563353741debf1645e133f6d29 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 2100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: DarkGridFloorStaticCrawler |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 50, y: 2.5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3} |
|||
m_Scale: {x: 50, y: 2.5} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 1, g: 1, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: b7f3bd8fd3ae84ccfabb8a9421031bcd |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 2100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: cb09636e2bfd74254939fe22b12c28e1 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: d9a4e7d08037d49c895555d4fe344764 |
|||
timeCreated: 1508521562 |
|||
licenseType: Free |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: aeeb12a8f17db49f095fd1936d2798c9 |
|||
timeCreated: 1507411991 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class CrawlerBodyContact : MonoBehaviour { |
|||
|
|||
CrawlerAgentConfigurable agent; |
|||
|
|||
void Start(){ |
|||
agent = gameObject.transform.parent.gameObject.GetComponent<CrawlerAgentConfigurable>(); |
|||
} |
|||
|
|||
void OnTriggerEnter(Collider other){ |
|||
if (other.gameObject.name == "Ground") |
|||
{ |
|||
agent.fell = true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a1c672528369d465e9d8cd7511a7f679 |
|||
timeCreated: 1507592528 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class CrawlerLegContact : MonoBehaviour { |
|||
|
|||
public int index; |
|||
public CrawlerAgentConfigurable agent; |
|||
|
|||
void Start(){ |
|||
|
|||
} |
|||
|
|||
void OnCollisionStay(Collision other){ |
|||
if (other.gameObject.name == "Ground") |
|||
{ |
|||
agent.leg_touching[index] = true; |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2b1c61949ba3445eea83275fb5ce32c5 |
|||
timeCreated: 1507591712 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using MLAgents; |
|||
|
|||
public class CrawlerAgentConfigurable : Agent |
|||
{ |
|||
|
|||
public float strength; |
|||
float x_position; |
|||
[HideInInspector] |
|||
public bool[] leg_touching; |
|||
[HideInInspector] |
|||
public bool fell; |
|||
Vector3 past_velocity; |
|||
Transform body; |
|||
Rigidbody bodyRB; |
|||
public Transform[] limbs; |
|||
Rigidbody[] limbRBs; |
|||
Dictionary<GameObject, Vector3> transformsPosition; |
|||
Dictionary<GameObject, Quaternion> transformsRotation; |
|||
|
|||
public override void InitializeAgent() |
|||
{ |
|||
body = transform.Find("Sphere"); |
|||
bodyRB = body.GetComponent<Rigidbody>(); |
|||
transformsPosition = new Dictionary<GameObject, Vector3>(); |
|||
transformsRotation = new Dictionary<GameObject, Quaternion>(); |
|||
Transform[] allChildren = GetComponentsInChildren<Transform>(); |
|||
foreach (Transform child in allChildren) |
|||
{ |
|||
transformsPosition[child.gameObject] = child.position; |
|||
transformsRotation[child.gameObject] = child.rotation; |
|||
} |
|||
leg_touching = new bool[4]; |
|||
limbRBs = new Rigidbody[limbs.Length]; |
|||
for (int i = 0; i < limbs.Length; i++) |
|||
{ |
|||
limbRBs[i] = limbs[i].gameObject.GetComponent<Rigidbody>(); |
|||
} |
|||
} |
|||
|
|||
public override void CollectObservations() |
|||
{ |
|||
AddVectorObs(body.transform.rotation.eulerAngles); |
|||
|
|||
AddVectorObs(bodyRB.velocity); |
|||
|
|||
AddVectorObs((bodyRB.velocity - past_velocity) / Time.fixedDeltaTime); |
|||
past_velocity = bodyRB.velocity; |
|||
|
|||
for (int i = 0; i < limbs.Length; i++) |
|||
{ |
|||
AddVectorObs(limbs[i].localPosition); |
|||
AddVectorObs(limbs[i].localRotation); |
|||
AddVectorObs(limbRBs[i].velocity); |
|||
AddVectorObs(limbRBs[i].angularVelocity); |
|||
} |
|||
|
|||
for (int index = 0; index < 4; index++) |
|||
{ |
|||
if (leg_touching[index]) |
|||
{ |
|||
AddVectorObs(1); |
|||
} |
|||
else |
|||
{ |
|||
AddVectorObs(0); |
|||
} |
|||
leg_touching[index] = false; |
|||
} |
|||
} |
|||
|
|||
public override void AgentAction(float[] vectorAction, string textAction) |
|||
{ |
|||
var toUse = new float[vectorAction.Length]; |
|||
var torquePenalty = 0f; |
|||
|
|||
for (int k = 0; k < vectorAction.Length; k++) |
|||
{ |
|||
toUse[k] = 1.5f * Mathf.Clamp(vectorAction[k], -1f, 1f); |
|||
torquePenalty += toUse[k] * toUse[k]; |
|||
} |
|||
|
|||
limbRBs[0].AddTorque(-limbs[0].transform.right * strength * toUse[0]); |
|||
limbRBs[1].AddTorque(-limbs[1].transform.right * strength * toUse[1]); |
|||
limbRBs[2].AddTorque(-limbs[2].transform.right * strength * toUse[2]); |
|||
limbRBs[3].AddTorque(-limbs[3].transform.right * strength * toUse[3]); |
|||
limbRBs[0].AddTorque(-body.transform.up * strength * toUse[4]); |
|||
limbRBs[1].AddTorque(-body.transform.up * strength * toUse[5]); |
|||
limbRBs[2].AddTorque(-body.transform.up * strength * toUse[6]); |
|||
limbRBs[3].AddTorque(-body.transform.up * strength * toUse[7]); |
|||
limbRBs[4].AddTorque(-limbs[4].transform.right * strength * toUse[8]); |
|||
limbRBs[5].AddTorque(-limbs[5].transform.right * strength * toUse[9]); |
|||
limbRBs[6].AddTorque(-limbs[6].transform.right * strength * toUse[10]); |
|||
limbRBs[7].AddTorque(-limbs[7].transform.right * strength * toUse[11]); |
|||
|
|||
if (!IsDone()) |
|||
{ |
|||
SetReward(- 0.01f * torquePenalty |
|||
+ 1.0f * bodyRB.velocity.x |
|||
- 0.05f * Mathf.Abs(body.transform.position.z - body.transform.parent.transform.position.z) |
|||
- 0.05f * Mathf.Abs(bodyRB.velocity.y) |
|||
); |
|||
} |
|||
|
|||
if (fell) |
|||
{ |
|||
Done(); |
|||
AddReward(-1f); |
|||
} |
|||
} |
|||
|
|||
public override void AgentReset() |
|||
{ |
|||
fell = false; |
|||
Transform[] allChildren = GetComponentsInChildren<Transform>(); |
|||
foreach (Transform child in allChildren) |
|||
{ |
|||
if (child.gameObject.name.Contains("Crawler") |
|||
|| child.gameObject.name.Contains("parent")) |
|||
{ |
|||
continue; |
|||
} |
|||
child.position = transformsPosition[child.gameObject]; |
|||
child.rotation = transformsRotation[child.gameObject]; |
|||
child.gameObject.GetComponent<Rigidbody>().velocity = default(Vector3); |
|||
child.gameObject.GetComponent<Rigidbody>().angularVelocity = default(Vector3); |
|||
} |
|||
gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, Random.value * 90 - 45, 0)); |
|||
} |
|||
|
|||
public override void AgentOnDone() |
|||
{ |
|||
|
|||
} |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue