episode_reward while true take step using best action or random action obs_t_oh one_hot(obs_tn_obsaction session run(pred_act_phfeed_dict={obs_t_phobs_t_oh})[ if np random rand( exploration_probability(episode)action env action_space sample(obs_tp rewarddone_ env step(action train model obs_tp _oh one_hot(obs_tp n_obsq_target_val session run(q_targetfeed_dict=obs_tp _phobs_tp _oh }session run(update_modelfeed_dict=obs_t_phobs_t_ohrew_phrewardq_target_phq_target_valact_phaction }episode_reward +reward obs_t obs_tp if donerewards append(episode_reward