Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Part 3 : Succcess Rate Function In Part 4 , you will be frequently asked to use simulation to estimate an agent's success rate
# Part : Succcess Rate Function
In Part you will be frequently asked to use simulation to estimate an agent's success rate under a given policy. To simplify this process, we will create a function to run such a simulation.
## A Define Function
Please define a function named successrate with five parameters named envpolicyepisodesmaxsteps and randomstate The function should perform the steps described below.
Set the NumPy random seed to randomstate
Create a variable called goals setting it to
Run a for loop for a number of iterations indicated by the episodes parameter. The loop should complete the following steps in each iteration:
Generate an episode for the environment instance env following the policy given by the policy parameter. To avoid infinite loops, set maxstepsmaxsteps
If the episode resulted in the agent finding the goal, increment goals
After the loop completes, calculate and return the observed success rate for the agent.
## B Test Function
Test your function by calling it on the FrozenPlatform environment from Part along with the opimal policy found for that environment using value iteration. Use episodes, set maxsteps and set randomstate
Print the message below with the blank filled in with the appropriate value, rounded to decimal places. If your function was implemented correctly, you should get a success rate of
When following the optimal policy, the agent's success rate was
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started