Question: Problem 1 : An MDP Episode ( 2 5 points ) In this part of the assignment, we are going to play an episode in

Problem 1: An MDP Episode (25 points)
In this part of the assignment, we are going to play an episode in an MDP by following a given policy. Consider the first test case of problem 1(available in the file test_cases/p1/1.prob).
The first part of this file specifies an MDP.S is the start state with four available actions (N,E,S,W is an ordinary state with the same four available actions and 1,-1 are states where the only available action is exit and the reward are 1 and -1 respectively. The reward for action in other states is -0.05.# is a wall.
Actions are not deterministic in this environment. In this case with noise =0.1, we are successfully acting 80% of the time and 20% of the time we will act perpendicular to the intended direction with equal probability, i.e.10%, for each unintended direction. If the agent attempts to move into a wall, the agent will stay in the same position. Note that this MDP is identical to the example that we covered extensively in our class.
The second part of this file specifies the policy to be executed.
As usual, your first task is to implement the parsing of this grid MDP in the function read_grid_mdp_problem_p1(file_path) of the file
parse.py. You may use any appropriate data structure.
Next, you should implement running the episode in the function play_episode(problem) in the file p1. py.
Below is the expected output. Note that we always use exactly 5 characters for the output of a single grid and that the last line does not contain a new line.
Taking action: W (intended: N)
Reward received: -0.05
New state:
-,bar(P),-,1
,-,-1
Cumulativ rew\bar (a) rd sm: -0.1
Taking action: N(intended: N)
Reward received: -0.05
New state:
Cumulativ rew\bar (a) rd sm: -0.15
Taking action: N(intended: N)
Reward received: -0.05
New state:
P,-,1?b
ar(S),-,-1
Cumulativ rew\bar (a) rd sm: -0.2
Taking action: S(intended: E)
Reward received: -0.05
New state:
?bar(P),#,-,1
S,-,-1
Cumulativ rew\bar (a) rd sm: -0.25
Taking action: N(intended: N)
Reward received: -0.05
New state:
P,-,1?b
ar(S),-,-,-1
Cumulativ rew\bar (a) rd sm: -0.3
Taking action: E (intended: E)
Reward received: -0.05
'New state:
Cumulativ rew\bar (a) rd sm: -0.35
Taking action: E (intended: E)
Reward received: -0.05
New state:
Cumulative rew\bar (a) rd sm: -0.4
Taking action: E (intended: E)
Reward received: -0.05
New state:
-,-,P
-,-,-1
?bar(s)
Cumulative rew\bar (a) rd sm: -0.45
Taking action: exit (intended: exit)
Reward received: 1.0
New state:
-,bar(2),-?b
ar(s),-,-1
Cumulative rew\bar (a) rd sm: 0.55
As you can see, in this question we don't use any discount factor. We will introduce that in the next question. You can also try some of the other test cases such as test_cases/p1/8.prob.With a correct implementation, you should be able to pass all test cases.
py q,
import sys, grader, parse
def policy_evaluation(problem):
return_value =''
return return_value
if _="":
test_case_id = int(sys.argv[1])
problem_id =2
grader.grade(problem_id, test_case_id, policy_evaluation, parse.read_grid_mdp_problem_p2)
Problem 1 : An MDP Episode ( 2 5 points ) In this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!