Link a Simulator to FLARE

To link a simulator/environment to FLARE, the user needs to derive from the base class Env in <flare_root>/flare/framework/env.py and implement a standard set of five functions:

@abstractmethod
def reset(self):
    """
    Reset the environment and return a dictionary of initial observations
    """
    pass

@abstractmethod
def step(self, actions, actrep):
    """
    Given a dictionary of actions, forward the environment actrep step.
    The output should be a dictionary of next observations, a dictionary of
    reward vectors (each vector for a kind), and next_game_over which only has
    three possible values: 0 alive, 1 success, -1 failure/dead
    """
    pass

@abstractmethod
def observation_dims(self):
    """
    Return a dictionary of tuples as observation dimensions, each tuple for one
    observation.
    Each tuple contains the dimension numbers of that input.
    """
    pass

@abstractmethod
def action_dims(self):
    """
    Return a dictionary of integers as action dimensions, each integer for an
    action. For each integer, if the corresponding action is discrete,
    then it means the total number of actions;
    if continous, then it means the length of the action vector.
    if language, then it means the cardinality of the dictionary
    """
    pass

@abstractmethod
def time_out(self):
    """
    Return a boolean of whether the env has timed out
    """
    pass

The comments above are already clear about what to be expected for the outputs of each of the five functions. A few example environments can be found in <flare_root>/flare/env_zoo. Some explanations:

NOTE: The keys defined in various Model specs should match the keys of the input/output dictionaries of the above five functions.

We have linked three environments (GymEnv, GymEnvImage, and XWorldEnv) to FLARE for the user in <flare_root>/flare/env_zoo.