Answered step by step
Verified Expert Solution
Link Copied!

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 3: Succcess Rate Function
In Part 4, 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.
## 3.A - Define Function
Please define a function named `success_rate` with five parameters named `env`,`policy`,`episodes`,`max_steps`, and `random_state`. The function should perform the steps described below.
1. Set the NumPy random seed to `random_state`.
2. Create a variable called `goals`, setting it to 0.
3. 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 `max_steps=max_steps`.
* If the episode resulted in the agent finding the goal, increment `goals`.
4. After the loop completes, calculate and return the observed success rate for the agent.
## 3.B - Test Function
Test your function by calling it on the `FrozenPlatform` environment from Part 2 along with the opimal policy found for that environment using value iteration. Use 10,000 episodes, set `max_steps=200`, and set `random_state=1`.
Print the message below with the blank filled in with the appropriate value, rounded to 4 decimal places. If your function was implemented correctly, you should get a success rate of 0.4114.
When following the optimal policy, the agent's success rate was ____.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do small bank activities differ from large bank activities?

Answered: 1 week ago