浏览代码

[WIP] 2.0 verified to main (#5385)

/colab-links
GitHub 3 年前
当前提交
456c2341
共有 17 个文件被更改,包括 46 次插入51 次删除
  1. 2
      .yamato/com.unity.ml-agents-test.yml
  2. 2
      .yamato/test_versions.metafile
  3. 2
      DevProject/Packages/manifest.json
  4. 6
      DevProject/Packages/packages-lock.json
  5. 4
      DevProject/ProjectSettings/ProjectVersion.txt
  6. 2
      Project/Packages/manifest.json
  7. 6
      Project/Packages/packages-lock.json
  8. 4
      Project/ProjectSettings/ProjectVersion.txt
  9. 1
      com.unity.ml-agents/CHANGELOG.md
  10. 6
      com.unity.ml-agents/Documentation~/com.unity.ml-agents.md
  11. 8
      com.unity.ml-agents/Documentation~/filter.yml
  12. 8
      com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs
  13. 34
      com.unity.ml-agents/Runtime/Integrations/Match3/AbstractBoard.cs
  14. 2
      com.unity.ml-agents/Runtime/Integrations/Match3/Match3SensorComponent.cs
  15. 4
      com.unity.ml-agents/Runtime/Sensors/ISensor.cs
  16. 2
      com.unity.ml-agents/package.json
  17. 4
      docs/Integrations-Match3.md

2
.yamato/com.unity.ml-agents-test.yml


- version: 2020.2
testProject: DevProject
enableNoDefaultPackages: !!bool true
- version: 2021.1
- version: 2021.2
testProject: DevProject
enableNoDefaultPackages: !!bool true

2
.yamato/test_versions.metafile


extra_test: gym
- version: 2020.3
extra_test: sensor
- version: 2021.1
- version: 2021.2
extra_test: llapi

2
DevProject/Packages/manifest.json


"com.unity.ml-agents.extensions": "file:../../com.unity.ml-agents.extensions",
"com.unity.package-manager-doctools": "1.7.0-preview",
"com.unity.package-validation-suite": "0.19.0-preview",
"com.unity.test-framework": "1.1.22",
"com.unity.test-framework": "1.1.24",
"com.unity.test-framework.performance": "2.2.0-preview",
"com.unity.testtools.codecoverage": "1.0.0-pre.3",
"com.unity.modules.imageconversion": "1.0.0",

6
DevProject/Packages/packages-lock.json


{
"dependencies": {
"com.unity.barracuda": {
"version": "1.4.0-preview",
"version": "2.0.0-pre.3",
"depth": 1,
"source": "registry",
"dependencies": {

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.barracuda": "1.4.0-preview",
"com.unity.barracuda": "2.0.0-pre.3",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}

"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
},
"com.unity.test-framework": {
"version": "1.1.22",
"version": "1.1.24",
"depth": 0,
"source": "registry",
"dependencies": {

4
DevProject/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2020.3.0f1
m_EditorVersionWithRevision: 2020.3.0f1 (c7b5465681fb)
m_EditorVersion: 2020.3.5f1
m_EditorVersionWithRevision: 2020.3.5f1 (8095aa901b9b)

2
Project/Packages/manifest.json


"com.unity.ml-agents": "file:../../com.unity.ml-agents",
"com.unity.ml-agents.extensions": "file:../../com.unity.ml-agents.extensions",
"com.unity.nuget.newtonsoft-json": "2.0.0",
"com.unity.test-framework": "1.1.22",
"com.unity.test-framework": "1.1.24",
"com.unity.toolchain.macos-x86_64-linux-x86_64": "0.1.20-preview",
"com.unity.ugui": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",

6
Project/Packages/packages-lock.json


{
"dependencies": {
"com.unity.barracuda": {
"version": "1.4.0-preview",
"version": "2.0.0-pre.3",
"depth": 1,
"source": "registry",
"dependencies": {

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.barracuda": "1.4.0-preview",
"com.unity.barracuda": "2.0.0-pre.3",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}

"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.22",
"version": "1.1.24",
"depth": 0,
"source": "registry",
"dependencies": {

4
Project/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.20f1
m_EditorVersionWithRevision: 2019.4.20f1 (6dd1c08eedfa)
m_EditorVersion: 2019.4.25f1
m_EditorVersionWithRevision: 2019.4.25f1 (01a0494af254)

1
com.unity.ml-agents/CHANGELOG.md


### Major Changes
### Minor Changes
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
- update Barracuda to 2.0.0-pre.3. (#5385)
- Fixed NullReferenceException when adding Behavior Parameters with no Agent. (#5382)
#### ml-agents / ml-agents-envs / gym-unity (Python)
- Added a fully connected visual encoder for environments with very small image inputs. (#5351)

6
com.unity.ml-agents/Documentation~/com.unity.ml-agents.md


The _ML-Agents_ package contains the primary C# SDK for the [Unity ML-Agents
Toolkit].
The package allows you to convert any Unity scene to into a learning environment
The package allows you to convert any Unity scene into a learning environment
and train character behaviors using a variety of machine learning algorithms.
Additionally, it allows you to embed these trained behaviors back into Unity
scenes to control your characters. More specifically, the package provides the

are entities that generate observations (through sensors), take actions, and
receive rewards from the environment.
- Define Behaviors: entities that specifiy how an agent should act. Multiple
- Define Behaviors: entities that specify how an agent should act. Multiple
agents can share the same Behavior and a scene may have multiple Behaviors.
- Record demonstrations of an agent within the Editor. You can use
demonstrations to help train a behavior for that agent.

[installation instructions] on our [GitHub repository].
### Advanced Installation
With the changes to Unity Package Manager in 2021, experimental packages will not show up in package list and have to be installed manually. There are two recommended ways to install the package manually:
With the changes to Unity Package Manager in 2021, experimental packages will not show up in the package list and have to be installed manually. There are two recommended ways to install the package manually:
#### Github via Package Manager

8
com.unity.ml-agents/Documentation~/filter.yml


apiRules:
- exclude:
uidRegex: ^Unity.MLAgents\.Tests$
uidRegex: .*Test.*
type: Namespace
- exclude:
uidRegex: ^Unity.MLAgents\.Tests\.Communicator$
type: Namespace
- exclude:
uidRegex: ^Unity.MLAgents\.Tests\.Actuators$
type: Namespace
- exclude:
uidRegex: ^Unity.MLAgents\.Editor$

8
com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs


/// <remarks>
/// By default, all discrete actions are allowed.
/// If isEnabled is false, the agent will not be able to perform the actions passed as argument
/// at the next decision for the specified action branch. The actionIndex correspond
/// at the next decision for the specified action branch. The actionIndex corresponds
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#masking-discrete-actions
/// <param name="actionIndex">Index of the action</param>
/// <param name="isEnabled">Whether the action is allowed or now.</param>
/// <param name="actionIndex">Index of the action.</param>
/// <param name="isEnabled">Whether the action is allowed or not.</param>
void SetActionEnabled(int branch, int actionIndex, bool isEnabled);
}
}

34
com.unity.ml-agents/Runtime/Integrations/Match3/AbstractBoard.cs


public static bool operator <=(BoardSize lhs, BoardSize rhs)
{
return lhs.Rows <= rhs.Rows && lhs.Columns <= rhs.Columns && lhs.NumCellTypes <= rhs.NumCellTypes &&
lhs.NumSpecialTypes <= rhs.NumSpecialTypes;
lhs.NumSpecialTypes <= rhs.NumSpecialTypes;
}
/// <summary>

public static bool operator >=(BoardSize lhs, BoardSize rhs)
{
return lhs.Rows >= rhs.Rows && lhs.Columns >= rhs.Columns && lhs.NumCellTypes >= rhs.NumCellTypes &&
lhs.NumSpecialTypes >= rhs.NumSpecialTypes;
lhs.NumSpecialTypes >= rhs.NumSpecialTypes;
}
/// <summary>

/// <summary>
/// Return the current size of the board. The values must less than or equal to the values returned from
/// GetMaxBoardSize().
/// By default, this will return GetMaxBoardSize(); if your board doesn't change size, you don't need to
/// <see cref="GetMaxBoardSize"/>.
/// By default, this will return <see cref="GetMaxBoardSize"/>; if your board doesn't change size, you don't need to
/// override it.
/// </summary>
/// <returns></returns>

/// <summary>
/// Returns the "color" of the piece at the given row and column.
/// This should be between 0 and NumCellTypes-1 (inclusive).
/// This should be between 0 and BoardSize.NumCellTypes-1 (inclusive).
/// The actual order of the values doesn't matter.
/// </summary>
/// <param name="row"></param>

/// <summary>
/// Returns the special type of the piece at the given row and column.
/// This should be between 0 and NumSpecialTypes (inclusive).
/// This should be between 0 and BoardSize.NumSpecialTypes (inclusive).
/// The actual order of the values doesn't matter.
/// </summary>
/// <param name="row"></param>

/// <summary>
/// Check whether the particular Move is valid for the game.
/// The actual results will depend on the rules of the game, but we provide SimpleIsMoveValid()
/// The actual results will depend on the rules of the game, but we provide <see cref="SimpleIsMoveValid(Move)"/>
/// Moves that would go outside of GetCurrentBoardSize() are filtered out before they are
/// Moves that would go outside of <see cref="GetCurrentBoardSize"/> are filtered out before they are
/// <param name="m"></param>
/// <param name="m">The move to check.</param>
/// Instruct the game to make the given Move. Returns true if the move was made.
/// Instruct the game to make the given <see cref="Move"/>. Returns true if the move was made.
/// <param name="m"></param>
/// <param name="m">The move to carry out.</param>
/// <returns></returns>
public abstract bool MakeMove(Move m);

public Action OnNoValidMovesAction;
/// <summary>
/// Iterate through all Moves on the board.
/// Iterate through all moves on the board.
/// </summary>
/// <returns></returns>
public IEnumerable<Move> AllMoves()

}
/// <summary>
/// Iterate through all valid Moves on the board.
/// Iterate through all valid moves on the board.
/// </summary>
/// <returns></returns>
public IEnumerable<Move> ValidMoves()

}
/// <summary>
/// Returns true if swapped the cells specified by the move would result in
/// Returns true if swapping the cells specified by the move would result in
/// to be moved; to add extra logic, incorporate it into you IsMoveValid() method.
/// to be moved; to add extra logic, incorporate it into your <see cref="IsMoveValid"/> method.
/// </summary>
/// <param name="move"></param>
/// <returns></returns>

/// <summary>
/// Check if one of the cells that is swapped during a move matches 3 or more.
/// Since these checks are similar for each cell, we consider the Move as two "half moves".
/// Since these checks are similar for each cell, we consider the move as two "half moves".
/// </summary>
/// <param name="newRow"></param>
/// <param name="newCol"></param>

}
/// <summary>
/// Make sure that the current BoardSize isn't larger than the original value of GetMaxBoardSize().
/// Make sure that the current BoardSize isn't larger than the original value of <see cref="GetMaxBoardSize"/>.
/// If it is, log a warning.
/// </summary>
/// <param name="originalMaxBoardSize"></param>

2
com.unity.ml-agents/Runtime/Integrations/Match3/Match3SensorComponent.cs


return Array.Empty<ISensor>();
}
var cellSensor = Match3Sensor.CellTypeSensor(board, m_ObservationType, m_SensorName + " (cells)");
// This can be null if numSpecialTypes is 0
// This can be null if BoardSize.NumSpecialTypes is 0
var specialSensor = Match3Sensor.SpecialTypeSensor(board, m_ObservationType, m_SensorName + " (special)");
m_Sensors = specialSensor != null
? new ISensor[] { cellSensor, specialSensor }

4
com.unity.ml-agents/Runtime/Sensors/ISensor.cs


/// Returns a description of the observations that will be generated by the sensor.
/// See <see cref="ObservationSpec"/> for more details, and helper methods to create one.
/// </summary>
/// <returns></returns>
/// <returns>An object describing the observation.</returns>
ObservationSpec GetObservationSpec();
/// <summary>

/// Return information on the compression type being used. If no compression is used, return
/// <see cref="CompressionSpec.Default()"/>.
/// </summary>
/// <returns>CompressionSpec used by the sensor.</returns>
/// <returns>An object describing the compression used by the sensor.</returns>
CompressionSpec GetCompressionSpec();
/// <summary>

2
com.unity.ml-agents/package.json


"unity": "2019.4",
"description": "Use state-of-the-art machine learning to create intelligent character behaviors in any Unity environment (games, robotics, film, etc.).",
"dependencies": {
"com.unity.barracuda": "1.4.0-preview",
"com.unity.barracuda": "2.0.0-pre.3",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}

4
docs/Integrations-Match3.md


##### `public abstract int GetCellType(int row, int col)`
Returns the "color" of piece at the given row and column.
This should be between 0 and NumCellTypes-1 (inclusive).
This should be between 0 and BoardSize.NumCellTypes-1 (inclusive).
This should be between 0 and NumSpecialTypes (inclusive).
This should be between 0 and BoardSize.NumSpecialTypes (inclusive).
The actual order of the values doesn't matter.
##### `public abstract bool IsMoveValid(Move m)`

正在加载...
取消
保存