GithubHelp home page GithubHelp logo

Custom Environment about marllib HOT 3 CLOSED

replicable-marl avatar replicable-marl commented on May 14, 2024
Custom Environment

from marllib.

Comments (3)

Morphlng avatar Morphlng commented on May 14, 2024 2

I've run into the same problem and now I'm halfway through. It is possible to introduce a custom environment by doing the following steps:

  1. You have to manually wrap your gym-like environment with MultiAgentEnv. You can refer to any other existing env under path envs/base_env/xxx.py. Aside from the standard reset, step, close method, you have to implement a method called get_env_info to return information like obs_space, action_space, etc. Also, the env class needs to include two member self.num_agents and self.agents. A global policy_mapping_dict should also be created and exposed, this will affect how Ray manage all those policies.

  2. You have to define a default env config file under envs/base_env/config, it should be something like:

    env: your_env
    
    env_args:
      map_name: "default" #  other options
      any_other_config_needed_by_your_env: ...
    
    mask_flag: True
    global_state_flag: True
    opp_action_in_cc: False
  3. Register your env in envs/base_env/__init__.py:

    try:
        from envs.base_env.your_env import CustomEnv
        ENV_REGISTRY["your_env"] = CustomEnv
    except Exception as e:
        ENV_REGISTRY["your_env"] = str(e)
  4. [Optional] You can customize algorithm configuration that fit your environment by putting it under marl/algos/hyperparams/finetuned/your_env

  5. Run your custom env by python marl/main.py --algo_config=mappo [--finetuned] --env_config=your_env [with env_args.map_name=custom]

By doing these steps above, I've successfully registered a Carla Environment to MARLlib. However, I said I was halfway through because the training is no good. I can't find a document explaining the exact meaning of "state", "obs" in observation space, and all the other configurations. It would be great to have complete documentation about customization.

from marllib.

Theohhhu avatar Theohhhu commented on May 14, 2024

Guys, have a quick glance of our new api design and instance of customize new environments.

from marllib.

luzgui avatar luzgui commented on May 14, 2024

Thank you very much!

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.