Answers.Body: <p>I would like to point out this paper: <a href="https://arxiv.org/pdf/1712.00378.pdf" rel="noreferrer">https://arxiv.org/pdf/1712.00378.pdf</a>, that answers exactly that question.</p>
  
  <blockquote>
    <p>We then showed that, when learning policies for time-unlimited tasks, it is necessary for correct value estimation, to continue bootstrapping at the end of the partial episodes when termination is due to time limits, or any early termination causes other than the environmental ones.</p>
  </blockquote>
  
  <p>The authors therefore argue, that the target <span class="math-container">$y$</span> for a one-step TD update, after transitioning to a state <span class="math-container">$s′$</span> and receiving a reward <span class="math-container">$r$</span>, should be:</p>
  
  <p><span class="math-container">$$
  y = 
  \begin{cases}
  r &amp; \text{if environment terminates}\\
  r+\gamma\hat{v}_{\pi}(s') &amp; \text{otherwise (including timeouts)}
  \end{cases}
  $$</span></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-25T17:44:01.087Z
Answers.LastActivityDate: 2020-01-25T18:04:59.917Z
Answers.LastEditDate: 2020-01-25T18:04:59.917Z
Answers.UserDisplayName: karlkurzer
Answers.Body: <p>The practical need for a <span class="math-container">$T$</span> or <span class="math-container">$t_{max}$</span> is based on the importance of prudent doubt as a cost containment measure.  At a certain point, it is wise to abandon an objective the resolution of which cannot be certain.  This is a technique used in the minimization of a much wider loss function associated with the business into which the seeking of the learning objective fits.</p>
  
  <p>Dismissing the easily retained knowledge of the state of the independent process variable <span class="math-container">$t$</span> in the context of its domain <span class="math-container">$[1, T]$</span> as irrelevant is like working on a project without project management.  What things to skip and what risks to take cannot be accurately evaluated, reducing the probability of success in relation to its optimum.</p>
  
  <p>Certainly the value gained at any step is an indicator of the advantage of the current path, an affirmation that impacts the probability of achieving favorable results before <span class="math-container">$t$</span> reaches <span class="math-container">$T$</span>.  Certainly any knowledge that can be used to predict possible values along the paths that begin with choices that can be made at any step should impact that choice.</p>
  
  <p>The question author's intuition that the critic should be aware that the stakeholder may pull the plug on the project soon is correct.  In terms of the mathematics, whether urgency can be formulated as something like <span class="math-container">$u(t) \propto \dfrac {1} {T - t + 1}$</span> and used as a term or a factor requires some thought about the probabilities involved.  The advantage expression should reflect the application of the basic relations of probability to the probability distributions as seen considering all the information known at any temporal point along the pursuit of the objective.</p>
  
  <p>The only occasion when a variable that can be known should be excluded from the advantage expression is if it can be shown to be absolutely irrelevant or that its relevance is sufficiently small to warrant exclusion to gain computational speed in exchange for loss of accuracy and/or reliability.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-03T02:57:37.477Z
Answers.Text: Thank you for your answer! Basically you're suggesting to give the value of the timer to the agent as an additional input, and I agree with you, this seems like a very reasonable thing to do. To my surprise, the majority of existing RL algorithms do not bother with that.
Answers.UserDisplayName: Aleksei Petrenko
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-27T08:15:37.643Z
Answers.LastActivityDate: 2018-11-28T02:58:52.077Z
Answers.LastEditDate: 2018-11-28T02:58:52.077Z
Answers.UserDisplayName: Douglas Daseeco
Answers.Body: <p>First a small note: I don't think your expression for <span class="math-container">$A(s_{T-1}, a_{T - 1})$</span> looks correct. If we assume that <span class="math-container">$V(s_T) = 0$</span> (i.e., assume that we cannot possibly reach the goal in one single step from <span class="math-container">$s_{T - 1}$</span>), we have:</p>
  
  <p><span class="math-container">\begin{align}
  A(s_{T-1}, a_{T-1}) &amp;= r(s_{T-1}, a_{T-1}) + \gamma V(s_{T}) (1 - done_{T})  - V(s_{T-1}) \\
  &amp;= r(s_{T-1}, a_{T-1}) - V(s_{T-1}).
  \end{align}</span></p>
  
  <p>In this expression, we'd normally have that <span class="math-container">$r(s_{T-1}, a_{T-1}) = -0.1$</span>, whereas you seem to have mistakenly taken <span class="math-container">$+0.1$</span> in your post.</p>
  
  <hr>
  
  <p>Those details aside; yes, there can be sudden bumps of positive advantage estimates as you described. This is not a problem though, this is exactly what we'd expect to happen given your description of the environment.</p>
  
  <p>You describe an environment in which the agent is likely going to be wandering around randomly (at least when it hasn't learned a good policy yet), and incurring negative rewards over and over again. This naturally leads to negative value estimates for all encountered states. Suddenly, it does something and the episode terminates; it receives a nice reward of <span class="math-container">$0$</span> rather than yet another negative reward (this actually "feels" like a bonus, a positive reward, something more than was expected). When your agent has not yet learned a good policy that can reach the better reward of <span class="math-container">$1$</span>, this is indeed a good result, a good action, and it rightfully should get reinforced.</p>
  
  <p>Because this event of the episode terminating is mostly uncorrelated with the state (I say "mostly", because in theory it probably ends up being a slightly rarer event in states close to the goal than in states far away from the goal), it will eventually (after sufficient training time) end up occurring approximately equally often in all states. From the perspective of an agent that is oblivious to the current time step, this will be perceived as an event that can simply occur by pure chance in a nondeterministic environment.</p>
  
  <p>This is not necessarily a problem. It can slow down learning due to increased variance in your reward observations (which can be addressed by using low learning rates / large batch sizes), but Reinforcement Learning algorithms are almost always naturally built to handle nondeterministic environments, it can work this out, it can average out all the different outcomes observed for the same state+action pairs. <strong>This is not a problem that requires dealing with</strong>.</p>
  
  <hr>
  
  <blockquote>
    <p>My ideas:</p>
    
    <ol>
    <li>Differentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with <span class="math-container">$0$</span>.</li>
    <li>Somehow add <span class="math-container">$t$</span> to the state such that the value function can learn to anticipate the termination of the episode.</li>
    </ol>
  </blockquote>
  
  <p>The first idea fundamentally changes the quantity that your algorithm is learning, it will essentially make your learning algorithm incorrect. There's always a chance that it might still appear to learn something useful (many Machine Learning/Reinforcement Learning algorithms can still appear to be okay even when there are bugs/technically incorrect parts), but it'll very likely perform worse.</p>
  
  <p>The second idea, while <strong>not necessary</strong> as explained in my answer above, <strong>may still be beneficial to learning speed provided it is done well</strong>. It may help because it can add to the power of your algorithm to "explain" its observations, and more importantly "explain" the variance in its observations.</p>
  
  <p>The main problem I see with adding <span class="math-container">$t$</span> to your input is that it is not naturally a binary variable. Very often you'll find that we're just using a bunch of binary inputs in (Deep) Reinforcement Learning algorithms. When all inputs are of the same magnitude like that, it tends to be easier to get the learning process to run well, tune hyperparameters like learning rate, etc. If you suddenly plug in an additional input which can take significantly larger values (like straight up adding <span class="math-container">$t$</span> as an input), this will be more difficult. Adding <span class="math-container">$\frac{t}{T}$</span> as an input may be better, since that will always still be bounded between <span class="math-container">$0$</span> and <span class="math-container">$1$</span>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-28T00:05:38.183Z
Answers.Text: Thank you very much for your comments, and thanks for correcting my equations! It should make sense now.
  I see your point, and it seems very reasonable, but this is not what I observe in practice. Your assumption that episode termination will occur with equal probability in all states is not always correct.
  Assume we have a maze with multiple rooms, and initially, with non-trained policy, we're basically doing the random walk. Hence the episode termination by timer will more often occur near the starting room, and this room will gradually be assigned higher value, which is not what we want.
Answers.UserDisplayName: Aleksei Petrenko
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-28T00:08:25.953Z
Answers.Text: Because of that, we have sort of feedback loop. Episode terminates more often near the starting room -> starting room gets higher value -> agent tends to stick around the starting position and stops exploring.
  I agree with your thoughs about adding $\frac{t}{T}$ to the state, that's a good idea! Before I tried to add $\log t$ (because it's small) but it didn't work very well.
Answers.UserDisplayName: Aleksei Petrenko
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-28T09:17:40.677Z
Answers.Text: @AlexeyPetrenko That's right, but those "higher values" are not going to keep going up and up and up... They're still never going to get greater than $0$ (or technically some negative function of $T$ and $\gamma$). And this exact same upper bound will be reached by every single episode that doesn't end at the goal. So, eventually this same value should saturate the complete state-action space around the starting position, and in theory this should allow the agent to explore past it though.
Answers.UserDisplayName: Dennis Soemers
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-28T09:19:56.843Z
Answers.Text: In practice, you're right, local optima can certainly be an annoying problem. You'd see exactly the same problem if there was a low reward (something like $r = 1$ achievable near the start, but a much greater reward (like $r = 100$) far away from the initial position. Many RL algorithms would have a tendency to get stuck around that $r = 1$ reward. This is pretty much the issue you're facing too. This is not a problem inherent to the A2C or other actor-critic or advantage-based algorithms, practically any RL algorithm can suffer from this. The problem is in exploration, not in the learning.
Answers.UserDisplayName: Dennis Soemers
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-27T18:15:54.687Z
Answers.LastActivityDate: 2018-11-27T18:15:54.687Z
Answers.UserDisplayName: Dennis Soemers
Body: <p>Advantage Actor-Critic algorithm may use the following expression to get 1-step estimate of the advantage:</p>
  
  <p><span class="math-container">$ A(s_t,a_t) = r(s_t, a_t) + \gamma V(s_{t+1}) (1 - done_{t+1})  - V(s_t) $</span></p>
  
  <p>where <span class="math-container">$done_{t+1}=1$</span> if <span class="math-container">$s_{t+1}$</span> is a terminal state (end of the episode) and <span class="math-container">$0$</span> otherwise.</p>
  
  <p>Suppose our learning environment has a goal, collecting the goal gives reward <span class="math-container">$r=1$</span> and terminates the episode. Agent also receives <span class="math-container">$r=-0.1$</span> for every step, encouraging it to collect the goal faster. We're learning with <span class="math-container">$\gamma=0.99$</span> and we terminate the episode after <span class="math-container">$T$</span> timesteps if the goal wasn't collected.</p>
  
  <p>For the state before collecting a goal we have the following advantage, which seems very reasonable: <span class="math-container">$A(s_t,a_t) = 1 - V(s_t)$</span>.</p>
  
  <p>For the timestep <span class="math-container">$T-1$</span>, regardless of the state, we have: <span class="math-container">$ A(s_{T-1},a_{T-1}) = r(s_{T-1}, a_{T-1}) - V(s_{T-1}) \approx -0.1 -\frac{-0.1}{1-\gamma} = -0.1 + 10 = 9.9 $</span> 
  (this is true under the assumption that we're not yet able to collect the goal reliably often, therefore the value function  converges to something close to <span class="math-container">$\frac{r_{avg}}{1-\gamma} \approx -10 $</span> ).</p>
  
  <p>Usually, <span class="math-container">$T$</span> is not a part of the state, so the value function has no way to anticipate the sudden change in reward-to-go. So, all of a sudden, we got a (relatively) big advantage for the arbitrary action that we took at the timestep <span class="math-container">$T-1$</span>.  Following the policy gradient rule, we will significantly increase the probability of an arbitrary action that we took at the end of the episode, even if we didn't achieve anything. This can quickly destroy the learning process.</p>
  
  <p>How do people deal with this problem in practice? My ideas:</p>
  
  <ol>
  <li>Differentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with <span class="math-container">$0$</span>.</li>
  <li>Somehow add <span class="math-container">$t$</span> to the state such that the value function can learn to anticipate the termination of the episode.</li>
  </ol>
  
  <p>As I noticed, the A2C implementation in OpenAI baselines does not seem to bother with any of that:</p>
  
  <ul>
  <li><p><a href="https://github.com/openai/baselines/blob/f3a5abaeeb1c1c9136a01c9dbfebc173dc311fef/baselines/a2c/runner.py#L64" rel="noreferrer">A2C implementation - calculation of discounted rewards</a></p></li>
  <li><p><a href="https://github.com/openai/baselines/blob/8c2aea2addc9f3ba36d4a0c937e6a2d09830afc7/baselines/a2c/utils.py#L147" rel="noreferrer"><code>discount_with_dones</code> function</a></p></li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-27T09:22:27.933Z
Comments.Text: Can you elaborate on how you came up with that expression for $A(s_{T-1}, a_{T - 1})$? Shouldn't that $0.1$ term be $-0.1$? The expression $0.1 - V(s_{T-1}) \approx -V(s_{T-1})$ also looks suspect to me... you're just throwing away the $0.1$ term arbitrarily?
Comments.UserDisplayName: Dennis Soemers
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-27T23:47:31.773Z
Comments.Text: @DennisSoemers sorry, this was a little sloppy on my side, should be -0.1 of course, corrected. I was editing this from the phone and screwed up a bit) Yes, I am throwing away the 0.1 because cumulative value is much larger than 1-step reward (V >> r). Would be 9.9 instead of 10, no big deal. These are approximate equalities.
Comments.UserDisplayName: Aleksei Petrenko
Tags: <reinforcement-learning>
Title: How to deal with episode termination in Advantage Actor-Critic algorithm?
UserDisplayName: Aleksei Petrenko
ThreadText: # How to deal with episode termination in Advantage Actor-Critic algorithm?
  
  (Asked by: username_0 on 2018-11-27)
  
  Advantage Actor-Critic algorithm may use the following expression to get 1-step estimate of the advantage:
  
  $ A(s\_t,a\_t) = r(s\_t, a\_t) + \gamma V(s\_{t+1}) (1 - done\_{t+1}) - V(s\_t) $
  
  where $done\_{t+1}=1$ if $s\_{t+1}$ is a terminal state (end of the episode) and $0$ otherwise.
  
  Suppose our learning environment has a goal, collecting the goal gives reward $r=1$ and terminates the episode. Agent also receives $r=-0.1$ for every step, encouraging it to collect the goal faster. We're learning with $\gamma=0.99$ and we terminate the episode after $T$ timesteps if the goal wasn't collected.
  
  For the state before collecting a goal we have the following advantage, which seems very reasonable: $A(s\_t,a\_t) = 1 - V(s\_t)$.
  
  For the timestep $T-1$, regardless of the state, we have: $ A(s\_{T-1},a\_{T-1}) = r(s\_{T-1}, a\_{T-1}) - V(s\_{T-1}) \approx -0.1 -\frac{-0.1}{1-\gamma} = -0.1 + 10 = 9.9 $
  (this is true under the assumption that we're not yet able to collect the goal reliably often, therefore the value function converges to something close to $\frac{r\_{avg}}{1-\gamma} \approx -10 $ ).
  
  Usually, $T$ is not a part of the state, so the value function has no way to anticipate the sudden change in reward-to-go. So, all of a sudden, we got a (relatively) big advantage for the arbitrary action that we took at the timestep $T-1$. Following the policy gradient rule, we will significantly increase the probability of an arbitrary action that we took at the end of the episode, even if we didn't achieve anything. This can quickly destroy the learning process.
  
  How do people deal with this problem in practice? My ideas:
  
  1. Differentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with $0$.
  2. Somehow add $t$ to the state such that the value function can learn to anticipate the termination of the episode.
  
  As I noticed, the A2C implementation in OpenAI baselines does not seem to bother with any of that:
  
  * [A2C implementation - calculation of discounted rewards](https://github.com/openai/baselines/blob/f3a5abaeeb1c1c9136a01c9dbfebc173dc311fef/baselines/a2c/runner.py#L64)
  * [`discount_with_dones` function](https://github.com/openai/baselines/blob/8c2aea2addc9f3ba36d4a0c937e6a2d09830afc7/baselines/a2c/utils.py#L147)
  
  **Tags:** reinforcement-learning
  
  > **Comments:**
  > **username_1**: Can you elaborate on how you came up with that expression for $A(s_{T-1}, a_{T - 1})$? Shouldn't that $0.1$ term be $-0.1$? The expression $0.1 - V(s_{T-1}) \approx -V(s_{T-1})$ also looks suspect to me... you're just throwing away the $0.1$ term arbitrarily?  
  > **username_0**: @username_1 sorry, this was a little sloppy on my side, should be -0.1 of course, corrected. I was editing this from the phone and screwed up a bit) Yes, I am throwing away the 0.1 because cumulative value is much larger than 1-step reward (V >> r). Would be 9.9 instead of 10, no big deal. These are approximate equalities.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2018-11-27. Score: 5 | Accepted answer
  
  First a small note: I don't think your expression for $A(s\_{T-1}, a\_{T - 1})$ looks correct. If we assume that $V(s\_T) = 0$ (i.e., assume that we cannot possibly reach the goal in one single step from $s\_{T - 1}$), we have:
  
  \begin{align}
  A(s\_{T-1}, a\_{T-1}) &= r(s\_{T-1}, a\_{T-1}) + \gamma V(s\_{T}) (1 - done\_{T}) - V(s\_{T-1}) \\
  &= r(s\_{T-1}, a\_{T-1}) - V(s\_{T-1}).
  \end{align}
  
  In this expression, we'd normally have that $r(s\_{T-1}, a\_{T-1}) = -0.1$, whereas you seem to have mistakenly taken $+0.1$ in your post.
  
  ---
  
  Those details aside; yes, there can be sudden bumps of positive advantage estimates as you described. This is not a problem though, this is exactly what we'd expect to happen given your description of the environment.
  
  You describe an environment in which the agent is likely going to be wandering around randomly (at least when it hasn't learned a good policy yet), and incurring negative rewards over and over again. This naturally leads to negative value estimates for all encountered states. Suddenly, it does something and the episode terminates; it receives a nice reward of $0$ rather than yet another negative reward (this actually "feels" like a bonus, a positive reward, something more than was expected). When your agent has not yet learned a good policy that can reach the better reward of $1$, this is indeed a good result, a good action, and it rightfully should get reinforced.
  
  Because this event of the episode terminating is mostly uncorrelated with the state (I say "mostly", because in theory it probably ends up being a slightly rarer event in states close to the goal than in states far away from the goal), it will eventually (after sufficient training time) end up occurring approximately equally often in all states. From the perspective of an agent that is oblivious to the current time step, this will be perceived as an event that can simply occur by pure chance in a nondeterministic environment.
  
  This is not necessarily a problem. It can slow down learning due to increased variance in your reward observations (which can be addressed by using low learning rates / large batch sizes), but Reinforcement Learning algorithms are almost always naturally built to handle nondeterministic environments, it can work this out, it can average out all the different outcomes observed for the same state+action pairs. **This is not a problem that requires dealing with**.
  
  ---
  
  > My ideas:
  >
  > 1. Differentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with $0$.
  > 2. Somehow add $t$ to the state such that the value function can learn to anticipate the termination of the episode.
  
  The first idea fundamentally changes the quantity that your algorithm is learning, it will essentially make your learning algorithm incorrect. There's always a chance that it might still appear to learn something useful (many Machine Learning/Reinforcement Learning algorithms can still appear to be okay even when there are bugs/technically incorrect parts), but it'll very likely perform worse.
  
  The second idea, while **not necessary** as explained in my answer above, **may still be beneficial to learning speed provided it is done well**. It may help because it can add to the power of your algorithm to "explain" its observations, and more importantly "explain" the variance in its observations.
  
  The main problem I see with adding $t$ to your input is that it is not naturally a binary variable. Very often you'll find that we're just using a bunch of binary inputs in (Deep) Reinforcement Learning algorithms. When all inputs are of the same magnitude like that, it tends to be easier to get the learning process to run well, tune hyperparameters like learning rate, etc. If you suddenly plug in an additional input which can take significantly larger values (like straight up adding $t$ as an input), this will be more difficult. Adding $\frac{t}{T}$ as an input may be better, since that will always still be bounded between $0$ and $1$.
  
  > **Comments:**
  > **username_0**: Thank you very much for your comments, and thanks for correcting my equations! It should make sense now. I see your point, and it seems very reasonable, but this is not what I observe in practice. Your assumption that episode termination will occur with equal probability in all states is not always correct. Assume we have a maze with multiple rooms, and initially, with non-trained policy, we're basically doing the random walk. Hence the episode termination by timer will more often occur near the starting room, and this room will gradually be assigned higher value, which is not what we want.  
  > **username_0**: Because of that, we have sort of feedback loop. Episode terminates more often near the starting room -> starting room gets higher value -> agent tends to stick around the starting position and stops exploring. I agree with your thoughs about adding $\frac{t}{T}$ to the state, that's a good idea! Before I tried to add $\log t$ (because it's small) but it didn't work very well.  
  > **username_1**: @AlexeyPetrenko That's right, but those "higher values" are not going to keep going up and up and up... They're still never going to get greater than $0$ (or technically some negative function of $T$ and $\gamma$). And this exact same upper bound will be reached by every single episode that doesn't end at the goal. So, eventually this same value should saturate the complete state-action space around the starting position, and in theory this should allow the agent to explore past it though.  
  > **username_1**: In practice, you're right, local optima can certainly be an annoying problem. You'd see exactly the same problem if there was a low reward (something like $r = 1$ achievable near the start, but a much greater reward (like $r = 100$) far away from the initial position. Many RL algorithms would have a tendency to get stuck around that $r = 1$ reward. This is pretty much the issue you're facing too. This is not a problem inherent to the A2C or other actor-critic or advantage-based algorithms, practically any RL algorithm can suffer from this. The problem is in exploration, not in the learning.  
  
  ---
  
  ### Answer by username_2 on 2020-01-25. Score: 6
  
  I would like to point out this paper: <https://arxiv.org/pdf/1712.00378.pdf>, that answers exactly that question.
  
  > We then showed that, when learning policies for time-unlimited tasks, it is necessary for correct value estimation, to continue bootstrapping at the end of the partial episodes when termination is due to time limits, or any early termination causes other than the environmental ones.
  
  The authors therefore argue, that the target $y$ for a one-step TD update, after transitioning to a state $s′$ and receiving a reward $r$, should be:
  
  $$
  y =
  \begin{cases}
  r & \text{if environment terminates}\\
  r+\gamma\hat{v}\_{\pi}(s') & \text{otherwise (including timeouts)}
  \end{cases}
  $$
  
  
  ---
  
  ### Answer by username_3 on 2018-11-27. Score: 1
  
  The practical need for a $T$ or $t\_{max}$ is based on the importance of prudent doubt as a cost containment measure. At a certain point, it is wise to abandon an objective the resolution of which cannot be certain. This is a technique used in the minimization of a much wider loss function associated with the business into which the seeking of the learning objective fits.
  
  Dismissing the easily retained knowledge of the state of the independent process variable $t$ in the context of its domain $[1, T]$ as irrelevant is like working on a project without project management. What things to skip and what risks to take cannot be accurately evaluated, reducing the probability of success in relation to its optimum.
  
  Certainly the value gained at any step is an indicator of the advantage of the current path, an affirmation that impacts the probability of achieving favorable results before $t$ reaches $T$. Certainly any knowledge that can be used to predict possible values along the paths that begin with choices that can be made at any step should impact that choice.
  
  The question author's intuition that the critic should be aware that the stakeholder may pull the plug on the project soon is correct. In terms of the mathematics, whether urgency can be formulated as something like $u(t) \propto \dfrac {1} {T - t + 1}$ and used as a term or a factor requires some thought about the probabilities involved. The advantage expression should reflect the application of the basic relations of probability to the probability distributions as seen considering all the information known at any temporal point along the pursuit of the objective.
  
  The only occasion when a variable that can be known should be excluded from the advantage expression is if it can be shown to be absolutely irrelevant or that its relevance is sufficiently small to warrant exclusion to gain computational speed in exchange for loss of accuracy and/or reliability.
  
  > **Comments:**
  > **username_0**: Thank you for your answer! Basically you're suggesting to give the value of the timer to the agent as an additional input, and I agree with you, this seems like a very reasonable thing to do. To my surprise, the majority of existing RL algorithms do not bother with that.  
  
  ---
  
  