Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What is difference between SetReward() and AddReward()

Discussion in 'ML-Agents' started by Hsgngr, Aug 27, 2020.

  1. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
    What is difference between SetReward() and AddReward() They all look like same while I am watching the cumulative reward in my environment. I didnt understand the difference which documents talk about.
     
    GhostRoboXt likes this.
  2. ReinierJ

    ReinierJ

    Joined:
    Jul 10, 2020
    Posts:
    10
    With SetReward you set the reward of a specific step during learning. With AddReward you add a value to the current reward value of that step. You can call AddReward(0.5) twice in the same step, or SetReward(1) once, to get the same result. If you first call AddReward(0.5) and then SetReward(0) then the reward in that step will be 0. If you first call SetReward(0.5) and then AddReward(0.5) then the reward in that step will be 1.

    Note that these functions only refer to one step, they don't set the reward for the entire episode (although depending on your setup, the last step in your episode may be the only one in which the agent gets a reward).