Giter VIP home page Giter VIP logo

Comments (3)

Aequatio-Space avatar Aequatio-Space commented on June 10, 2024

You can use an example from marllib/envs/base_env to check how a custom environment is wrapped for RLlib. I write my own environment according to such example.

class RLlibMPE(MultiAgentEnv):
def __init__(self, env_config):
map = env_config["map_name"]
env_config.pop("map_name", None)
env = REGISTRY[map](**env_config)
# keep obs and action dim same across agents
# pad_action_space_v0 will auto mask the padding actions
env = ss.pad_observations_v0(env)
env = ss.pad_action_space_v0(env)
self.env = ParallelPettingZooEnv(env)
self.action_space = self.env.action_space
self.observation_space = GymDict({"obs": Box(
low=-100.0,
high=100.0,
shape=(self.env.observation_space.shape[0],),
dtype=self.env.observation_space.dtype)})
self.agents = self.env.agents
self.num_agents = len(self.agents)
env_config["map_name"] = map
self.env_config = env_config
def reset(self):
original_obs = self.env.reset()
obs = {}
for i in self.agents:
obs[i] = {"obs": original_obs[i]}
return obs
def step(self, action_dict):
o, r, d, info = self.env.step(action_dict)
rewards = {}
obs = {}
for key in action_dict.keys():
rewards[key] = r[key]
obs[key] = {
"obs": o[key]
}
dones = {"__all__": d["__all__"]}
return obs, rewards, dones, info
def close(self):
self.env.close()
def render(self, mode=None):
self.env.render()
time.sleep(0.05)
return True
def get_env_info(self):
env_info = {
"space_obs": self.observation_space,
"space_act": self.action_space,
"num_agents": self.num_agents,
"episode_limit": 25,
"policy_mapping_info": policy_mapping_dict
}
return env_info

from marllib.

ChenJiangxi avatar ChenJiangxi commented on June 10, 2024

I'm having the same problem, and I think the key to customizing your environment is in this statement:
self.env = ParallelPettingZooEnv(env)
But I don't really know how to access my own simulation environment

from marllib.

Theohhhu avatar Theohhhu commented on June 10, 2024

Thank you to @Aequatio-Space for offering guidance. MARLlib utilizes a standard agent-environment interface based on RLlib. A practical approach to integrating your own environment is to begin by identifying a similar environment (e.g., with the same data structure or interaction style) and then follow the integration approach used for that environment.

from marllib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.