Hello, this is my question Description -------------------------------Welcome to the…
- User
Hello, this is my question Description -------------------------------Welcome to the third assignment for this course. The goal of this assignment is to acquire experience in defining and solving a reinforcement learning (RL) environment, following Gym standards. The assignment consists of three parts. The first part focuses on defining an environment that is based on a Markov decision process (MDP). In the second part, we will apply a tabular method SARSA to solve an environment that was previously defined. In the third part, we apply the Q-learning method to solve a grid-world environment. Part I: Define an RL Environment [30 points] In this part, we will define a grid-world reinforcement learning environment as an MDP. While building an RL environment, you need to define possible states, actions, rewards and other parameters. STEPS:
- Choose a scenario for your grid world. You are welcome to use the visualizationdemo as a reference to visualize it. An example of idea for RL environment: • Theme: Lawnmower Grid World with batteries as positive rewards and rocks as negative rewards. • States: {S1 = (0,0), S2 = (0,1), S3 = (0,2), S4 = (0,3), S5 = (1,0), S6 = (1,1), S7 = (1,2), S8 = (1,3), S9 = (2,0), S10 = (2,1), S11 = (2,2), S12 = (2,3), S13 = (3,0), S14 = (3,1), S15 = (3,2), S16 = (3,3)} • Actions: {Up, Down, Right, Left} • Rewards: {-5, -6, +5, +6} • Objective: Reach the goal state with maximum reward
- Define an RL environment following the scenario that you chose. Environment requirements: • Min number of states: 12 • Min number of actions: 4 • Min number of rewards: 4 Environment definition should follow the OpenAI Gym structure, which includes thebasic methods. You can use the “Defining RL env” demo as a base code. def init:
Initializes the class
Define action and observation space
def step:
Executes one timestep within the environment
Input to the function is an action
def reset:
Resets the state of the environment to an initial state
def render:
Visualizes the environment
Any form like vector representation or visualizing
usingmatplotlib is sufficient 3. Run a random agent for at least 10 timesteps to show that the environment logic is defined correctly. Print the current state, chosen action, reward and return your grid world visualization for each step. In your report for Part I:
- Describe the environment that you defined. Provide a set of actions, states, rewards, main objective, etc.
- Provide visualization of your environment.
- Safety in AI: Write a brief review (∼ 5 sentences) explaining how you ensure the safety of your environment. E.g. how do you ensure that the agent chooses only actions that are allowed, that agent is navigating within defined state-space, etc -------------------This is my answer ------------------------------------------------- import numpy as np import gym from gym import spaces import matplotlib.pyplot as plt
- Assistant