Example #1
0
    void Awake()
    {
        resetParameters = new Dictionary <string, float>();
        foreach (ResetParameter kv in defaultResetParameters)
        {
            resetParameters[kv.key] = kv.value;
        }

        GetBrains(gameObject, brains);
        InitializeAcademy();

        communicator = new ExternalCommunicator(this);
        if (!communicator.CommunicatorHandShake())
        {
            communicator = null;
        }

        foreach (Brain brain in brains)
        {
            brain.InitializeBrain();
        }
        if (communicator != null)
        {
            communicator.InitializeCommunicator();
            externalCommand = communicator.GetCommand();
        }

        isInference           = (communicator == null);
        _isCurrentlyInference = !isInference;
        done           = true;
        acceptingSteps = true;
    }
Example #2
0
    /// <summary>
    /// Initializes the environment, configures it and initialized the Academy.
    /// </summary>
    void InitializeEnvironment()
    {
        // Retrieve Brain and initialize Academy
        List <Brain> brains = GetBrains(gameObject);

        InitializeAcademy();

        // Check for existence of communicator
        communicator = new ExternalCommunicator(this);
        if (!communicator.CommunicatorHandShake())
        {
            communicator = null;
        }

        // Initialize Brains and communicator (if present)
        foreach (Brain brain in brains)
        {
            brain.InitializeBrain(this, communicator);
        }
        if (communicator != null)
        {
            isCommunicatorOn = true;
            communicator.InitializeCommunicator();
            communicator.UpdateCommand();
        }

        // If a communicator is enabled/provided, then we assume we are in
        // training mode. In the absence of a communicator, we assume we are
        // in inference mode.
        isInference = !isCommunicatorOn;

        BrainDecideAction += () => { };
        AgentSetStatus    += (m, d, i) => { };
        AgentResetIfDone  += () => { };
        AgentSendState    += () => { };
        AgentAct          += () => { };
        AgentForceReset   += () => { };

        // Configure the environment using the configurations provided by
        // the developer in the Editor.
        ConfigureEnvironment();
    }