.
info = environment.reset() # Keep going until it terminates - if there's no terminal state then # it'll keep going forever, so you would insert a 'break' in the loop! while not done: action = ... # Pick an action based on a policy # Step forward in time, simulating the MDP state, reward, done, info