smearle / control-pcgrl Goto Github PK
View Code? Open in Web Editor NEWTrain or evolve controllable and diverse level-generators.
License: MIT License
Train or evolve controllable and diverse level-generators.
License: MIT License
When running train_pcgrl multiagent.n_agents=2
, the MultiAgentWrapper step method should execute without error.
When running train_pcgrl multiagent.n_agents=2
, the environment is wrapped in a MultiAgentWrapper. When calling the step function of the wrapper, we call the step method of the parent class.
def step(self, action):
obs, rew, done, info = {}, {}, {}, {}
for k, v in action.items():
self.unwrapped._rep.set_active_agent(k)
obs_k, rew[k], done[k], info[k] = super().step(action={k: v}). # THIS LINE HERE
obs.update(obs_k)
done['__all__'] = np.all(list(done.values()))
return obs, rew, done, info
The step method is expected to return the observations for a single agent, however, the parent's class observation space contains both agents. This raises the following exception:
AssertionError: The obs returned by the `step()` method observation keys is not same as the observation space keys, obs keys: ['agent_0'], space keys: ['agent_0', 'agent_1']
Ray 2.1.0
gym 0.26.2
This implementation of the MultiAgentWrapper calls the step method of the parent class. Instead, we could call the step method of the unwrapped class. Note that this is not the base environment, this would just be one layer deeper:
def step(self, action):
obs, rew, done, info = {}, {}, {}, {}
for k, v in action.items():
self.unwrapped._rep.set_active_agent(k)
obs_k, rew[k], done[k], info[k] = self.unwrapped.step(action={k: v}) ## CHANGED THIS LINE
obs.update(obs_k)
done['__all__'] = np.all(list(done.values()))
return obs, rew, done, info
Note that since the representation is also wrapped, we can still pass in a action dictionary to the environment.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.