def play_episode(env, policy, render_option, min_steps):
    """
    Play an episode with the given policy.

    :param min_steps: the minimum steps the game should be played
    :param env: the OpenAI gym environment
    :param policy: the policy that should be used to generate actions
    :param render_option: how the game play should be rendered
    :return: episode reward
    """
    state = env.reset()
    done = False
    episode_reward = 0.0
    step_cnt = 0
    while not done or step_cnt < min_steps:
        if render_option == 'collect':
            env.render()
        action = policy(state)
        next_state, reward, done, _ = env.step(action)
        episode_reward += reward
        state = next_state
        step_cnt += 1
    print('episode finished with reward {0}'.format(episode_reward))
    return episode_reward