def __init__(self, game, paramOnly=False, nReps=1, record=False): """Initializes task environment Args: game - (string) - dict key of task to be solved (see domain/config.py) Optional: paramOnly - (bool) - only load parameters instead of launching task? nReps - (nReps) - number of trials to get average fitness """ # Network properties self.nInput = game.input_size self.nOutput = game.output_size self.actRange = game.h_act self.absWCap = game.weightCap self.layers = game.layers self.activations = np.r_[np.full(1, 1), game.i_act, game.o_act] # Environment self.nReps = nReps self.maxEpisodeLength = game.max_episode_length self.actSelect = game.actionSelect if not paramOnly: if record: env_to_wrap = make_env(game.env_name) self.env = Monitor(env_to_wrap, "trial_recording/", force=True) else: self.env = make_env(game.env_name) # Special needs... self.needsClosed = (game.env_name.startswith("CartPoleSwingUp"))
def __init__(self, game, encoder, max_features, paramOnly=False, nReps=1): """Initializes task environment Args: game - (string) - dict key of task to be solved (see domain/config.py) Optional: paramOnly - (bool) - only load parameters instead of launching task? nReps - (nReps) - number of trials to get average fitness """ # Network properties if encoder == 'ascii' or encoder == 'count': self.nInput = max_features i_act = np.full(max_features, 1) elif encoder == 'lstm': self.nInput = 4096 i_act = np.full(4096, 1) else: self.nInput = game.input_size i_act = game.i_act self.nOutput = game.output_size self.actRange = game.h_act self.absWCap = game.weightCap self.layers = game.layers self.activations = np.r_[np.full(1, 1), i_act, game.o_act] # Environment self.nReps = nReps self.maxEpisodeLength = game.max_episode_length self.actSelect = game.actionSelect if not paramOnly: self.env = make_env(game.env_name, encoder, max_features) # Special needs... self.needsClosed = (game.env_name.startswith("CartPoleSwingUp"))