April 2019
Intermediate to advanced
212 pages
5h 34m
English
In this section, we'll create our first task loop. We'll let our agent run by making random moves until it successfully reaches the goal of dropping off a passenger at the correct location.
Here is a simple way to implement a randomly-acting agent:
state = env.reset()reward = 0while reward != 20: observation, reward, done, info = env.step(env.action_space.sample())env.render()
We reset the environment to put it into a random state for the start of the loop. We set the reward to zero, meaning that the goal has not yet been reached. We call env.step() repeatedly, with env.action_space.sample() as an argument to get a random action from the six allowable actions, and then advance the agent by one step. Finally, we set the ...
Read now
Unlock full access