Пример #1
0
        /// <summary>
        /// Sends the academy parameters through the Communicator.
        /// Is used by the academy to send the AcademyParameters to the communicator.
        /// </summary>
        /// <returns>The External Initialization Parameters received.</returns>
        /// <param name="academyParameters">The Unity Initialization Parameters to be sent.</param>
        public CommunicatorObjects.UnityRLInitializationInput SendAcademyParameters(
            CommunicatorObjects.UnityRLInitializationOutput academyParameters)
        {
            CommunicatorObjects.UnityInput input;
            var initializationInput = new CommunicatorObjects.UnityInput();

            try
            {
                initializationInput = m_communicator.Initialize(
                    new CommunicatorObjects.UnityOutput
                {
                    RlInitializationOutput = academyParameters
                },
                    out input);
            }
            catch
            {
                throw new UnityAgentsException(
                          "The Communicator was unable to connect. Please make sure the External " +
                          "process is ready to accept communication with Unity.");
            }

            var firstRlInput = input.RlInput;

            m_command          = firstRlInput.Command;
            m_arenasParameters = input.RlResetInput;
            m_isTraining       = firstRlInput.IsTraining;
            return(initializationInput.RlInitializationInput);
        }
Пример #2
0
        /// <summary>
        /// Sends the academy parameters through the Communicator.
        /// Is used by the academy to send the AcademyParameters to the communicator.
        /// </summary>
        /// <returns>The External Initialization Parameters received.</returns>
        /// <param name="academyParameters">The Unity Initialization Parameters to be sent.</param>
        public CommunicatorObjects.UnityRLInitializationInput SendAcademyParameters(
            CommunicatorObjects.UnityRLInitializationOutput academyParameters)
        {
            CommunicatorObjects.UnityInput input;
            var initializationInput = new CommunicatorObjects.UnityInput();

            try
            {
                initializationInput = m_Communicator.Initialize(
                    new CommunicatorObjects.UnityOutput
                {
                    RlInitializationOutput = academyParameters
                },
                    out input);
            }
            catch
            {
                var exceptionMessage = "The Communicator was unable to connect. Please make sure the External " +
                                       "process is ready to accept communication with Unity.";

                // Check for common error condition and add details to the exception message.
                var httpProxy  = Environment.GetEnvironmentVariable("HTTP_PROXY");
                var httpsProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY");
                if (httpProxy != null || httpsProxy != null)
                {
                    exceptionMessage += " Try removing HTTP_PROXY and HTTPS_PROXY from the" +
                                        "environment variables and try again.";
                }
                throw new UnityAgentsException(exceptionMessage);
            }

            var firstRlInput = input.RlInput;

            m_Command = firstRlInput.Command;
            m_EnvironmentParameters = firstRlInput.EnvironmentParameters;
            m_IsTraining            = firstRlInput.IsTraining;
            return(initializationInput.RlInitializationInput);
        }