PIXELBANKv9.1.0
Menu

Problem Statement

The TD(0) target for a single transition (s, r, s') is:

target=r+γV(s′)target = r + \gamma V(s')

Implement td_target(reward, gamma, v_next) returning a float. For a terminal transition callers pass v_next = 0.0.

Example:

Input:
td_target(1.0, 0.9, 10.0)
Output:
10.0
Reasoning:
  • Identify the input parameters for the TD(0) formula: the immediate reward r=1.0r = 1.0, the discount factor γ=0.9\gamma = 0.9, and the value of the next state V(s′)=10.0V(s') = 10.0.
  • Calculate the discounted future value by multiplying the discount factor by the next state's value: γ⋅V(s′)=0.9×10.0=9.0\gamma \cdot V(s') = 0.9 \times 10.0 = 9.0.
  • Add the immediate reward to the discounted future value to compute the target: r+9.0=1.0+9.0=10.0r + 9.0 = 1.0 + 9.0 = 10.0.
  • The final output is 10.0

Constraints:

  • Return a float.
  • No clamping or rounding inside the function.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
TD(0) Target - Easy | PixelBank