November 2018
Intermediate to advanced
322 pages
7h 54m
English
So far, we have randomly picked an action and applied it to the game. Now, let's apply DQN for selecting actions for playing the PacMan game.
def policy_q_nn(obs, env): # Exploration strategy - Select a random action if np.random.random() < explore_rate: action = env.action_space.sample() # Exploitation strategy - Select the action with the highest q else: action = np.argmax(q_nn.predict(np.array([obs]))) return action
def episode(env, policy, r_max=0, t_max=0): # create the empty list to contain ...
Read now
Unlock full access