Click4Ai

431.

Medium

Reward Shaping

===============

In reinforcement learning, reward shaping is a technique used to modify the reward function to guide the agent towards desired behaviors. The goal is to create a reward function that encourages the agent to take actions that lead to a better outcome.

**Example:** Consider a robot arm that needs to pick up a block. A naive reward function might give a reward of 1 for picking up the block and a penalty of -1 for dropping it. However, this might not be enough to encourage the robot to pick up the block efficiently. A shaped reward function might give a reward of 2 for picking up the block and a penalty of -0.5 for each step taken to pick up the block.

**Constraints:** The shaped reward function should still be a valid reward function, i.e., it should be bounded and should not encourage the agent to take actions that lead to an infinite reward.

**Your Task:** Implement a reward shaping function that takes the original reward function and the shaped reward function as input and returns the shaped reward function.

Test Cases

Test Case 1
Input: np.array([1, 2])
Expected: np.array([2, 4])
Test Case 2
Input: np.array([3, 4])
Expected: np.array([6, 8])
+ 3 hidden test cases