diff --git a/cooperative_cuisine/configs/environment_config.yaml b/cooperative_cuisine/configs/environment_config.yaml index 249b0fd6a4b85f0d5c57397fd13ac86d09d5c844..25514c3bd6627f35df634e5836e9e617abc47f34 100644 --- a/cooperative_cuisine/configs/environment_config.yaml +++ b/cooperative_cuisine/configs/environment_config.yaml @@ -13,6 +13,7 @@ game: layout_chars: _: Free hash: Counter # # + equal: EdgeCounter # = A: Agent pipe: Extinguisher P: PlateDispenser diff --git a/cooperative_cuisine/configs/item_info.yaml b/cooperative_cuisine/configs/item_info.yaml index 96ddf78c9ddb9800f1948f9e159cc2215784648c..f8a14b7f57adbe184f318892a2d236338c66b43e 100644 --- a/cooperative_cuisine/configs/item_info.yaml +++ b/cooperative_cuisine/configs/item_info.yaml @@ -172,6 +172,11 @@ FishAndChips: needs: [ FriedFish, Chips ] equipment: ~ +BurgerWithChips: + type: Meal + needs: [ Burger, Chips ] + equipment: ~ + Pizza: type: Meal needs: [ PizzaBase, ChoppedTomato, GratedCheese, ChoppedSausage ] diff --git a/cooperative_cuisine/configs/layouts/overcooked-1/1-1-far-apart.layout b/cooperative_cuisine/configs/layouts/overcooked-1/1-1-far-apart.layout index 1b0b160ca73b18a62526ab9d020b9a4394fd2c63..5cf16b3f7bfa3ca45e8afd87d3255a73d3e64da8 100644 --- a/cooperative_cuisine/configs/layouts/overcooked-1/1-1-far-apart.layout +++ b/cooperative_cuisine/configs/layouts/overcooked-1/1-1-far-apart.layout @@ -1,6 +1,6 @@ ###N#T##U#### #___________| -L___A___A___# +#___A___A___# #___________S ##########__+ P___________# diff --git a/cooperative_cuisine/configs/layouts/study_layouts/1-1-far-apart.layout b/cooperative_cuisine/configs/layouts/study_layouts/1-1-far-apart.layout new file mode 100644 index 0000000000000000000000000000000000000000..651db57d04b706517e12ee8dbabd509fe9dbe480 --- /dev/null +++ b/cooperative_cuisine/configs/layouts/study_layouts/1-1-far-apart.layout @@ -0,0 +1,14 @@ +=#N#T###U###= +#___________| +#___A_______# +#___________S +=#########__+ +P___________# +$_______A___# +$___________X +=##C#C###@@#= + +; seconds=150 +; plates={c:0, d:0} +; dirty_plates=true +; link: https://overcooked.fandom.com/wiki/1-1_(Overcooked!) \ No newline at end of file diff --git a/cooperative_cuisine/configs/layouts/study_layouts/1-4-bottleneck.layout b/cooperative_cuisine/configs/layouts/study_layouts/1-4-bottleneck.layout new file mode 100644 index 0000000000000000000000000000000000000000..60eb7af88bc47cc657b5d23e51556cad9a204fc0 --- /dev/null +++ b/cooperative_cuisine/configs/layouts/study_layouts/1-4-bottleneck.layout @@ -0,0 +1,14 @@ +=#S+#====C#C#= +T____#==#____| +M_A__####__A_# +B____________# +L____####____$ +#____#==#____$ +#____#==#____P +X____#==#____# +=QQ#U====#@@@= + +; seconds=240 +; plates={c:0, d:0} +; dirty_plates=true +; link: https://overcooked.fandom.com/wiki/1-4_(Overcooked!) \ No newline at end of file diff --git a/cooperative_cuisine/configs/layouts/study_layouts/1-5-circle.layout b/cooperative_cuisine/configs/layouts/study_layouts/1-5-circle.layout new file mode 100644 index 0000000000000000000000000000000000000000..995c7634b47696c65e5330cb94c9c7c326aa09c3 --- /dev/null +++ b/cooperative_cuisine/configs/layouts/study_layouts/1-5-circle.layout @@ -0,0 +1,14 @@ +====P$$#==== +=T#N____##|= +#_A________X +#_###S+###_# +#_#======#_# +#_#======#_# +#_####@@##_# +#________A_# +=#C#C###U#U= + +; seconds=240 +; plates={c:0, d:0} +; dirty_plates=true +; link: https://overcooked.fandom.com/wiki/1-5_(Overcooked!) \ No newline at end of file diff --git a/cooperative_cuisine/configs/layouts/study_layouts/forced-cooperation.layout b/cooperative_cuisine/configs/layouts/study_layouts/forced-cooperation.layout new file mode 100644 index 0000000000000000000000000000000000000000..39fdd1a4a754bd7bc7a076f438a4c2de9553145a --- /dev/null +++ b/cooperative_cuisine/configs/layouts/study_layouts/forced-cooperation.layout @@ -0,0 +1,9 @@ +=#C#C#####$$= +#___________# +#_A_________P +#_____##@#@#= +X_____#_____X +=###@##_____| +F_________A_# +Q___________K +=#+S###LT#MB= \ No newline at end of file diff --git a/cooperative_cuisine/configs/study/study_config.yaml b/cooperative_cuisine/configs/study/study_config.yaml index 366615b0ff03ef27506353190a43b7724a1c5c06..3796e7f2afd516cc2225980fb88d9167a47fe2f2 100644 --- a/cooperative_cuisine/configs/study/study_config.yaml +++ b/cooperative_cuisine/configs/study/study_config.yaml @@ -1,58 +1,134 @@ levels: - config_path: CONFIGS_DIR/environment_config.yaml - layout_path: LAYOUTS_DIR/overcooked-1/1-1-far-apart.layout + layout_path: LAYOUTS_DIR/study_layouts/1-1-far-apart.layout item_info_path: CONFIGS_DIR/item_info.yaml name: "Level 1" seed: 12345 config_overwrite: + player_config: + speed_units_per_seconds: 5 game: time_limit_seconds: 300 + validate_recipes: false plates: clean_plates: 0 dirty_plates: 0 - orders: - order_gen_kwargs: - order_duration_random_func: - kwargs: - a: 60 - b: 70 + return_dirty: true + orders: + meals: + all: false + list: + - TomatoSoup + - OnionSoup + order_gen_kwargs: + order_duration_random_func: + kwargs: + a: 60 + b: 70 + sample_on_dur_random_func: + func: uniform + kwargs: + a: 45 + b: 35 - config_path: CONFIGS_DIR/environment_config.yaml - layout_path: LAYOUTS_DIR/overcooked-1/1-4-bottleneck.layout + layout_path: LAYOUTS_DIR/study_layouts/1-4-bottleneck.layout item_info_path: CONFIGS_DIR/item_info.yaml name: "Level 2" seed: 12345 config_overwrite: + player_config: + speed_units_per_seconds: 5 game: time_limit_seconds: 300 + plates: + clean_plates: 1 + dirty_plates: 0 + return_dirty: true + orders: + meals: + all: false + list: + - Burger + - Salad + - TomatoSoup + order_gen_kwargs: + order_duration_random_func: + kwargs: + a: 60 + b: 70 + sample_on_dur_random_func: + func: uniform + kwargs: + a: 45 + b: 35 - config_path: CONFIGS_DIR/environment_config.yaml - layout_path: LAYOUTS_DIR/overcooked-1/1-5-circle.layout + layout_path: LAYOUTS_DIR/study_layouts/1-5-circle.layout item_info_path: CONFIGS_DIR/item_info.yaml name: "Level 3" seed: 12345 config_overwrite: + player_config: + speed_units_per_seconds: 5 game: time_limit_seconds: 300 + validate_recipes: true plates: clean_plates: 1 dirty_plates: 0 - return_dirty: false + return_dirty: true + orders: + meals: + all: false + list: + - TomatoSoup + - OnionSoup + order_gen_kwargs: + order_duration_random_func: + kwargs: + a: 60 + b: 70 + sample_on_dur_random_func: + func: uniform + kwargs: + a: 45 + b: 35 + - config_path: CONFIGS_DIR/environment_config.yaml - layout_path: LAYOUTS_DIR/overcooked-1/4-1-moving-counters.layout + layout_path: LAYOUTS_DIR/study_layouts/forced-cooperation.layout item_info_path: CONFIGS_DIR/item_info.yaml name: "Level 4" seed: 12345 config_overwrite: + player_config: + speed_units_per_seconds: 300 game: - time_limit_seconds: 300 + time_limit_seconds: 10 plates: clean_plates: 0 dirty_plates: 0 - - + return_dirty: true + orders: + meals: + all: false + list: + - Burger + - Salad + - Chips + - BurgerWithChips + order_gen_kwargs: + order_duration_random_func: + kwargs: + a: 60 + b: 70 + sample_on_dur_random_func: + func: uniform + kwargs: + a: 40 + b: 50 num_players: 1 num_bots: 0 diff --git a/cooperative_cuisine/counters.py b/cooperative_cuisine/counters.py index 97dd339359c6887ffad601782084813cae5eaefe..eb39a753b95e938c077def8ebd36697bcef37eac 100644 --- a/cooperative_cuisine/counters.py +++ b/cooperative_cuisine/counters.py @@ -333,6 +333,10 @@ class Counter: } +class EdgeCounter(Counter): + ... + + class CuttingBoard(Counter): """Cutting ingredients on. The requirement in a new object could look like. diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py index 8d3b49c5638436aab0d7f9f625680eebe8a96fe6..b46340e0cb1c02d8b13520b9a524ce2583af9723 100644 --- a/cooperative_cuisine/pygame_2d_vis/gui.py +++ b/cooperative_cuisine/pygame_2d_vis/gui.py @@ -1546,7 +1546,7 @@ class PyGameGUI: "translations.level_name", text_kwargs={"level": self.level_info["name"]} ) - graph_width = self.window_width * 0.55 + graph_width = self.window_width * 0.6 rows = 0 for rg in self.level_info["recipe_graphs"]: rows += len(np.unique(np.array(list(rg["layout"].values()))[:, 1])) @@ -2128,8 +2128,7 @@ class PyGameGUI: if event.type == pygame.JOYDEVICEREMOVED: self.remove_joystick(event) - # Press enter key or controller start button instead of mouse button press - if ( + if self.visualization_config["Gui"]["press_button_to_continue"] and ( event.type == pygame.JOYBUTTONDOWN and any([joy.get_button(7) for joy in self.joysticks.values()]) or (event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN) diff --git a/cooperative_cuisine/pygame_2d_vis/images/wall.png b/cooperative_cuisine/pygame_2d_vis/images/wall.png new file mode 100644 index 0000000000000000000000000000000000000000..9a7173aebc63094bae6d1618f48d6d188974dff8 Binary files /dev/null and b/cooperative_cuisine/pygame_2d_vis/images/wall.png differ diff --git a/cooperative_cuisine/pygame_2d_vis/locales/translations.de.json b/cooperative_cuisine/pygame_2d_vis/locales/translations.de.json index 6e3098c96adcec81e6481b04d31062f8a9922539..47579ce8519b642e48e78611225d37e7e037fdfd 100644 --- a/cooperative_cuisine/pygame_2d_vis/locales/translations.de.json +++ b/cooperative_cuisine/pygame_2d_vis/locales/translations.de.json @@ -34,6 +34,7 @@ "Fish And Chips": "Fish and Chips:", "Chips": "Pommes", "Salad": "Salat:", - "Fried Fish": "Backfisch:" + "Fried Fish": "Backfisch:", + "Burger With Chips": "Burger mit Pommes:" } } \ No newline at end of file diff --git a/cooperative_cuisine/pygame_2d_vis/locales/translations.en.json b/cooperative_cuisine/pygame_2d_vis/locales/translations.en.json index b2674d78e5abe8373c93eb914b124ccac798e596..9f9c558bf762d3db59f73aacd127e71d19491853 100644 --- a/cooperative_cuisine/pygame_2d_vis/locales/translations.en.json +++ b/cooperative_cuisine/pygame_2d_vis/locales/translations.en.json @@ -34,6 +34,7 @@ "Fish And Chips": "Fish and Chips:", "Chips": "Chips", "Salad": "Salad:", - "Fried Fish": "Fried Fish:" + "Fried Fish": "Fried Fish:", + "Burger With Chips": "Burger with Chips:" } } \ No newline at end of file diff --git a/cooperative_cuisine/pygame_2d_vis/visualization.yaml b/cooperative_cuisine/pygame_2d_vis/visualization.yaml index 6cccb65b0358f4d6d6191ada7e67340ff0bb8e7b..9b2dcffe094b750fa66085196ec715fd9d1a5530 100644 --- a/cooperative_cuisine/pygame_2d_vis/visualization.yaml +++ b/cooperative_cuisine/pygame_2d_vis/visualization.yaml @@ -5,6 +5,7 @@ Gui: use_player_cook_sprites: True show_interaction_range: False show_counter_centers: False + press_button_to_continue: False GameWindow: screen_margin_proportion: 0.15 @@ -35,6 +36,16 @@ Counter: path: images/counter5.png size: 1 +EdgeCounter: + parts: + # - type: rect + # height: 1 + # width: 1 + # color: whitesmoke + - type: image + path: images/wall.png + size: 1 + CuttingBoard: parts: - type: image @@ -44,11 +55,10 @@ CuttingBoard: PlateDispenser: - parts: [ ] -# - type: rect -# height: 0.95 -# width: 0.95 -# color: cadetblue1 + parts: + - type: image + path: images/plate_dispenser.png + size: 1 Trashcan: parts: @@ -113,11 +123,11 @@ ServingWindow: size: 0.8 center_offset: [ 0, -0.02 ] rotate_image: False - - type: image - path: images/bell_gold.png - size: 0.5 - center_offset: [ -0.2, -0.05 ] - rotate_image: False +# - type: image +# path: images/bell_gold.png +# size: 0.5 +# center_offset: [ -0.2, -0.05 ] +# rotate_image: False Stove: parts: @@ -376,6 +386,18 @@ FishAndChips: size: 0.8 center_offset: [ +0.2, 0 ] +BurgerWithChips: + parts: + - type: image + path: images/fries2.png + size: 0.8 + center_offset: [ -0.1, 0 ] + - type: image + path: images/burger.png + size: 0.8 + center_offset: [ +0.2, 0 ] + + Dough: parts: - type: image diff --git a/cooperative_cuisine/validation.py b/cooperative_cuisine/validation.py index e6b615cb68126dcf457f5a7f5d6d534427bef75c..cea549750ef51f2cbfc6b323cd8a3c6d14fb3eca 100644 --- a/cooperative_cuisine/validation.py +++ b/cooperative_cuisine/validation.py @@ -2,6 +2,7 @@ import hashlib import json import os +import uuid import warnings from typing import TypedDict, Tuple, Iterator, Set @@ -144,18 +145,19 @@ class Validation: graph.add_edge(need, current) elif len(current_info.needs) > 1: - for idx, item_name in enumerate(current_info.needs): - add_queue.append(f"{item_name}_{idx}") + for item_name in current_info.needs: + unique_id = uuid.uuid4().hex + add_queue.append(f"{item_name}_{unique_id}") if current_info.equipment and current_info.equipment.equipment: equip_id = f"{current_info.equipment.name}_{current_index}" equip_equip_id = f"{current_info.equipment.equipment.name}_{current_index}" graph.add_edge(equip_equip_id, current) graph.add_edge(equip_id, equip_equip_id) - graph.add_edge(f"{item_name}_{idx}", equip_id) + graph.add_edge(f"{item_name}_{unique_id}", equip_id) else: graph.add_edge( - f"{item_name}_{idx}", + f"{item_name}_{unique_id}", current, )