Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart AgentBasedSimulation #72

Closed
rusu24edward opened this issue Apr 7, 2021 · 1 comment · Fixed by #418
Closed

Smart AgentBasedSimulation #72

rusu24edward opened this issue Apr 7, 2021 · 1 comment · Fixed by #418
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rusu24edward
Copy link
Collaborator

rusu24edward commented Apr 7, 2021

The environments we design are completely based what we include in the init, namely which components to use. We should make a smart super class that can fill out the rest of the functions, like reset, step, get_obs, etc. based on what we create in the init and some order that we specify for step.

Furthermore, we shouldn't have to make a separate simulation just because a different component is used. So we should think of ways to support varying the components without the user having to redefine the simulation.

Depends on #58

@rusu24edward
Copy link
Collaborator Author

rusu24edward commented Jul 12, 2023

For built-in components, we can create a component registry in the GWSF that maps a component's name to itself. Then we can support a builder that takes component names as input and builds out the simulation from there. A rough idea of the code might look something like this:

class GridWorldSimulation(ABS):
    ...
    @class_method
    def build_from_built_in_components(self, states=None, actors=None, observers=None, dones=None, **kwargs):
        if states is not None:
            assert type(states) is set
            for state in states:
                assert type(state) is str
                assert state in GridWorldSimluation.component_registry
                assert issubclass(GridWorldSimluation.component_registry[state], StateBaseComponent)
            self.states = {
                state: GridWorldSimulation.component_registry[state](**kwargs)
                for state in states
            }

        if actors is not None:
            assert type(actors) is set
            for actor in actors:
                assert type(actor) is str
                assert actor in GridWorldSimluation.component_registry
                assert issubclass(GridWorldSimluation.component_registry[actor], ActorBaseComponent)
            self.actors = {
                actor: GridWorldSimulation.component_registry[actor](**kwargs)
                for actor in actors
            }
        ...

Then the user can just supply component names instead of having to redefine a new simulation entirely.

Outstanding questions:

  1. Users can create their own components, can they add them to the GWSF registry? --> Users can register their components
  2. Component wrappers? --> Smart GridWorld Sim takes component wrappers #420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant