EpisodeGenerator: changed termination condition of loop