import tensorflow as tf

# call proper policy and value estimators for each envs
for i in range(n_particles):
  if(ENV_NAME=="Pendulum-v0"):
    policy_estimator[i] = PolicyEstimator_Pendulum(entropy_beta=ENTROPY_BETA,learning_rate=POLICY_LR,par_idx=i)
    value_estimator[i] = ValueEstimator_Pendulum(learning_rate=VALUE_LR,par_idx=i)
  if(ENV_NAME=="MountainCarContinuous-v0"):
    policy_estimator[i] = PolicyEstimator_MountainCarContinuous(entropy_beta=ENTROPY_BETA,learning_rate=POLICY_LR,par_idx=i)
    value_estimator[i] = ValueEstimator_MountainCarContinuous(learning_rate=VALUE_LR,par_idx=i)

svpg=SVPG(policy_estimator,independent_flag_svpg,learning_rate=POLICY_LR);

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    # Note, due to randomness in the policy the number of episodes you need varies
    # TODO: Sometimes the algorithm gets stuck, I'm not sure what exactly is happening there.
    stats = advantage_actor_critic(env, policy_estimator, value_estimator, svpg, NUM_EPISODES, MAX_EPI_STEP,discount_factor=DISCOUNT_FACTOR)

