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