Assignment 4: Reinforcement Learning

Corresponding TA: Safa Messaoud

Overview

Release Date: 11/20/17

Due Date: 12/12/17

In this assignment you will:

Written Section

Note: Answers without sufficient justification will not recieve any points.

Exercise:

Consider the MDP with two states and represented in the figure below. In , the agent can perform either action or action . In , the agent chooses between actions and action . and are associated with rewards and , respectively.

  1. Apply 3 steps of the policy iteration algorithm with . Assume that the initial policy has actions in and in . Report the new policy after every iteration and its associated value function.
  2. Apply 3 steps of the value iteration algorithm. Assume that the value function associated with every state is initialized to zero. Report a table with the value function computed at every iteration. What is the best policy obtained after these 3 iterations?
  3. Assume that the transition probabilities are unknown, and that the agent's first 3 transitions are given by the tuples , and . Apply the Q-learning algorithm for three iterations with and . Report a table with the Q-function computed at every iteration. What is the best policy obtained after these 3 iterations?

Programming Section

In this part, you will train an AI agent to play the Pong game with two different methods, namely Q-learning and policy gradient. On the low level, the game works as follows: we receive the last 4 image frames which constitute the state of the game and we get to decide if we want to move the paddle to the left, to the right or not to move it (3 actions). After every single choice, the game simulator executes the action and gives us a reward: either a +1 reward if the ball went past the opponent, a -1 reward if we missed the ball and 0 otherwise. Our goal is to move the paddle so that we get lots of reward.

Part 1: Setup

This homework requires: python3, Tensorflow and pygame. Reuse the virtual environment from MP1.

Part 2: Q learning

This exercise requires you to use Q-Learning to train a convolutional neural networks for playing the Pong game. We consider the deep Q-netweork in the figure below. Follow the instructions in the starter code to fill in the missing functions. Include a learning curve plot showing the performance of your implementation. The x-axis should correspond to number of time steps and the y-axis should show the reward. Your agent should be performing well after 4-5m steps.

Relevant File: q_learning.py

Part 3: Policy Gradient

This exercise requires you to use Policy Gradient to train a convolutional neural networks for playing the Pong game. In this case, the network produces a probability distribution over the set of possible actions . After the end of every episode, we label the actions that were taken in this episode with the obtained final reward (+1 if we win and -1 if we lose). Then, we compute the discounted reward for every action. The resulting score is used to compute the policy gradients with respect to the parameters of the convolutional network, i.e. . Follow the instructions in the starter code to fill in the missing functions. Include a learning curve plot showing the performance of your implementation. The x-axis should correspond to number of time steps and the y-axis should show the reward. Your agent should be performing well after 4-5m steps.

Relevant File: policy_gradient.py

Part 4: Submission

Submitting your code is simply commiting you code. This can be done with the follow command:

svn commit -m "Some meaningful comment here."