def run_HAC(FLAGS, env, agent):
    print_summary(FLAGS, env)
    mix_train_test = False
    if ((not FLAGS.test) and (not FLAGS.train_only)):
        mix_train_test = True
    for batch in range(NUM_BATCH):
        num_episodes = agent.other_params['num_exploration_episodes']
        if (mix_train_test and ((batch % TEST_FREQ) == 0)):
            print('\n--- TESTING ---')
            agent.FLAGS.test = True
            num_episodes = num_test_episodes
            successful_episodes = 0
        for episode in range(num_episodes):
            print(('\nBatch %d, Episode %d' % (batch, episode)))
            success = agent.train(env, episode)
            if success:
                print(('Batch %d, Episode %d End Goal Achieved\n' % (batch, episode)))
                if (mix_train_test and ((batch % TEST_FREQ) == 0)):
                    successful_episodes += 1
        agent.save_model(episode)
        if (mix_train_test and ((batch % TEST_FREQ) == 0)):
            success_rate = ((successful_episodes / num_test_episodes) * 100)
            print(('\nTesting Success Rate %.2f%%' % success_rate))
            agent.log_performance(success_rate)
            agent.FLAGS.test = False
            print('\n--- END TESTING ---\n')
def run_HAC(FLAGS, env, agent):
    print_summary(FLAGS, env)
    mix_train_test = False
    if ((not FLAGS.test) and (not FLAGS.train_only)):
        mix_train_test = True
    for batch in range(NUM_BATCH):
        num_episodes = agent.other_params['num_exploration_episodes']
        if (mix_train_test and ((batch % TEST_FREQ) == 0)):
            print('\n--- TESTING ---')
            agent.FLAGS.test = True
            num_episodes = num_test_episodes
            successful_episodes = 0
        for episode in range(num_episodes):
            print(('\nBatch %d, Episode %d' % (batch, episode)))
            success = agent.train(env, episode)
            if success:
                print(('Batch %d, Episode %d End Goal Achieved\n' % (batch, episode)))
                if (mix_train_test and ((batch % TEST_FREQ) == 0)):
                    successful_episodes += 1
        agent.save_model(episode)
        if (mix_train_test and ((batch % TEST_FREQ) == 0)):
            success_rate = ((successful_episodes / num_test_episodes) * 100)
            print(('\nTesting Success Rate %.2f%%' % success_rate))
            agent.log_performance(success_rate)
            agent.FLAGS.test = False
            print('\n--- END TESTING ---\n')