reinforcement learning steps_explore= steps_exploit= xscale='linear')""plots the agent ag label is the label for the plot yplot is 'averageor 'totalstep_size is the number of steps between each point plotted steps_explore is the number of steps the agent spends exploring steps_exploit is the number of steps the agent spends exploiting xscale is 'logor 'linear returns total reward when exploringtotal reward when exploiting ""assert yplot in ['average','total'if step_size is nonestep_size max( ,(steps_explore+steps_exploit)// if label is nonelabel ag label ag max_display_level,old_mdl ,ag max_display_level plt ion(plt xscale(xscaleplt xlabel("step"plt ylabel(yplot+reward"steps [steps rewards [return ag restart(step while step steps_exploreag do(step_sizestep +step_size steps append(stepif yplot ="average"rewards append(ag acc_rewards/stepelserewards append(ag acc_rewardsacc_rewards_exploring ag acc_rewards ag explore,explore_save ,ag explore while step steps_explore+steps_exploitag do(step_sizestep +step_size steps append(stepif yplot ="average"rewards append(ag acc_rewards/stepelserewards append(ag acc_rewardsplt plot(steps,rewards,label=labelplt legend(loc="upper left"plt draw(ag max_display_level old_mdl ag explore=explore_save return acc_rewards_exploringag acc_rewards-acc_rewards_exploring version june