docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method AddReward

    AddReward(float)

    Increments the step and episode rewards by the provided value.

    Declaration
    public void AddReward(float increment)
    Parameters
    Type Name Description
    float increment

    Incremental reward value.

    Remarks

    Use a positive reward to reinforce desired behavior. You can use a negative reward to penalize mistakes. Use SetReward(float) to set the reward assigned to the current step with a specific value rather than increasing or decreasing it.

     Typically, you assign rewards in the Agent subclass's <xref href="Unity.MLAgents.Actuators.IActionReceiver.OnActionReceived(Unity.MLAgents.Actuators.ActionBuffers)" data-throw-if-not-resolved="false"></xref>
     implementation after carrying out the received action and evaluating its success.
    
     Rewards are used during reinforcement learning; they are ignored during inference.
    
     See [Agents - Rewards] for general advice on implementing rewards and [Reward Signals]
     for information about mixing reward signals from curiosity and Generative Adversarial
     Imitation Learning (GAIL) with rewards supplied through this method.
    
     [Agents - Rewards]: https://github.com/Unity-Technologies/ml-agents/blob/release_21_docs/docs/Learning-Environment-Design-Agents.md#rewards
     [Reward Signals]: https://github.com/Unity-Technologies/ml-agents/blob/release_21_docs/docs/ML-Agents-Overview.md#a-quick-note-on-reward-signals
    
    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023