def evaluate_agent(agent, env):
    """Agent training function

    Args:
        agent: agent to train
        env: environment to interact with

    Returns:
        score (float): total score of episode
    """
    brain_name = env.brain_names[0]
    # reset the environment
    env_info = env.reset(train_mode=True)[brain_name]
    # get the current state
    state = env_info.vector_observations[0]
    # initialize the score
    score = 0
    while True:
        action = agent.act(state)

        # Perform action in the environment
        env_info = env.step(action)[brain_name]
        # Get next state, reward and completion boolean
        next_state = env_info.vector_observations[0]
        reward = env_info.rewards[0]
        done = env_info.local_done[0]
        # Update overall score
        score += reward
        state = next_state
        if done:
            break

    return score