# Path: utils/phis.py
# def CartPole0phi1(obs, done=False):
# def CartPole0phi2(obs, done=False):
# def MountainCar0phi(obs, done=False):
# def Acrobot1phi(obs, done=False):
# def getPhiConfig(env_name, debug=False):


import json, os
import tensorflow as tf
from gym.spaces import Discrete, Box
from utils import phis
    @staticmethod
    def get_random_config(fixed_params={}):
        raise Exception('The get_random_config function must be overrided by the agent')

    def build_graph(self, graph):
        raise Exception('The build_graph function must be overrided by the agent')

    def act(self, obs, eps=None):
        raise Exception('The act function must be overrided by the agent')

    def learn_from_episode(self, env):
        raise Exception('The learn_from_episode function must be overrided by the agent')

    def train(self, render=False, save_every=49):
        for episode_id in range(0, self.max_iter):
            self.learn_from_episode(self.env, render)

            if save_every > 0 and episode_id % save_every == 0:
                self.save()

    def save(self):
        global_step_t = tf.train.get_global_step(self.graph)
        global_step, episode_id = self.sess.run([global_step_t, self.episode_id])
        if self.config['debug']:
            print('Saving to %s with global_step %d' % (self.result_dir, global_step))
        self.saver.save(self.sess, self.result_dir + '/agent-ep_' + str(episode_id), global_step)

        if not os.path.isfile(self.result_dir + '/config.json'):
            config = self.config
            if 'phi' in config:

# Path: utils/phis.py
# def CartPole0phi1(obs, done=False):
# def CartPole0phi2(obs, done=False):
# def MountainCar0phi(obs, done=False):
# def Acrobot1phi(obs, done=False):
# def getPhiConfig(env_name, debug=False):


# Path: agents/basic_agent.py
import json, os
import tensorflow as tf
from gym.spaces import Discrete, Box
from utils import phis

    @staticmethod
    def get_random_config(fixed_params={}):
        raise Exception('The get_random_config function must be overrided by the agent')

    def build_graph(self, graph):
        raise Exception('The build_graph function must be overrided by the agent')

    def act(self, obs, eps=None):
        raise Exception('The act function must be overrided by the agent')

    def learn_from_episode(self, env):
        raise Exception('The learn_from_episode function must be overrided by the agent')

    def train(self, render=False, save_every=49):
        for episode_id in range(0, self.max_iter):
            self.learn_from_episode(self.env, render)

            if save_every > 0 and episode_id % save_every == 0:
                self.save()

    def save(self):
        global_step_t = tf.train.get_global_step(self.graph)
        global_step, episode_id = self.sess.run([global_step_t, self.episode_id])
        if self.config['debug']:
            print('Saving to %s with global_step %d' % (self.result_dir, global_step))
        self.saver.save(self.sess, self.result_dir + '/agent-ep_' + str(episode_id), global_step)

        if not os.path.isfile(self.result_dir + '/config.json'):
            config = self.config
            if 'phi' in config:

                del config['phi']