Question: Inis assignment uses autograding. We rely on the random number generator generating the same random sequence. Same as in Assignment 2 . This time, we

Inis assignment uses autograding. We rely on the random number generator generating the same random sequence. Same as in Assignment 2. This time, we will be using the random.choices() function as follows.This will give the following output.Note that we obtain 80% intendent actions and 10% unintended actions here. Make sure that you understand the output and that you can reproduce it on your machine before proceeding. Note that we use anaconda python 3.9 to obtain the above result.
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).
po.
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 recelved: -0.05
New state:
,-,1?b
ar(p),-,-1
Cunulative rewrd sn: -0.1
Taking action: N(intended: N)
Reward received: -0.05
New state:
,barpbar(n),-,1
s
,S
Cunulativ rew\bar (a) rd sn: -0.15
Taking action: N(Intended: N)
Reward recelved: -0.05
New state:
,P=1
?bar(S)-1
,bar(s)
Cumulativ rew\bar (a) rd sn: -0.2
Taking action: S(Intended: E)
Reward recelved: -0.05
New state:
,barpbar(s)=-1
,S---
Cumulativ rew\bar (a) rd sn: -0.25
-.......................................................
Taking action: N(intended: N)
Reward received: -0.05
New state:
,bar(s)
Cumulative rew\bar (a) rd sn: -0.3
Taking action: E (intended: E)
Reward recelved: -0.65
New state:
,,P,1?b
ar(s),-,-1
Cumulativ rew\bar (a) rd sm: -0.35
Taking action: E (intended: E)
Reward received: -0.05
New state:
,-,1?b
ar(s),-,-1
,bar(s)---1
Cumulativ rew\bar (a) rd sn: -0.4
Taking action: E (intended: E)
Reward recelved: =0.05
New state:
-,-,-?b
ar(s),-,-1
Cumulative rewrd sm: -6-6.45
Taking action: exit (Intended; exit)
Reward received: 1.0
Nw state:
,-,bar(2)?b
ar(2),-1
,s ---
Cumulativ 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.
parse.py
parse.py >ox read_grid_mdp_problem_p1
1 def read_grid_mdp_problem_p1(file_path):
#Your p1 code here
problem =''
return problem
def read_grid_mdp_problem_p2(file_path):
#Your p2 code here.
problem =''
return problem
def read_grid_mdp_problem_p3(file_path):
#Your p3 code here
problem =''
return problem
Inis assignment uses autograding. We rely on the

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!