Skip to content

Commit

Permalink
Fixed package works issues. Updated com.unity.ml-agents.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelalonsojr committed Sep 12, 2024
1 parent f74208d commit 2fa290c
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 143 deletions.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions com.unity.ml-agents/CODEOWNERS.meta

This file was deleted.

162 changes: 41 additions & 121 deletions com.unity.ml-agents/Documentation~/com.unity.ml-agents.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
# About ML-Agents package (`com.unity.ml-agents`)

The _ML-Agents_ package contains the primary C# SDK for the [Unity ML-Agents
Toolkit].

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
following core functionalities:

- Define Agents: entities, or characters, whose behavior will be learned. Agents
are entities that generate observations (through sensors), take actions, and
receive rewards from the environment.
- 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.
- Embedding a trained behavior into the scene via the [Unity Inference Engine].
Embedded behaviors allow you to switch an Agent between learning and
inference.

Note that the _ML-Agents_ package does not contain the machine learning
algorithms for training behaviors. The _ML-Agents_ package only supports
instrumenting a Unity scene, setting it up for training, and then embedding the
trained model back into your Unity scene. The machine learning algorithms that
orchestrate training are part of the companion [Python package].

Note that we also provide an _ML-Agents Extensions_ package
(`com.unity.ml-agents.extensions`) that contains early/experimental features
that you may find useful. This package is only available from the [ML-Agents
GitHub repo].
# ML-Agents Overview
ML-agents enable games and simulations to serve as environments for training intelligent agents in Unity. Training can be done with reinforcement learning, imitation learning, neuroevolution, or any other methods. Trained agents can be used for many use cases, including controlling NPC behavior (in a variety of settings such as multi-agent and adversarial), automated testing of game builds and evaluating different game design decisions pre-release.

The _ML-Agents_ package has a C# SDK for the [Unity ML-Agents Toolkit], which can be used outside of Unity. The scope of these docs is just to get started in the context of Unity, but further details and samples are located on the [github docs].

## Capabilities
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 following core functionalities:

* Define Agents: entities, or characters, whose behavior will be learned. Agents are entities that generate observations (through sensors), take actions, and receive rewards from the environment.
* 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: To show the behaviors of an agent within the Editor. You can use demonstrations to help train a behavior for that agent.
* Embed a trained behavior (aka: run your ML model) in the scene via the [Unity Sentis] inference engine. Embedded behaviors allow you to switch an Agent between learning and inference.

## Special Notes
Note that the ML-Agents package does not contain the machine learning algorithms for training behaviors. The ML-Agents package only supports instrumenting a Unity scene, setting it up for training, and then embedding the trained model back into your Unity scene. The machine learning algorithms that orchestrate training are part of the companion [python package].
Note that we also provide an ML-Agents Extensions package (`com.unity.ml-agents.extensions`) that contains early/experimental features that you may find useful. This package is only available from the [ML-Agents GitHub repo].


## Package contents

Expand All @@ -47,49 +32,14 @@ The following table describes the package folder structure:
<a name="Installation"></a>

## Installation
To add the ML-Agents package to a Unity project:

To install this _ML-Agents_ package, follow the instructions in the [Package
Manager documentation].

To install the companion Python package to enable training behaviors, follow the
[installation instructions] on our [GitHub repository].

### Advanced Installation
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

In Unity 2019.4 or later, open the Package Manager, hit the "+" button, and select "Add package from git URL".

![Package Manager git URL](https://github.com/Unity-Technologies/ml-agents/blob/release_21_docs/docs/images/unity_package_manager_git_url.png)

In the dialog that appears, enter

```
git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_21
```

You can also edit your project's `manifest.json` directly and add the following line to the `dependencies`
section:

```
"com.unity.ml-agents": "git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_21",
```

See [Git dependencies](https://docs.unity3d.com/Manual/upm-git.html#subfolder) for more information. Note that this
may take several minutes to resolve the packages the first time that you add it.

#### Local Installation for Development

[Clone the repository](https://github.com/Unity-Technologies/ml-agents/tree/release_21_docs/docs/Installation.md#clone-the-ml-agents-toolkit-repository-optional) and follow the
[Local Installation for Development](https://github.com/Unity-Technologies/ml-agents/tree/release_21_docs/docs/Installation.md#advanced-local-installation-for-development-1) directions.

## Requirements

This version of the Unity ML-Agents package is compatible with the following
versions of the Unity Editor:

- 2019.4 and later
* Create a new Unity project with Unity 2023.2 (or later) or open an existing one.
* To open the Package Manager, navigate to Window > Package Manager.
* Click + and select Add package by name...
* Enter com.unity.ml-agents
*Click Add to add the package to your project.
To install the companion Python package to enable training behaviors, follow the [installation instructions] on our [GitHub repository].

## Known Limitations

Expand All @@ -102,62 +52,32 @@ mode if training is not supported or is not currently running.

### Inference

Inference is executed via the
[Unity Inference Engine](https://docs.unity3d.com/Packages/com.unity.sentis@latest/index.html).

**CPU**

All platforms supported.

**GPU**

All platforms supported except:

- WebGL and GLES 3/2 on Android / iPhone

**NOTE:** Mobile platform support includes:

- Vulkan for Android
- Metal for iOS.
Inference is executed via [Unity Sentis](https://docs.unity3d.com/Packages/com.unity.sentis@latest/index.html) on the end-user device. Therefore, it is subject to the performance limitations of the end-user CPU or GPU. Also, only models created with our trainers are supported for running ML-Agents with a neural network behavior.

### Headless Mode

If you enable Headless mode, you will not be able to collect visual observations
from your agents.
If you enable Headless mode, you will not be able to collect visual observations from your agents.

### Rendering Speed and Synchronization

Currently the speed of the game physics can only be increased to 100x real-time.
The Academy also moves in time with FixedUpdate() rather than Update(), so game
behavior implemented in Update() may be out of sync with the agent decision
making. See [Execution Order of Event Functions] for more information.

You can control the frequency of Academy stepping by calling
`Academy.Instance.DisableAutomaticStepping()`, and then calling
`Academy.Instance.EnvironmentStep()`
Currently the speed of the game physics can only be increased to 100x real-time. The Academy (the sentinel that controls the stepping of the game to make sure everything is synchronized, from collection of observations to applying actions generated from policy inference to the agent) also moves in time with `FixedUpdate()` rather than `Update()`, so game behavior implemented in Update() may be out of sync with the agent decision-making. See [Execution Order of Event Functions] for more information.

### Unity Inference Engine Models
You can control the frequency of Academy stepping by calling `Academy.Instance.DisableAutomaticStepping()`, and then calling `Academy.Instance.EnvironmentStep()`.

Currently, only models created with our trainers are supported for running
ML-Agents with a neural network behavior.
## Additional Resources

## Helpful links
* [GitHub repository]
* [Unity Discussions]
* [Discord]
* [Website]

If you are new to the Unity ML-Agents package, or have a question after reading
the documentation, you can checkout our [GitHub Repository], which also includes
a number of ways to [connect with us] including our [ML-Agents Forum].

In order to improve the developer experience for Unity ML-Agents Toolkit, we have added in-editor analytics.
Please refer to "Information that is passively collected by Unity" in the
[Unity Privacy Policy](https://unity3d.com/legal/privacy-policy).

[unity ML-Agents Toolkit]: https://github.com/Unity-Technologies/ml-agents
[unity inference engine]: https://docs.unity3d.com/Packages/com.unity.sentis@latest/index.html
[package manager documentation]: https://docs.unity3d.com/Manual/upm-ui-install.html
[installation instructions]: https://github.com/Unity-Technologies/ml-agents/blob/release_21_docs/docs/Installation.md
[github repository]: https://github.com/Unity-Technologies/ml-agents
[github docs]: https://unity-technologies.github.io/ml-agents/
[Unity Sentis]: https://docs.unity3d.com/Packages/com.unity.sentis@2.1/manual/index.html
[python package]: https://github.com/Unity-Technologies/ml-agents
[execution order of event functions]: https://docs.unity3d.com/Manual/ExecutionOrder.html
[connect with us]: https://github.com/Unity-Technologies/ml-agents#community-and-feedback
[ml-agents forum]: https://forum.unity.com/forums/ml-agents.453/
[ML-Agents GitHub repo]: https://github.com/Unity-Technologies/ml-agents/blob/release_21_docs/com.unity.ml-agents.extensions
[GitHub repository]: https://github.com/Unity-Technologies/ml-agents
[Execution Order of Event Functions]: https://docs.unity3d.com/Manual/ExecutionOrder.html
[Unity Discussions]: https://discussions.unity.com/tag/ml-agents
[Discord]: https://discord.com/channels/489222168727519232/1202574086115557446
[Website]: https://unity-technologies.github.io/ml-agents/

6 changes: 3 additions & 3 deletions com.unity.ml-agents/Documentation~/filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apiRules:
uidRegex: .*Test.*
type: Namespace
- exclude:
uidRegex: ^Unity.MLAgents\.CommunicatorObjects$
uidRegex: ^Unity\.MLAgents\.CommunicatorObjects$
type: Namespace
- exclude:
uidRegex: ^Unity.MLAgents\.Editor$
uidRegex: ^Unity\.MLAgents\.Editor$
type: Namespace
- exclude:
uidRegex: ^Unity.MLAgentsExamples$
uidRegex: ^Unity\.MLAgentsExamples$
type: Namespace

1 change: 0 additions & 1 deletion com.unity.ml-agents/Samples/3DBall/.sample.json

This file was deleted.

3 changes: 0 additions & 3 deletions com.unity.ml-agents/Tests/.tests.json

This file was deleted.

7 changes: 0 additions & 7 deletions com.unity.ml-agents/catalog-info.yaml.meta

This file was deleted.

9 changes: 8 additions & 1 deletion com.unity.ml-agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.physics": "1.0.0"
}
},
"samples": [
{
"displayName":"3D Ball",
"description":"The 3D Ball sample is a simple environment that is a great for jumping into ML-Agents to see how things work.",
"path": "Samples~/3DBall"
}
]
}

0 comments on commit 2fa290c

Please sign in to comment.