Giter Club home page Giter Club logo

cooking_zoo's Introduction

Code for CookingZoo

Contents:

Introduction

CookingZoo is a derived work and reuse part of the visual assets. It is a flexible cooking environment with a lot of different cooking tools and ingredients to test generalization abilities. It offers multi-agent support with the PettingZoo library and the gymnasium library. Furthermore, one agent may be controlled by a human.

The advantages of using this environment are listed below:

- Extensive Library of existing recipes and room with extensibility to add more
- Different Observation spaces (Feature Vector, symbolic)
- Customizable Level design
- Observation spaces can be same size for different levels with fixed object location
- Variable number of agents
- Cover Competing, Collaborating and Coexisting Environments
- Multi-agent support with PettingZoo and gymnasium latest versions
- Human controllable agent

Please cite this paper when using this environment using bibtex:

@inproceedings{rother2023disentangling,
  title={Disentangling Interaction using MaximumEntropy Reinforcement Learning in Multi-Agent Systems},
  author={Rother, David and Weisswange, Thomas and Peters, Jan},
  booktitle={European Conference on Artificial Intelligence},
  year={2023}
}

You can use this bibtex if you would like to cite the original paper this work is derived from (Wu and Wang et al., 2021):

@article{wu_wang2021too,
  author = {Wu, Sarah A. and Wang, Rose E. and Evans, James A. and Tenenbaum, Joshua B. and Parkes, David C. and Kleiman-Weiner, Max},
  title = {Too many cooks: Coordinating multi-agent collaboration through inverse planning},
  journal = {Topics in Cognitive Science},
  year = {2021},
  volume = {n/a},
  number = {n/a},
  keywords = {Coordination, Social learning, Inverse planning, Bayesian inference, Multi-agent reinforcement learning},
  doi = {https://doi.org/10.1111/tops.12525},
  url = {https://onlinelibrary.wiley.com/doi/abs/10.1111/tops.12525},
}

Installation

git clone https://github.com/DavidRother/cooking_zoo.git
cd cooking_zoo
pip3 install -e .

The environment is compatible with python 3.7 and higher.

Usage

# Example Parameters for two agents
num_agents = 2
max_steps = 400
render = True
obs_spaces = ["feature_vector", "feature_vector"]
action_scheme = "scheme3"
meta_file = "example"
level = "coop_test"
recipes = ["TomatoLettuceSalad", "CarrotBanana"]
end_condition_all_dishes = True
agent_visualization = ["human", "robot"]
reward_scheme = {"recipe_reward": 20, "max_time_penalty": -5, "recipe_penalty": -40, "recipe_node_reward": 0}


# Single Agent gym environment
env = gym.envs.make("cooking_zoo:cookingEnvMA-v1", level=level, meta_file=meta_file, num_agents=num_agents,
                    max_steps=max_steps, recipes=recipes, agent_visualization=agent_visualization,
                    obs_spaces=obs_spaces, end_condition_all_dishes=end_condition_all_dishes,
                    action_scheme=action_scheme, render=render, reward_scheme=reward_scheme)

# Multi Agent gym environment
env = gym.envs.make("cooking_zoo:cookingEnv-v1", level=level, meta_file=meta_file,
                    max_steps=max_steps, recipes=recipes, agent_visualization=agent_visualization,
                    obs_spaces=obs_spaces, end_condition_all_dishes=end_condition_all_dishes,
                    action_scheme=action_scheme, render=render, reward_scheme=reward_scheme)

# Multi Agent PettingZoo environment
env = parallel_env(level=level, meta_file=meta_file, num_agents=num_agents, max_steps=max_steps, recipes=recipes,
                   agent_visualization=agent_visualization, obs_spaces=obs_spaces,
                   end_condition_all_dishes=end_condition_all_dishes, action_scheme=action_scheme, render=render,
                   reward_scheme=reward_scheme)

The environment can be used as a gym environment and as a PettingZoo environment. PettingZoo is a multi-agent environment library and is compatible with big frameworks such as RLLib, StableBaselines3, PettingZoo, EPyMARL, MushroomRL, and others that support the gym single-agent interface, the gym multi-agent convention as found in EPyMARL or the more general PettingZoo interface.

Please note that we use the updated gym conventions of version 0.26.1 and upwards, where done is replaced with termination and truncation variables. During test a small wrapper was necessary with EPyMARL for compatibility reasons.

A single-agent usage example is shown in the main.py file. To get a playable demo in a single agent environment view the demo_gameplay.py file and for a playable multi-agent demo, where another agent is controlled by a random movement AI view the demo_multiplayer_gameplay.py file.

Observation Spaces

Feature Vector

a numpy vector containing a feature representation of all objects in the world

Symbolic

A copy of all objects in the world for reasoning purposes

Extending the environment

In this section it is described how to add additional objects and make changes to the code to fit the simulation to your needs.

Adding Objects

Look up the file world_objects.py in the folder cooking_world. In this file add a new class of your object and let it inherit from the desired classes in abstract_classes.py. To get specific implementation details you can look at another inherited objects.

Recipes

A recipe is a graph in this game. Everything related to recipes is found in the folder cooking_book. A recipe node describes a state in the world that is desired and is fulfilled when it is reached. More concrete a node takes as input an object type, the conditions for the attributes of that object and what should be on/in the object (if applicable). If an object of the correct object type then fulfills all specified conditions and holds all specified objects (described as nodes), then the node is considered done.

By chaining different nodes now in the contains section you get a graph that the game can check if it is fulfilled or not and hand out rewards for each node.

To add a new recipe add the node call the register_recipe function in the recipe_book.py file. If you want to add to the default recipe book directly add the recipe in the files.

cooking_zoo's People

Contributors

davidrother avatar rosewang2008 avatar sarahawu avatar

Stargazers

 avatar Pablo Iyu Guerrero avatar takumi nishimura avatar  avatar Xin Lin avatar Chen Sun avatar  avatar Hao Ding avatar  avatar Jiaxun Cui avatar Shao ZHANG avatar Ziyan Wang avatar Graham Waters avatar David Slayback avatar Minglu Lucy Zhao avatar  avatar Rujikorn Charakorn avatar Tobias Niehues avatar

cooking_zoo's Issues

language input

gui interface to enter language during demonstration.
for example, the text in the input field (after pressing enter or something) is active until a new sentence is entered, and the currently active sentence is added to the observation for that step.

uniform descpritions

general unified descriptions would be very helpful, like

  • all tools should have contents attribute (every tool can only be used if a food is placed on/in it), important
  • even more general, every entity that can have something on in should have this field, like counter has tools on it etc.

this would create a uniform world description that is much easier to use.

Questions about development progress and plans

Hi there, I'm a research student in the field of multi-agent systems, and I'm fascinated by this amazing environment and keen to track your progress. It appears that you have been actively updating this repository lately, which presents a slight challenge for me to seamlessly integrate it into my own codebase. I was wondering if there is a development plan or any specific goals you have set for this project recently?

new foods and tools

adding new entities:

  • bread (can be cut into pieces, pieces can be toasted, meaning temperature gets hot, color darker, and crisper)

  • spaghetti (can be cooked with pot, or heated with microwave, temperature and status changes)

  • pot (to cook spaghetti, changes temperature and status)

  • toaster (to toast bread, changes temperature, status, color, softness)

  • microwave (to heat food)

  • oven (to heat food)

details to be discussed.

last observation

it seems like there's no 'last observation', meaning there are equally many observations and actions.
but for a (s,a,s') like structure, there needs to be +1 state/observation, and generally, the last observation should be the state of the world AFTER an/the last action.

Remove constraints that only desired actions are possible

Actions should not be constrained by the semantic sense. For example i should be able to put eggs on a cutting board even if the action to cut an egg does not make sense. Or one is able to merge ingredients that do not lead to any valid recipe.

Adding Objects

The following objects should be added to the game:

Watertap, Toaster, Bread, Oven, Pot, Egg, Spaghetti, Microwave

unique ID

adding an unique ID to each object instance.

Question regarding adding new ingredients and recipes

I intend to extend this repo to have more ingredients and recipes. I see that the branch smile has added many ingredients already. So, I'm wondering if I can start using that branch directly or you plan to push a breaking change in that branch?

Ps. Have you tried training rl agents in this environment? Can they learn without any reward shaping?

pick_all and pick_x

feature for picking up all objects on the plate, i.e., the plate, or picking up individual objects from the plate.

Feature request: update PettingZoo version

Hi, would it be possible to update this repo to use the most recent version of PettingZoo? This project is listed in PettingZoo's third-party-environments, but we only want to include environments which work with the current version.

If you need any help working out issues due to different versions feel free to ask, there were some breaking changes in version 1.2, so it requires a bit of code changes to adapt. The previous API returned done in the step() function, whereas the new one returns truncated and terminated (matching gymnasium). There is a migration guide for gymnasium explaining the changes further, the steps should be basically the same (we're working on making resources for updating old PettingZoo repositories as well): https://gymnasium.farama.org/content/migration-guide/

Revamp Object Inheritance system

An object should be able to have multiple progression paths. For example a carrot might be able to be put into a blender and be cut
on a cutting board resulting in different procesed foods.

interaction object in agent

indicate the object the agent interacts with in the agent description, additional entry like 'interacts'. (list)

game play of demo_xxx always stucks when all recipes completed

When I run demo_gameplay.py in cooking_zoo/, and complete the recipe with manual policy, the program will stuck in the step of cooking_zoo\demo_gameplay.py:30:

observations, rewards, terminations, truncations, infos = env.step(action)

And I try to figure it out, it sames like the problem is in the pettingzoo's library, in Lib\site-packages\pettingzoo\utils\conversions.py:217-221:

        while self.aec_env.agents and (
            self.aec_env.terminations[self.aec_env.agent_selection]
            or self.aec_env.truncations[self.aec_env.agent_selection]
        ):
            self.aec_env.step(None)

So it will stuck in the while block.
I want to know is it working normally or is there any solution to this problem.

Observation dict

Output the symbolic representation of the environments, list/dict/set/.. of named entities with their properties.

Observation Selection

When creating an environment i want to be able to tell for every agent what its observation space is.

First one should select the wanted state representation: Symbolic (a list of objects) or feature planes or image pixels
Then one should be able to select the MDP representation (the whole environment is visible) or a POMDP representation
where one can select the view radius.

Revamp Merging object animation

To make merging of arbitrary objects possible, each object should just have a png for each of its states. Then if multiple dynamic objects are merged onto the same place/container instead of loading a new png of the merged object, the objects are shown in a smaller version inside the container. This system should work with any number of merging objects (although objects wont be recognizable at some point anymore)

Document Objects

All objects in the environment (Tools, Ingredients) should be documented and their affordances should be documented.
This makes it much easier to see, which generalizations between objects will be possible or where an object has a unique property.

Episode end

Adding a feature for manually ending an episode, to provide demonstrations of different lengths for example.

uniform action behavior

actions and objects behave differently.
e.g., I can pick up food from the blender by F, but not from the cutboard, there it gets cut.
should be different actions to pick/place objects or to use a tool for example. currently the blender can't be actively used for example.

control mode

new additional control mode, only walk in facing direction, turn left/right on spot

console / ASCII rendering

how difficult / time-consuming would it be to implement a pure console / ASCII rendering version of the game? no graphics, especially no openGL etc. ?

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.