Answers.Body: <p>There is two ways to formulate a reward function for these types of problems. First there is <strong>sparse reward</strong>:</p>
  <p>Win +1</p>
  <p>Loss -1</p>
  <p>All other rewards are 0.</p>
  <p>As the opposite  there also exist <strong>dense rewards</strong>, which could be some signal for every timestep which tells you how well you're doing, i.e. give rewards in chess if you kick an opponents piece of the board.</p>
  <p>Sparse rewards is harder to learn from since a lot of the time your reward and so your gradient is 0. On the other hand reward functions for dense reward require careful crafting by hand and leave room for human error and bias.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-10T18:08:44.683Z
Answers.LastActivityDate: 2021-09-10T18:08:44.683Z
Answers.UserDisplayName: tnfru
Body: <p>I am new to Reinforcement Learning and trying to understand the concept of reaping rewards during episodic tasks. I think in games like tic-tac-toe, rewards will be in terms of a win or lose. But does that mean we need to finish the entire game to gain the reward? I mean reward will make sense only if three of the tokens are in one line. Each game of tic-tac-toe will be different as the sequence of actions followed will be different. So does reward come into the picture only after completing the game? And what if the game is a draw?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-10T18:27:53.450Z
Comments.Text: This question seems to be related to or a duplicate of [this](https://ai.stackexchange.com/q/12189/2444), [this](https://ai.stackexchange.com/q/22603/2444) or [this](https://ai.stackexchange.com/q/23292/2444).
Comments.UserDisplayName: nbro
Tags: <reinforcement-learning><deep-rl><rewards><reward-functions><tic-tac-toe>
Title: How are rewards calculated for episodic tasks like playing chess or tic-tac-toe?
UserDisplayName: Saily_Shah
ThreadText: # How are rewards calculated for episodic tasks like playing chess or tic-tac-toe?
  
  (Asked by: username_0 on 2021-09-10)
  
  I am new to Reinforcement Learning and trying to understand the concept of reaping rewards during episodic tasks. I think in games like tic-tac-toe, rewards will be in terms of a win or lose. But does that mean we need to finish the entire game to gain the reward? I mean reward will make sense only if three of the tokens are in one line. Each game of tic-tac-toe will be different as the sequence of actions followed will be different. So does reward come into the picture only after completing the game? And what if the game is a draw?
  
  **Tags:** reinforcement-learning, deep-rl, rewards, reward-functions, tic-tac-toe
  > **Comments:**
  > **username_1**: This question seems to be related to or a duplicate of [this](https://ai.stackexchange.com/q/12189/2444), [this](https://ai.stackexchange.com/q/22603/2444) or [this](https://ai.stackexchange.com/q/23292/2444).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-09-10. Score: 1
  
  There is two ways to formulate a reward function for these types of problems. First there is **sparse reward**:
  
  Win +1
  
  Loss -1
  
  All other rewards are 0.
  
  As the opposite there also exist **dense rewards**, which could be some signal for every timestep which tells you how well you're doing, i.e. give rewards in chess if you kick an opponents piece of the board.
  
  Sparse rewards is harder to learn from since a lot of the time your reward and so your gradient is 0. On the other hand reward functions for dense reward require careful crafting by hand and leave room for human error and bias.
  
  
  ---
  
  