def loop(env, agent, training=False):
    """
    Basic training loop; given an environment, calls Agent.act() until the 
    game is finished.
    """
    reward = 0
    done = False
    score = 0
    special_data = {}
    special_data['ale.lives'] = 3
    ob = env.reset()
    while not done:
        
        action = agent.act(ob, reward, done, training=training)
        ob, reward, done, _ = env.step(action)
        score += reward
        # env.render()
     
    # Close the env and write monitor result info to disk
    # print ("Your score: %d" % score)
    return score