예제 #1
0
    public override void InitializeAcademy()
    {
        if (RobotAgent.GetComponent <RobotAgent>().usePlayerBrain)
        {
            MLAgents.PlayerBrain playerBrain = (MLAgents.PlayerBrain)Resources.Load("_RobotPlayerBrain");
            GetComponent <Academy>().broadcastHub.Clear();
            GetComponent <Academy>().broadcastHub.broadcastingBrains.Add(playerBrain);
        }

        Monitor.SetActive(true);
        this.SetIsInference(_isInference);
    }
예제 #2
0
        /// <summary>
        /// Draws the UI for continuous control key mapping to actions.
        /// </summary>
        /// <param name="serializedBrain"> The SerializedObject corresponding to the brain. </param>
        /// <param name="brain"> The Brain of which properties are displayed. </param>
        private static void DrawContinuousKeyMapping(
            SerializedObject serializedBrain, PlayerBrain brain)
        {
            GUILayout.Label("Edit the continuous inputs for your actions", EditorStyles.boldLabel);
            var keyActionsProp  = serializedBrain.FindProperty(KeyContinuousPropName);
            var axisActionsProp = serializedBrain.FindProperty(AxisContinuousPropName);

            EditorGUILayout.PropertyField(keyActionsProp, true);
            EditorGUILayout.PropertyField(axisActionsProp, true);
            var keyContinuous  = brain.keyContinuousPlayerActions;
            var axisContinuous = brain.axisContinuousPlayerActions;
            var brainParams    = brain.brainParameters;

            if (keyContinuous == null)
            {
                keyContinuous = new PlayerBrain.KeyContinuousPlayerAction[0];
            }
            if (axisContinuous == null)
            {
                axisContinuous = new PlayerBrain.AxisContinuousPlayerAction[0];
            }
            foreach (var action in keyContinuous)
            {
                if (action.index >= brainParams.vectorActionSize[0])
                {
                    EditorGUILayout.HelpBox(
                        $"Key {action.key.ToString()} is assigned to index " +
                        $"{action.index.ToString()} but the action size is only of size " +
                        $"{brainParams.vectorActionSize.ToString()}",
                        MessageType.Error);
                }
            }
            foreach (var action in axisContinuous)
            {
                if (action.index >= brainParams.vectorActionSize[0])
                {
                    EditorGUILayout.HelpBox(
                        $"Axis {action.axis} is assigned to index {action.index.ToString()} " +
                        $"but the action size is only of size {brainParams.vectorActionSize}",
                        MessageType.Error);
                }
            }
            GUILayout.Label("You can change axis settings from Edit->Project Settings->Input",
                            EditorStyles.helpBox);
        }
예제 #3
0
    public override void InitializeAgent()
    {
        if (usePlayerBrain)
        {
            MLAgents.PlayerBrain playerBrain = (MLAgents.PlayerBrain)Resources.Load("_RobotPlayerBrain");
            this.brain = playerBrain;
            print("Brain loaded");
        }

        rbMainBody = MainBody.GetComponent <Rigidbody>();
        rbPalette  = Palette.GetComponent <Rigidbody>();
        rayPer     = MainBody.GetComponent <Ray3D>();

        forkPosition                  = forkMin;
        maxAngularVelocity            = Ray.DegreeToRadian(360) * rpm / 60;
        rbMainBody.maxAngularVelocity = maxAngularVelocity;

        GameObject ground    = GameObject.Find("Ground");
        var        transform = ground.GetComponent <Transform>();

        maxPositionValue = transform.lossyScale.x * 10 / 2;
        minPositionValue = -maxPositionValue;
    }