diff --git a/cooperative_cuisine/configs/environment_config.yaml b/cooperative_cuisine/configs/environment_config.yaml index 8b27d42e5b5a6548ba9a89b5da2879cb51374a99..e63620d0843c21a7f77e0dbf92538a5acc0c1779 100644 --- a/cooperative_cuisine/configs/environment_config.yaml +++ b/cooperative_cuisine/configs/environment_config.yaml @@ -7,7 +7,7 @@ plates: game: time_limit_seconds: 300 undo_dispenser_pickup: true - validate_recipes: false + validate_recipes: true layout_chars: @@ -84,7 +84,7 @@ orders: player_config: radius: 0.4 - speed_units_per_seconds: 10 + speed_units_per_seconds: 6 interaction_range: 1.6 restricted_view: False view_angle: 70 diff --git a/cooperative_cuisine/configs/study/level1/level1_config.yaml b/cooperative_cuisine/configs/study/level1/level1_config.yaml deleted file mode 100644 index bbe47e5b5d9b1f2ea0dff9c1329e73a5362ad1ff..0000000000000000000000000000000000000000 --- a/cooperative_cuisine/configs/study/level1/level1_config.yaml +++ /dev/null @@ -1,202 +0,0 @@ -plates: - clean_plates: 2 - dirty_plates: 0 - plate_delay: [ 5, 10 ] - # range of seconds until the dirty plate arrives. - return_dirty: true - -game: - time_limit_seconds: 300 - undo_dispenser_pickup: true - validate_recipes: false - - -layout_chars: - _: Free - hash: Counter # # - A: Agent - pipe: Extinguisher - P: PlateDispenser - C: CuttingBoard - X: Trashcan - $: ServingWindow - S: Sink - +: SinkAddon - at: Plate # @ just a clean plate on a counter - U: Pot # with Stove - Q: Pan # with Stove - O: Peel # with Oven - F: Basket # with DeepFryer - T: Tomato - N: Onion # oNioN - L: Lettuce - K: Potato # Kartoffel - I: Fish # fIIIsh - D: Dough - E: Cheese # chEEEse - G: Sausage # sausaGe - B: Bun - M: Meat - question: Counter # ? mushroom - ↓: Counter - ^: Counter - right: Counter - left: Counter - wave: Free # ~ Water - minus: Free # - Ice - dquote: Counter # " wall/truck - p: Counter # second plate return ?? - - -orders: - - meals: - all: false - # if all: false -> only orders for these meals are generated - # TODO: what if this list is empty? - list: - - TomatoSoup - - Salad - order_gen_class: !!python/name:cooperative_cuisine.orders.RandomOrderGeneration '' - # the class to that receives the kwargs. Should be a child class of OrderGeneration in orders.py - order_gen_kwargs: - order_duration_random_func: - # 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: 2 - # number of orders generated at the start of the environment - sample_on_dur_random_func: - # 'random' library call with getattr, kwargs are passed to the function - func: uniform - kwargs: - a: 10 - b: 20 - sample_on_serving: false - # Sample the delay for the next order only after a meal was served. - serving_not_ordered_meals: true - # can meals that are not ordered be served / dropped on the serving window - -player_config: - radius: 0.4 - speed_units_per_seconds: 6 - interaction_range: 1.6 - restricted_view: False - view_angle: 70 - view_range: 4 # in grid units, can be "null" - -effect_manager: - FireManager: - class: !!python/name:cooperative_cuisine.effects.FireEffectManager '' - kwargs: - spreading_duration: [ 5, 10 ] - fire_burns_ingredients_and_meals: true - - -hook_callbacks: - # # --------------- Scoring --------------- - orders: - hooks: [ completed_order ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: 20 - score_on_specific_kwarg: meal_name - score_map: - Burger: 15 - OnionSoup: 10 - Salad: 5 - TomatoSoup: 10 - not_ordered_meals: - hooks: [ serve_not_ordered_meal ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: 2 - trashcan_usages: - hooks: [ trashcan_usage ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: -5 - expired_orders: - hooks: [ order_expired ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: -10 - # # --------------- Recording --------------- - # json_states: - # hooks: [ json_state ] - # callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - # callback_class_kwargs: - # record_path: USER_LOG_DIR/ENV_NAME/json_states.jsonl - - # Game event recording - game_events: - hooks: - - post_counter_pick_up - - post_counter_drop_off - - post_dispenser_pick_up - - cutting_board_100 - - player_start_interaction - - player_end_interact - - post_serving - - no_serving - - dirty_plate_arrives - - trashcan_usage - - plate_cleaned - - added_plate_to_sink - - drop_on_sink_addon - - pick_up_from_sink_addon - - serve_not_ordered_meal - - serve_without_plate - - completed_order - - new_orders - - order_expired - - action_on_not_reachable_counter - - new_fire - - fire_spreading - - drop_off_on_cooking_equipment - - players_collide - - post_plate_dispenser_pick_up - - post_plate_dispenser_drop_off - - on_item_transition - - progress_started - - progress_finished - - content_ready - - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - add_hook_ref: true - - actions: - hooks: [ pre_perform_action ] - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - random_env_events: - hooks: [ order_duration_sample, plate_out_of_kitchen_time ] - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - add_hook_ref: true - env_configs: - hooks: [ env_initialized, item_info_config ] - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - add_hook_ref: true -# info_msg: -# hooks: [ cutting_board_100 ] -# record_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager '' -# record_class_kwargs: -# msg: Glückwunsch du hast was geschnitten! -# fire_msg: -# hooks: [ new_fire ] -# record_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager '' -# record_class_kwargs: -# msg: Feuer, Feuer, Feuer -# level: Warning diff --git a/cooperative_cuisine/configs/study/level1/level1_item_info.yaml b/cooperative_cuisine/configs/study/level1/level1_item_info.yaml deleted file mode 100644 index 1266f61ebd611cd5c2a9097b1be9dd7eff65b7f7..0000000000000000000000000000000000000000 --- a/cooperative_cuisine/configs/study/level1/level1_item_info.yaml +++ /dev/null @@ -1,232 +0,0 @@ -CuttingBoard: - type: Equipment - -Sink: - type: Equipment - -Stove: - type: Equipment - -DeepFryer: - type: Equipment - -Oven: - type: Equipment - -Pot: - type: Equipment - equipment: Stove - -Pan: - type: Equipment - equipment: Stove - -Basket: - type: Equipment - equipment: DeepFryer - -Peel: - type: Equipment - equipment: Oven - -DirtyPlate: - type: Equipment - -Plate: - type: Equipment - needs: [ DirtyPlate ] - seconds: 2.0 - equipment: Sink - -# -------------------------------------------------------------------------------- - -Tomato: - type: Ingredient - -Lettuce: - type: Ingredient - -Onion: - type: Ingredient - -Meat: - type: Ingredient - -Bun: - type: Ingredient - -Potato: - type: Ingredient - -Fish: - type: Ingredient - -Dough: - type: Ingredient - -Cheese: - type: Ingredient - -Sausage: - type: Ingredient - -ChoppedTomato: - type: Ingredient - needs: [ Tomato ] - seconds: 4.0 - equipment: CuttingBoard - -ChoppedLettuce: - type: Ingredient - needs: [ Lettuce ] - seconds: 3.0 - equipment: CuttingBoard - -ChoppedOnion: - type: Ingredient - needs: [ Onion ] - seconds: 5.0 - equipment: CuttingBoard - -RawPatty: - type: Ingredient - needs: [ Meat ] - seconds: 4.0 - equipment: CuttingBoard - -RawChips: - type: Ingredient - needs: [ Potato ] - seconds: 4.0 - equipment: CuttingBoard - -ChoppedFish: - type: Ingredient - needs: [ Fish ] - seconds: 4.0 - equipment: CuttingBoard - -PizzaBase: - type: Ingredient - needs: [ Dough ] - seconds: 4.0 - equipment: CuttingBoard - -GratedCheese: - type: Ingredient - needs: [ Cheese ] - seconds: 4.0 - equipment: CuttingBoard - -ChoppedSausage: - type: Ingredient - needs: [ Sausage ] - seconds: 4.0 - equipment: CuttingBoard - -CookedPatty: - type: Ingredient - seconds: 5.0 - needs: [ RawPatty ] - equipment: Pan - -# -------------------------------------------------------------------------------- - -Chips: - type: Meal - seconds: 5.0 - needs: [ RawChips ] - equipment: Basket - -FriedFish: - type: Meal - seconds: 5.0 - needs: [ ChoppedFish ] - equipment: Basket - -Burger: - type: Meal - needs: [ Bun, ChoppedLettuce, ChoppedTomato, CookedPatty ] - equipment: ~ - -Salad: - type: Meal - needs: [ ChoppedLettuce, ChoppedTomato ] - equipment: ~ - -TomatoSoup: - type: Meal - needs: [ ChoppedTomato, ChoppedTomato, ChoppedTomato ] - seconds: 6.0 - equipment: Pot - -OnionSoup: - type: Meal - needs: [ ChoppedOnion, ChoppedOnion, ChoppedOnion ] - seconds: 6.0 - equipment: Pot - -FishAndChips: - type: Meal - needs: [ FriedFish, Chips ] - equipment: ~ - -Pizza: - type: Meal - needs: [ PizzaBase, ChoppedTomato, GratedCheese, ChoppedSausage ] - seconds: 7.0 - equipment: Peel - -# -------------------------------------------------------------------------------- - -BurntCookedPatty: - type: Waste - seconds: 5.0 - needs: [ CookedPatty ] - equipment: Pan - -BurntChips: - type: Waste - seconds: 5.0 - needs: [ Chips ] - equipment: Basket - -BurntFriedFish: - type: Waste - seconds: 5.0 - needs: [ FriedFish ] - equipment: Basket - -BurntTomatoSoup: - type: Waste - needs: [ TomatoSoup ] - seconds: 6.0 - equipment: Pot - -BurntOnionSoup: - type: Waste - needs: [ OnionSoup ] - seconds: 6.0 - equipment: Pot - -BurntPizza: - type: Waste - needs: [ Pizza ] - seconds: 7.0 - equipment: Peel - -# -------------------------------------------------------------------------------- - -Fire: - type: Effect - seconds: 5.0 - needs: [ BurntCookedPatty, BurntChips, BurntFriedFish, BurntTomatoSoup, BurntOnionSoup, BurntPizza ] - manager: FireManager - effect_type: Unusable - -# -------------------------------------------------------------------------------- - -Extinguisher: - type: Tool - seconds: 1.0 - needs: [ Fire ] diff --git a/cooperative_cuisine/configs/study/level2/level2_config.yaml b/cooperative_cuisine/configs/study/level2/level2_config.yaml deleted file mode 100644 index 273bbcdf13823e74a137eb3f8dc71d0b1fb0d6ba..0000000000000000000000000000000000000000 --- a/cooperative_cuisine/configs/study/level2/level2_config.yaml +++ /dev/null @@ -1,201 +0,0 @@ -plates: - clean_plates: 2 - dirty_plates: 0 - plate_delay: [ 5, 10 ] - # range of seconds until the dirty plate arrives. - -game: - time_limit_seconds: 300 - undo_dispenser_pickup: true - validate_recipes: false - - - -layout_chars: - _: Free - hash: Counter # # - A: Agent - pipe: Extinguisher - P: PlateDispenser - C: CuttingBoard - X: Trashcan - $: ServingWindow - S: Sink - +: SinkAddon - at: Plate # @ just a clean plate on a counter - U: Pot # with Stove - Q: Pan # with Stove - O: Peel # with Oven - F: Basket # with DeepFryer - T: Tomato - N: Onion # oNioN - L: Lettuce - K: Potato # Kartoffel - I: Fish # fIIIsh - D: Dough - E: Cheese # chEEEse - G: Sausage # sausaGe - B: Bun - M: Meat - question: Counter # ? mushroom - ↓: Counter - ^: Counter - right: Counter - left: Counter - wave: Free # ~ Water - minus: Free # - Ice - dquote: Counter # " wall/truck - p: Counter # second plate return ?? - - -orders: - - meals: - all: false - # if all: false -> only orders for these meals are generated - # TODO: what if this list is empty? - list: - - Pizza - order_gen_class: !!python/name:cooperative_cuisine.orders.RandomOrderGeneration '' - # the class to that receives the kwargs. Should be a child class of OrderGeneration in orders.py - order_gen_kwargs: - order_duration_random_func: - # 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: 2 - # number of orders generated at the start of the environment - sample_on_dur_random_func: - # 'random' library call with getattr, kwargs are passed to the function - func: uniform - kwargs: - a: 10 - b: 20 - sample_on_serving: false - # Sample the delay for the next order only after a meal was served. - serving_not_ordered_meals: true - # can meals that are not ordered be served / dropped on the serving window - -player_config: - radius: 0.4 - speed_units_per_seconds: 6 - interaction_range: 1.6 - restricted_view: True - view_angle: 100 - view_range: 3.2 # in grid units, can be "null" - -effect_manager: - FireManager: - class: !!python/name:cooperative_cuisine.effects.FireEffectManager '' - kwargs: - spreading_duration: [ 5, 10 ] - fire_burns_ingredients_and_meals: true - - -hook_callbacks: - # # --------------- Scoring --------------- - orders: - hooks: [ completed_order ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: 20 - score_on_specific_kwarg: meal_name - score_map: - Burger: 15 - OnionSoup: 10 - Salad: 5 - TomatoSoup: 10 - not_ordered_meals: - hooks: [ serve_not_ordered_meal ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: 2 - trashcan_usages: - hooks: [ trashcan_usage ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: -5 - expired_orders: - hooks: [ order_expired ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - static_score: -10 - # # --------------- Recording --------------- - # json_states: - # hooks: [ json_state ] - # callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - # callback_class_kwargs: - # record_path: USER_LOG_DIR/ENV_NAME/json_states.jsonl - actions: - hooks: [ pre_perform_action ] - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - random_env_events: - hooks: [ order_duration_sample, plate_out_of_kitchen_time ] - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - add_hook_ref: true - env_configs: - hooks: [ env_initialized, item_info_config ] - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - add_hook_ref: true - - # Game event recording - game_events: - hooks: - - post_counter_pick_up - - post_counter_drop_off - - post_dispenser_pick_up - - cutting_board_100 - - player_start_interaction - - player_end_interact - - post_serving - - no_serving - - dirty_plate_arrives - - trashcan_usage - - plate_cleaned - - added_plate_to_sink - - drop_on_sink_addon - - pick_up_from_sink_addon - - serve_not_ordered_meal - - serve_without_plate - - completed_order - - new_orders - - order_expired - - action_on_not_reachable_counter - - new_fire - - fire_spreading - - drop_off_on_cooking_equipment - - players_collide - - post_plate_dispenser_pick_up - - post_plate_dispenser_drop_off - - on_item_transition - - progress_started - - progress_finished - - content_ready - - callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder '' - callback_class_kwargs: - record_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl - add_hook_ref: true - -# info_msg: -# hooks: [ cutting_board_100 ] -# record_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager '' -# record_class_kwargs: -# msg: Glückwunsch du hast was geschnitten! -# fire_msg: -# hooks: [ new_fire ] -# record_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager '' -# record_class_kwargs: -# msg: Feuer, Feuer, Feuer -# level: Warning diff --git a/cooperative_cuisine/configs/study/level2/level2_item_info.yaml b/cooperative_cuisine/configs/study/level2/level2_item_info.yaml deleted file mode 100644 index c924241dcd60f6fb1d7ef79ebaf3462719eae491..0000000000000000000000000000000000000000 --- a/cooperative_cuisine/configs/study/level2/level2_item_info.yaml +++ /dev/null @@ -1,232 +0,0 @@ -CuttingBoard: - type: Equipment - -Sink: - type: Equipment - -Stove: - type: Equipment - -DeepFryer: - type: Equipment - -Oven: - type: Equipment - -Pot: - type: Equipment - equipment: Stove - -Pan: - type: Equipment - equipment: Stove - -Basket: - type: Equipment - equipment: DeepFryer - -Peel: - type: Equipment - equipment: Oven - -DirtyPlate: - type: Equipment - -Plate: - type: Equipment - needs: [ DirtyPlate ] - seconds: 2.0 - equipment: Sink - -# -------------------------------------------------------------------------------- - -Tomato: - type: Ingredient - -Lettuce: - type: Ingredient - -Onion: - type: Ingredient - -Meat: - type: Ingredient - -Bun: - type: Ingredient - -Potato: - type: Ingredient - -Fish: - type: Ingredient - -Dough: - type: Ingredient - -Cheese: - type: Ingredient - -Sausage: - type: Ingredient - -ChoppedTomato: - type: Ingredient - needs: [ Tomato ] - seconds: 3.0 - equipment: CuttingBoard - -ChoppedLettuce: - type: Ingredient - needs: [ Lettuce ] - seconds: 3.0 - equipment: CuttingBoard - -ChoppedOnion: - type: Ingredient - needs: [ Onion ] - seconds: 5.0 - equipment: CuttingBoard - -RawPatty: - type: Ingredient - needs: [ Meat ] - seconds: 4.0 - equipment: CuttingBoard - -RawChips: - type: Ingredient - needs: [ Potato ] - seconds: 4.0 - equipment: CuttingBoard - -ChoppedFish: - type: Ingredient - needs: [ Fish ] - seconds: 4.0 - equipment: CuttingBoard - -PizzaBase: - type: Ingredient - needs: [ Dough ] - seconds: 4.0 - equipment: CuttingBoard - -GratedCheese: - type: Ingredient - needs: [ Cheese ] - seconds: 4.0 - equipment: CuttingBoard - -ChoppedSausage: - type: Ingredient - needs: [ Sausage ] - seconds: 4.0 - equipment: CuttingBoard - -CookedPatty: - type: Ingredient - seconds: 5.0 - needs: [ RawPatty ] - equipment: Pan - -# -------------------------------------------------------------------------------- - -Chips: - type: Meal - seconds: 5.0 - needs: [ RawChips ] - equipment: Basket - -FriedFish: - type: Meal - seconds: 5.0 - needs: [ ChoppedFish ] - equipment: Basket - -Burger: - type: Meal - needs: [ Bun, ChoppedLettuce, ChoppedTomato, CookedPatty ] - equipment: ~ - -Salad: - type: Meal - needs: [ ChoppedLettuce, ChoppedTomato ] - equipment: ~ - -TomatoSoup: - type: Meal - needs: [ ChoppedTomato, ChoppedTomato, ChoppedTomato ] - seconds: 6.0 - equipment: Pot - -OnionSoup: - type: Meal - needs: [ ChoppedOnion, ChoppedOnion, ChoppedOnion ] - seconds: 6.0 - equipment: Pot - -FishAndChips: - type: Meal - needs: [ FriedFish, Chips ] - equipment: ~ - -Pizza: - type: Meal - needs: [ PizzaBase, ChoppedTomato, GratedCheese, ChoppedSausage ] - seconds: 7.0 - equipment: Peel - -# -------------------------------------------------------------------------------- - -BurntCookedPatty: - type: Waste - seconds: 5.0 - needs: [ CookedPatty ] - equipment: Pan - -BurntChips: - type: Waste - seconds: 5.0 - needs: [ Chips ] - equipment: Basket - -BurntFriedFish: - type: Waste - seconds: 5.0 - needs: [ FriedFish ] - equipment: Basket - -BurntTomatoSoup: - type: Waste - needs: [ TomatoSoup ] - seconds: 6.0 - equipment: Pot - -BurntOnionSoup: - type: Waste - needs: [ OnionSoup ] - seconds: 6.0 - equipment: Pot - -BurntPizza: - type: Waste - needs: [ Pizza ] - seconds: 7.0 - equipment: Peel - -# -------------------------------------------------------------------------------- - -Fire: - type: Effect - seconds: 5.0 - needs: [ BurntCookedPatty, BurntChips, BurntFriedFish, BurntTomatoSoup, BurntOnionSoup, BurntPizza ] - manager: FireManager - effect_type: Unusable - -# -------------------------------------------------------------------------------- - -Extinguisher: - type: Tool - seconds: 1.0 - needs: [ Fire ] diff --git a/cooperative_cuisine/configs/study/study_config.yaml b/cooperative_cuisine/configs/study/study_config.yaml index 28c420aa32e0b7b2228b7e16815dd77f3cf35633..9d5f34e80682c0dfba08b8b83849e150df05e6d8 100644 --- a/cooperative_cuisine/configs/study/study_config.yaml +++ b/cooperative_cuisine/configs/study/study_config.yaml @@ -1,18 +1,33 @@ levels: - - config_path: STUDY_DIR/level1/level1_config.yaml + - config_path: CONFIGS_DIR/environment_config.yaml layout_path: LAYOUTS_DIR/overcooked-1/1-1-far-apart.layout - item_info_path: STUDY_DIR/level1/level1_item_info.yaml + item_info_path: CONFIGS_DIR/item_info.yaml name: "Level 1-1: Far Apart" + config_overwrite: + game: + time_limit_seconds: 300 + plates: + clean_plates: 0 + dirty_plates: 0 - # - config_path: CONFIGS_DIR/environment_config.yaml - # layout_path: LAYOUTS_DIR/basic.layout - # item_info_path: CONFIGS_DIR/item_info.yaml - # name: "Basic" + - config_path: CONFIGS_DIR/environment_config.yaml + layout_path: LAYOUTS_DIR/basic.layout + item_info_path: CONFIGS_DIR/item_info.yaml + name: "Basic" + config_overwrite: + game: + time_limit_seconds: 300 - - config_path: STUDY_DIR/level2/level2_config.yaml + - config_path: CONFIGS_DIR/environment_config.yaml layout_path: LAYOUTS_DIR/overcooked-1/1-4-bottleneck.layout - item_info_path: STUDY_DIR/level2/level2_item_info.yaml + item_info_path: CONFIGS_DIR/item_info.yaml name: "Level 1-4: Bottleneck" + config_overwrite: + player_config: + restricted_view: true + plates: + clean_plates: 0 + dirty_plates: 0 num_players: 1 diff --git a/cooperative_cuisine/study_server.py b/cooperative_cuisine/study_server.py index fe69626bb9831a82314049d2265f230d690c77b6..501cfa4e99c66585bb1478c7cb36bf619ea50c3c 100644 --- a/cooperative_cuisine/study_server.py +++ b/cooperative_cuisine/study_server.py @@ -20,7 +20,7 @@ import signal import subprocess from pathlib import Path from subprocess import Popen -from typing import Tuple +from typing import Tuple, Any import requests import uvicorn @@ -37,6 +37,7 @@ from cooperative_cuisine.utils import ( add_list_of_manager_ids_arguments, expand_path, add_study_arguments, + deep_update, ) log = logging.getLogger(__name__) @@ -65,6 +66,8 @@ class LevelConfig(BaseModel): """Path to the layout file.""" item_info_path: str """Path to the item info file.""" + config_overwrite: dict[str, Any] | None = None + """Overwrite parts of the `environment_config`""" class LevelInfo(BaseModel): @@ -102,10 +105,10 @@ class Study: env_config_f = file.read() self.study_config: StudyConfig = yaml.load( - str(env_config_f), Loader=yaml.SafeLoader + str(env_config_f), Loader=yaml.Loader ) """Configuration for the study which layouts, env_configs and item infos are used for the study levels.""" - self.levels: list[LevelConfig] = self.study_config["levels"] + self.levels: list[dict] = self.study_config["levels"] """List of level configs for each of the levels which the study runs through.""" self.current_level_idx: int = 0 """Counter of which level is currently run in the config.""" @@ -159,12 +162,12 @@ class Study: ) return filled and not self.is_full - def create_env(self, level: LevelConfig) -> EnvironmentData: + def create_env(self, level: dict) -> EnvironmentData: """Creates/starts an environment on the game server, given the configuration file paths specified in the level. Args: - level: LevelConfig which contains the paths to the env config, layout and item info files. + level: dict with LevelConfig content which contains the paths to the env config, layout and item info files. Returns: EnvironmentData which contains information about the newly created environment. @@ -172,10 +175,10 @@ class Study: Raises: ValueError if the gameserver returned a conflict, HTTPError with 500 if the game server crashes. """ - - item_info_path = expand_path(level["item_info_path"]) - layout_path = expand_path(level["layout_path"]) - config_path = expand_path(level["config_path"]) + level = LevelConfig(**level) + item_info_path = expand_path(level.item_info_path) + layout_path = expand_path(level.layout_path) + config_path = expand_path(level.config_path) with open(item_info_path, "r") as file: item_info = file.read() @@ -183,9 +186,14 @@ class Study: layout = file.read() with open(config_path, "r") as file: environment_config = file.read() - self.current_config: EnvironmentConfig = yaml.load( - environment_config, Loader=yaml.Loader - ) + + self.current_config: EnvironmentConfig = yaml.load( + environment_config, Loader=yaml.Loader + ) + if level.config_overwrite is not None: + deep_update(self.current_config, level.config_overwrite) + environment_config = yaml.dump(self.current_config) + seed = int(random.random() * 1000000) creation_json = CreateEnvironmentConfig( manager_id=study_manager.server_manager_id, diff --git a/cooperative_cuisine/utils.py b/cooperative_cuisine/utils.py index 102c340a182bf99e1a32ba257f8a215e15d3be97..9314a01e29c0d7abb23c90323067280460f1057f 100644 --- a/cooperative_cuisine/utils.py +++ b/cooperative_cuisine/utils.py @@ -3,6 +3,7 @@ Some utility functions. """ from __future__ import annotations +import collections.abc import dataclasses import json import logging @@ -460,3 +461,12 @@ def create_layout_with_counters(w, h) -> str: string += "\n" print(string) return string + + +def deep_update(d, u): + for k, v in u.items(): + if isinstance(v, collections.abc.Mapping): + d[k] = deep_update(d.get(k, {}), v) + else: + d[k] = v + return d