vincentpierre
4 年前
当前提交
396bc43c
共有 53 个文件被更改,包括 907 次插入 和 397 次删除
-
2.yamato/com.unity.ml-agents-performance.yml
-
1.yamato/gym-interface-test.yml
-
16Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicActuatorComponent.cs
-
25Project/Assets/ML-Agents/Examples/Match3/Prefabs/Match3Heuristic.prefab
-
25Project/Assets/ML-Agents/Examples/Match3/Prefabs/Match3VectorObs.prefab
-
25Project/Assets/ML-Agents/Examples/Match3/Prefabs/Match3VisualObs.prefab
-
10Project/Assets/ML-Agents/Examples/Match3/Scenes/Match3.unity
-
166Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Agent.cs
-
13Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Board.cs
-
24README.md
-
74com.unity.ml-agents.extensions/Runtime/Match3/Match3Actuator.cs
-
10com.unity.ml-agents.extensions/Runtime/Match3/Match3ActuatorComponent.cs
-
6com.unity.ml-agents/CHANGELOG.md
-
43com.unity.ml-agents/Runtime/Actuators/ActuatorManager.cs
-
27com.unity.ml-agents/Runtime/Actuators/VectorActuator.cs
-
38com.unity.ml-agents/Runtime/Agent.cs
-
70com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs
-
94com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs
-
56com.unity.ml-agents/Runtime/Inference/TensorGenerator.cs
-
1com.unity.ml-agents/Runtime/Inference/TensorNames.cs
-
9com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
-
11com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs
-
3com.unity.ml-agents/Runtime/Sensors/SensorComponent.cs
-
12com.unity.ml-agents/Runtime/SideChannels/EngineConfigurationChannel.cs
-
18com.unity.ml-agents/Tests/Editor/Actuators/ActuatorManagerTests.cs
-
11com.unity.ml-agents/Tests/Editor/Actuators/TestActuator.cs
-
19com.unity.ml-agents/Tests/Editor/Actuators/VectorActuatorTests.cs
-
6com.unity.ml-agents/Tests/Editor/BehaviorParameterTests.cs
-
2com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs
-
2com.unity.ml-agents/Tests/Editor/Sensor/CameraSensorComponentTest.cs
-
2com.unity.ml-agents/Tests/Editor/Sensor/RenderTextureSensorComponentTests.cs
-
8docs/Migrating.md
-
2ml-agents/mlagents/trainers/tests/test_subprocess_env_manager.py
-
67ml-agents/mlagents/trainers/tests/torch/test_attention.py
-
33ml-agents/mlagents/trainers/torch/attention.py
-
6ml-agents/mlagents/trainers/torch/encoders.py
-
8ml-agents/mlagents/trainers/torch/networks.py
-
2ml-agents/mlagents/trainers/torch/utils.py
-
44.yamato/training-backcompat-tests.yml
-
121Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuator.cs
-
3Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuator.cs.meta
-
18Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuatorComponent.cs
-
3Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuatorComponent.cs.meta
-
18com.unity.ml-agents/Runtime/Actuators/IHeuristicProvider.cs
-
3com.unity.ml-agents/Runtime/Actuators/IHeuristicProvider.cs.meta
-
86com.unity.ml-agents/Tests/Editor/Sensor/BufferSensorTest.cs
-
11com.unity.ml-agents/Tests/Editor/Sensor/BufferSensorTest.cs.meta
-
3com.unity.ml-agents/Tests/Editor/SideChannels.meta
-
44com.unity.ml-agents/Tests/Editor/SideChannels/EngineConfigurationChannelTests.cs
-
3com.unity.ml-agents/Tests/Editor/SideChannels/EngineConfigurationChannelTests.cs.meta
-
0/com.unity.ml-agents/Tests/Editor/SideChannels/SideChannelTests.cs.meta
-
0/com.unity.ml-agents/Tests/Editor/SideChannels/SideChannelTests.cs
|
|||
|
|||
test_mac_backcompat_2020.1: |
|||
{% capture editor_version %}2020.1{% endcapture %} |
|||
{% capture csharp_backcompat_version %}1.0.0{% endcapture %} |
|||
# This test has to run on mac because it requires the custom build of tensorflow without AVX |
|||
# Test against 2020.1 because 2020.2 has to run against package version 1.2.0 |
|||
name: Test Mac Backcompat Training {{ editor_version }} |
|||
agent: |
|||
type: Unity::VM::osx |
|||
image: ml-agents/ml-agents-bokken-mac:0.1.4-492264 |
|||
flavor: b1.small |
|||
variables: |
|||
UNITY_VERSION: {{ editor_version }} |
|||
commands: |
|||
- | |
|||
python3 -m venv venv && source venv/bin/activate |
|||
python -m pip install pyyaml --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple |
|||
python -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade |
|||
unity-downloader-cli -u {{ editor_version }} -c editor --wait --fast |
|||
# Backwards-compatibility tests. |
|||
# If we make a breaking change to the communication protocol, these will need |
|||
# to be disabled until the next release. |
|||
python -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=mac |
|||
python -u -m ml-agents.tests.yamato.training_int_tests --csharp {{ csharp_backcompat_version }} |
|||
- | |
|||
python3 -m venv venv_old && source venv_old/bin/activate |
|||
python -m pip install pyyaml --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple |
|||
python -u -m ml-agents.tests.yamato.training_int_tests --python 0.16.0 |
|||
triggers: |
|||
cancel_old_ci: true |
|||
recurring: |
|||
- branch: master |
|||
frequency: daily |
|||
artifacts: |
|||
logs: |
|||
paths: |
|||
- "artifacts/standalone_build.txt" |
|||
- "artifacts/inference.nn.txt" |
|||
- "artifacts/inference.onnx.txt" |
|||
- "artifacts/*.log" |
|||
standalonebuild: |
|||
paths: |
|||
- "artifacts/testPlayer*/**" |
|||
- "artifacts/models/**" |
|
|||
using Unity.MLAgents; |
|||
using Unity.MLAgents.Extensions.Match3; |
|||
|
|||
namespace Unity.MLAgentsExamples |
|||
{ |
|||
public class Match3ExampleActuator : Match3Actuator |
|||
{ |
|||
Match3Board Board => (Match3Board)m_Board; |
|||
|
|||
public Match3ExampleActuator(Match3Board board, |
|||
bool forceHeuristic, |
|||
Agent agent, |
|||
string name, |
|||
int seed |
|||
) |
|||
: base(board, forceHeuristic, seed, agent, name) { } |
|||
|
|||
|
|||
protected override int EvalMovePoints(Move move) |
|||
{ |
|||
var pointsByType = new[] { Board.BasicCellPoints, Board.SpecialCell1Points, Board.SpecialCell2Points }; |
|||
// Counts the expected points for making the move.
|
|||
var moveVal = m_Board.GetCellType(move.Row, move.Column); |
|||
var moveSpecial = m_Board.GetSpecialType(move.Row, move.Column); |
|||
var (otherRow, otherCol) = move.OtherCell(); |
|||
var oppositeVal = m_Board.GetCellType(otherRow, otherCol); |
|||
var oppositeSpecial = m_Board.GetSpecialType(otherRow, otherCol); |
|||
|
|||
|
|||
int movePoints = EvalHalfMove( |
|||
otherRow, otherCol, moveVal, moveSpecial, move.Direction, pointsByType |
|||
); |
|||
int otherPoints = EvalHalfMove( |
|||
move.Row, move.Column, oppositeVal, oppositeSpecial, move.OtherDirection(), pointsByType |
|||
); |
|||
return movePoints + otherPoints; |
|||
} |
|||
|
|||
int EvalHalfMove(int newRow, int newCol, int newValue, int newSpecial, Direction incomingDirection, int[] pointsByType) |
|||
{ |
|||
// This is a essentially a duplicate of AbstractBoard.CheckHalfMove but also counts the points for the move.
|
|||
int matchedLeft = 0, matchedRight = 0, matchedUp = 0, matchedDown = 0; |
|||
int scoreLeft = 0, scoreRight = 0, scoreUp = 0, scoreDown = 0; |
|||
|
|||
if (incomingDirection != Direction.Right) |
|||
{ |
|||
for (var c = newCol - 1; c >= 0; c--) |
|||
{ |
|||
if (m_Board.GetCellType(newRow, c) == newValue) |
|||
{ |
|||
matchedLeft++; |
|||
scoreLeft += pointsByType[m_Board.GetSpecialType(newRow, c)]; |
|||
} |
|||
else |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (incomingDirection != Direction.Left) |
|||
{ |
|||
for (var c = newCol + 1; c < m_Board.Columns; c++) |
|||
{ |
|||
if (m_Board.GetCellType(newRow, c) == newValue) |
|||
{ |
|||
matchedRight++; |
|||
scoreRight += pointsByType[m_Board.GetSpecialType(newRow, c)]; |
|||
} |
|||
else |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (incomingDirection != Direction.Down) |
|||
{ |
|||
for (var r = newRow + 1; r < m_Board.Rows; r++) |
|||
{ |
|||
if (m_Board.GetCellType(r, newCol) == newValue) |
|||
{ |
|||
matchedUp++; |
|||
scoreUp += pointsByType[m_Board.GetSpecialType(r, newCol)]; |
|||
} |
|||
else |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (incomingDirection != Direction.Up) |
|||
{ |
|||
for (var r = newRow - 1; r >= 0; r--) |
|||
{ |
|||
if (m_Board.GetCellType(r, newCol) == newValue) |
|||
{ |
|||
matchedDown++; |
|||
scoreDown += pointsByType[m_Board.GetSpecialType(r, newCol)]; |
|||
} |
|||
else |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if ((matchedUp + matchedDown >= 2) || (matchedLeft + matchedRight >= 2)) |
|||
{ |
|||
// It's a match. Start from counting the piece being moved
|
|||
var totalScore = pointsByType[newSpecial]; |
|||
if (matchedUp + matchedDown >= 2) |
|||
{ |
|||
totalScore += scoreUp + scoreDown; |
|||
} |
|||
|
|||
if (matchedLeft + matchedRight >= 2) |
|||
{ |
|||
totalScore += scoreLeft + scoreRight; |
|||
} |
|||
return totalScore; |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9e6fe1a020a04421ab828be4543a655c |
|||
timeCreated: 1610665874 |
|
|||
using Unity.MLAgents; |
|||
using Unity.MLAgents.Actuators; |
|||
using Unity.MLAgents.Extensions.Match3; |
|||
|
|||
namespace Unity.MLAgentsExamples |
|||
{ |
|||
public class Match3ExampleActuatorComponent : Match3ActuatorComponent |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override IActuator CreateActuator() |
|||
{ |
|||
var board = GetComponent<Match3Board>(); |
|||
var agent = GetComponentInParent<Agent>(); |
|||
var seed = RandomSeed == -1 ? gameObject.GetInstanceID() : RandomSeed + 1; |
|||
return new Match3ExampleActuator(board, ForceHeuristic, agent, ActuatorName, seed); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b17adcc6c9b241da903aa134f2dac930 |
|||
timeCreated: 1610665885 |
|
|||
namespace Unity.MLAgents.Actuators |
|||
{ |
|||
/// <summary>
|
|||
/// Interface that allows objects to fill out an <see cref="ActionBuffers"/> data structure for controlling
|
|||
/// behavior of Agents or Actuators.
|
|||
/// </summary>
|
|||
public interface IHeuristicProvider |
|||
{ |
|||
/// <summary>
|
|||
/// Method called on objects which are expected to fill out the <see cref="ActionBuffers"/> data structure.
|
|||
/// Object that implement this interface should be careful to be consistent in the placement of their actions
|
|||
/// in the <see cref="ActionBuffers"/> data structure.
|
|||
/// </summary>
|
|||
/// <param name="actionBuffersOut">The <see cref="ActionBuffers"/> data structure to be filled by the
|
|||
/// object implementing this interface.</param>
|
|||
void Heuristic(in ActionBuffers actionBuffersOut); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: be90ffb28f39444a8fb02dfd4a82870c |
|||
timeCreated: 1610057456 |
|
|||
using System; |
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using Unity.MLAgents.Sensors; |
|||
|
|||
namespace Unity.MLAgents.Tests |
|||
{ |
|||
|
|||
[TestFixture] |
|||
public class BufferSensorTest |
|||
{ |
|||
[Test] |
|||
public void TestBufferSensor() |
|||
{ |
|||
|
|||
var bufferSensor = new BufferSensor(20, 4); |
|||
var shape = bufferSensor.GetObservationShape(); |
|||
var dimProp = bufferSensor.GetDimensionProperties(); |
|||
Assert.AreEqual(shape[0], 20); |
|||
Assert.AreEqual(shape[1], 4); |
|||
Assert.AreEqual(shape.Length, 2); |
|||
Assert.AreEqual(dimProp[0], DimensionProperty.VariableSize); |
|||
Assert.AreEqual(dimProp[1], DimensionProperty.None); |
|||
Assert.AreEqual(dimProp.Length, 2); |
|||
|
|||
bufferSensor.AppendObservation(new float[] { 1, 2, 3, 4 }); |
|||
bufferSensor.AppendObservation(new float[] { 5, 6, 7, 8 }); |
|||
|
|||
var obsWriter = new ObservationWriter(); |
|||
var obs = bufferSensor.GetObservationProto(obsWriter); |
|||
|
|||
Assert.AreEqual(shape, obs.Shape); |
|||
Assert.AreEqual(obs.DimensionProperties.Count, 2); |
|||
Assert.AreEqual((int)dimProp[0], obs.DimensionProperties[0]); |
|||
Assert.AreEqual((int)dimProp[1], obs.DimensionProperties[1]); |
|||
|
|||
for (int i = 0; i < 8; i++) |
|||
{ |
|||
Assert.AreEqual(obs.FloatData.Data[i], i + 1); |
|||
|
|||
} |
|||
for (int i = 8; i < 80; i++) |
|||
{ |
|||
Assert.AreEqual(obs.FloatData.Data[i], 0); |
|||
|
|||
} |
|||
} |
|||
|
|||
[Test] |
|||
public void TestBufferSensorComponent() |
|||
{ |
|||
var agentGameObj = new GameObject("agent"); |
|||
var bufferComponent = agentGameObj.AddComponent<BufferSensorComponent>(); |
|||
bufferComponent.MaxNumObservables = 20; |
|||
bufferComponent.ObservableSize = 4; |
|||
|
|||
var sensor = bufferComponent.CreateSensor(); |
|||
var shape = bufferComponent.GetObservationShape(); |
|||
|
|||
Assert.AreEqual(shape[0], 20); |
|||
Assert.AreEqual(shape[1], 4); |
|||
Assert.AreEqual(shape.Length, 2); |
|||
|
|||
bufferComponent.AppendObservation(new float[] { 1, 2, 3, 4 }); |
|||
bufferComponent.AppendObservation(new float[] { 5, 6, 7, 8 }); |
|||
|
|||
var obsWriter = new ObservationWriter(); |
|||
var obs = sensor.GetObservationProto(obsWriter); |
|||
|
|||
Assert.AreEqual(shape, obs.Shape); |
|||
Assert.AreEqual(obs.DimensionProperties.Count, 2); |
|||
|
|||
for (int i = 0; i < 8; i++) |
|||
{ |
|||
Assert.AreEqual(obs.FloatData.Data[i], i + 1); |
|||
|
|||
} |
|||
for (int i = 8; i < 80; i++) |
|||
{ |
|||
Assert.AreEqual(obs.FloatData.Data[i], 0); |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5267572aa66d34b49bbc65940674b2a6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1228f198ceee45a38c7d9ff50425b65d |
|||
timeCreated: 1610760867 |
|
|||
using NUnit.Framework; |
|||
using Unity.MLAgents.SideChannels; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.MLAgents.Tests |
|||
{ |
|||
public class EngineConfigurationChannelTests |
|||
{ |
|||
float m_OldTimeScale = 1.0f; |
|||
|
|||
[SetUp] |
|||
public void Setup() |
|||
{ |
|||
m_OldTimeScale = Time.timeScale; |
|||
} |
|||
|
|||
[TearDown] |
|||
public void TearDown() |
|||
{ |
|||
Time.timeScale = m_OldTimeScale; |
|||
} |
|||
|
|||
[Test] |
|||
public void TestTimeScaleClamping() |
|||
{ |
|||
OutgoingMessage pythonMsg = new OutgoingMessage(); |
|||
pythonMsg.WriteInt32((int)EngineConfigurationChannel.ConfigurationType.TimeScale); |
|||
pythonMsg.WriteFloat32(1000f); |
|||
|
|||
var sideChannel = new EngineConfigurationChannel(); |
|||
sideChannel.ProcessMessage(pythonMsg.ToByteArray()); |
|||
|
|||
#if UNITY_EDITOR
|
|||
// Should be clamped
|
|||
Assert.AreEqual(100.0f, Time.timeScale); |
|||
#else
|
|||
// Not sure we can run this test from a player, but just in case, shouldn't clamp.
|
|||
Assert.AreEqual(1000.0f, Time.timeScale); |
|||
#endif
|
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 71aa620295f74ca5875e8e4782f08768 |
|||
timeCreated: 1610760906 |
撰写
预览
正在加载...
取消
保存
Reference in new issue