From 1de15125597f17dc27665f1bf4feb77dbcbf029c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Schr=C3=B6der?= <fschroeder@techfak.uni-bielefeld.de> Date: Thu, 18 Jan 2024 16:27:37 +0100 Subject: [PATCH] configure the allowed meals via environment_config.yaml and some comments --- .../game_content/environment_config.yaml | 22 ++++++++++++++++++- .../overcooked_environment.py | 19 +++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/overcooked_simulator/game_content/environment_config.yaml b/overcooked_simulator/game_content/environment_config.yaml index d69f18f8..1109ae09 100644 --- a/overcooked_simulator/game_content/environment_config.yaml +++ b/overcooked_simulator/game_content/environment_config.yaml @@ -2,39 +2,59 @@ plates: clean_plates: 1 dirty_plates: 2 plate_delay: [ 5, 10 ] + # seconds until the dirty plate arrives. game: time_limit_seconds: 180 +meals: + all: false + # if all: false -> only orders for these meals are generated + list: + - TomatoSoup + - OnionSoup + - Salad + orders: kwargs: duration_sample: + # how long should the orders be alive + # 'random' library call with getattr, kwargs are passed to the function func: uniform kwargs: a: 40 b: 60 max_orders: 6 + # maximum number of active orders at the same time num_start_meals: 3 + # number of orders generated at the start of the environment sample_on_dur: true + # if true, the next order is generated based on the sample_on_dur_func method in seconds + # if sample_on_serving is also true, the value is sampled after a meal was served, otherwise it is sampled directly after an order generation. sample_on_dur_func: + # 'random' library call with getattr, kwargs are passed to the function func: uniform kwargs: a: 10 b: 20 sample_on_serving: false + # The sample time for a new incoming order is only generated after a meal was served. + score_calc_gen_func: !!python/name:overcooked_simulator.order.simple_score_calc_gen_func '' score_calc_gen_kwargs: + # the kwargs for the score_calc_gen_func other: 0 scores: Burger: 15 OnionSoup: 10 Salad: 5 TomatoSoup: 10 - score_calc_gen_func: !!python/name:overcooked_simulator.order.simple_score_calc_gen_func '' expired_penalty_func: !!python/name:overcooked_simulator.order.simple_expired_penalty '' expired_penalty_kwargs: default: -5 serving_not_ordered_meals: null + # a func that calcs a store for not ordered but served meals. Input: meal order_gen_class: !!python/name:overcooked_simulator.order.RandomOrderGeneration '' + # the class to that receives the kwargs. Should be a child class of OrderGeneration in order.py player_config: radius: 0.4 diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index a7dcc90d..3eaf84e1 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -70,12 +70,23 @@ class Environment: self.item_info_path: Path = item_info_path self.item_info = self.load_item_info() self.validate_item_info() + if self.environment_config["meals"]["all"]: + self.allowed_meal_names = set( + [ + item + for item, info in self.item_info.items() + if info.type == ItemType.Meal + ] + ) + else: + self.allowed_meal_names = set(self.environment_config["meals"]["list"]) + self.order_and_score = OrderAndScoreManager( order_config=self.environment_config["orders"], available_meals={ item: info for item, info in self.item_info.items() - if info.type == ItemType.Meal + if info.type == ItemType.Meal and item in self.allowed_meal_names }, ) plate_transitions = { @@ -103,11 +114,7 @@ class Environment: "W": lambda pos: ServingWindow( pos, self.order_and_score, - meals={ - item - for item, info in self.item_info.items() - if info.type == ItemType.Meal - }, + meals=self.allowed_meal_names, env_time_func=self.get_env_time, ), "T": lambda pos: Dispenser(pos, self.item_info["Tomato"]), -- GitLab