docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface ICommunicator

    This is the interface of the Communicators. This does not need to be modified nor implemented to create a Unity environment.

    When the Unity Communicator is initialized, it will wait for the External Communicator to be initialized as well. The two communicators will then exchange their first messages that will usually contain information for initialization (information that does not need to be resent at each new exchange).

    By convention a Unity input is from External to Unity and a Unity output is from Unity to External. Inputs and outputs are relative to Unity.

    By convention, when the Unity Communicator and External Communicator call exchange, the exchange is NOT simultaneous but sequential. This means that when a side of the communication calls exchange, the other will receive the result of its previous xchange call. This is what happens when A calls exchange a single time: A sends data_1 to B -> B receives data_1 -> B generates and sends data_2 -> A receives data_2 When A calls exchange, it sends data_1 and receives data_2

    Since the messages are sent back and forth with exchange and simultaneously when calling initialize, External sends two messages at initialization.

    The structure of the messages is as follows: UnityMessage ...Header ...UnityOutput ......UnityRLOutput ......UnityRLInitializationOutput ...UnityInput ......UnityRLInput ......UnityRLInitializationInput

    UnityOutput and UnityInput can be extended to provide functionalities beyond RL UnityRLOutput and UnityRLInput can be extended to provide new RL functionalities

    Inherited Members
    IDisposable.Dispose()
    Namespace: Unity.MLAgents
    Assembly: Unity.ML-Agents.dll
    Syntax
    public interface ICommunicator : IDisposable

    Methods

    DecideBatch()

    Signals the ICommunicator that the Agents are now ready to receive their action and that if the communicator has not yet received an action for one of the Agents it needs to get one at this point.

    Declaration
    void DecideBatch()

    GetActions(string, int)

    Gets the AgentActions based on the batching key.

    Declaration
    ActionBuffers GetActions(string key, int agentId)
    Parameters
    Type Name Description
    string key

    A key to identify which behavior actions to get.

    int agentId

    A key to identify which Agent actions to get.

    Returns
    Type Description
    ActionBuffers

    ActionBuffers corresponding to the input key.

    Initialize(CommunicatorInitParameters, out UnityRLInitParameters)

    Sends the academy parameters through the Communicator. Is used by the academy to send the AcademyParameters to the communicator.

    Declaration
    bool Initialize(CommunicatorInitParameters initParameters, out UnityRLInitParameters initParametersOut)
    Parameters
    Type Name Description
    CommunicatorInitParameters initParameters

    The Unity Initialization Parameters to be sent.

    UnityRLInitParameters initParametersOut

    The External Initialization Parameters received

    Returns
    Type Description
    bool

    Whether the connection was successful.

    PutObservations(string, AgentInfo, List<ISensor>)

    Sends the observations of one Agent.

    Declaration
    void PutObservations(string brainKey, AgentInfo info, List<ISensor> sensors)
    Parameters
    Type Name Description
    string brainKey

    Batch Key.

    AgentInfo info

    Agent info.

    List<ISensor> sensors

    The list of ISensors of the Agent.

    SubscribeBrain(string, ActionSpec)

    Registers a new Brain to the Communicator.

    Declaration
    void SubscribeBrain(string name, ActionSpec actionSpec)
    Parameters
    Type Name Description
    string name

    The name or key uniquely identifying the Brain.

    ActionSpec actionSpec

    Description of the actions for the Agent.

    Events

    QuitCommandReceived

    Quit was received by the communicator.

    Declaration
    event QuitCommandHandler QuitCommandReceived
    Event Type
    Type Description
    QuitCommandHandler

    ResetCommandReceived

    Reset command sent back from the communicator.

    Declaration
    event ResetCommandHandler ResetCommandReceived
    Event Type
    Type Description
    ResetCommandHandler
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)