def evaluate_single_episode(environment, agent, render=False, epsilon=None):
    """
    Evaluate a single episode of agent operating inside of an environment.

    This method should be applicable to all reinforcement learning algorithms
    so long as they implement the Agent interface.
    """
    state = environment.reset()
    done = False
    step = 0
    total_reward = 0
    while not done:
        if render:
            environment.render()

        action = agent.act(state, training=False, epsilon=epsilon)
        next_state, reward, done, _ = environment.step(action)

        state = next_state
        step += 1
        total_reward += reward

    agent.end_of_episode()

    return total_reward