diff --git a/cooperative_cuisine/configs/environment_config.yaml b/cooperative_cuisine/configs/environment_config.yaml index 6722182b0097e07a2884f8080e823df5f792d21d..5790dcc2b9bb20627a9697b54a3c1bfb3a230a97 100644 --- a/cooperative_cuisine/configs/environment_config.yaml +++ b/cooperative_cuisine/configs/environment_config.yaml @@ -48,6 +48,10 @@ layout_chars: exclamation: Lava # ! Lave dquote: Counter # " wall/truck p: Counter # second plate return ?? + exclamation: Lava # ! Lave + star: Target # * Target + dquote: Counter # " wall/truck + p: Counter # second plate return ?? orders: diff --git a/cooperative_cuisine/configs/environment_config_moonlander.yaml b/cooperative_cuisine/configs/environment_config_moonlander.yaml index e81e133eb2ffc81ce9e27b57bd6a7fac2c4e9fb3..cbaf40fd04494937a48787b85517af28e276c141 100644 --- a/cooperative_cuisine/configs/environment_config_moonlander.yaml +++ b/cooperative_cuisine/configs/environment_config_moonlander.yaml @@ -1,7 +1,7 @@ # you have to remove (put in comment) the assert in environment.py: assert meals_to_be_ordered, "Need possible meals for order generation." plates: - clean_plates: 2 - dirty_plates: 1 + clean_plates: 0 + dirty_plates: 0 plate_delay: [ 5, 10 ] # range of seconds until the dirty plate arrives. @@ -116,103 +116,119 @@ hook_callbacks: callback_class: !!python/name:cooperative_cuisine.hook_addons.restricted_movement.RestrictedMovementHook '' callback_class_kwargs: ignore_dims: [t, b] - # # --------------- Scoring --------------- - orders: - hooks: [ completed_order ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' - callback_class_kwargs: - time_dependence_func: !!python/name:cooperative_cuisine.scores.constant_score '' - time_dependence_kwargs: { } - static_score: 100 - score_on_specific_kwarg: meal_name - score_map: { } - - 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 '' + fixed_agent_direction: + hooks: [ post_step ] + callback_class: !!python/name:cooperative_cuisine.hook_addons.restrict_facing_direction.RestrictedFacingDirectionHook '' callback_class_kwargs: - static_score: -5 - expired_orders: - hooks: [ order_expired ] - callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' + fixed_directions: [[0, 1]] + add_movement_info: + hooks: [ pre_perform_action ] + callback_class: !!python/name:cooperative_cuisine.hook_addons.add_player_movement_info.AddPlayerMovementInfoHook '' + callback_class_kwargs: {} + reset_movement_info: + hooks: [ state_dict ] + callback_class: !!python/name:cooperative_cuisine.hook_addons.reset_player_info.ResetPlayerInfoHook '' callback_class_kwargs: - static_score: -10 + keys: [ last_movement ] + delay: 0.2 + delay_key: 1 + # # --------------- Scoring --------------- +# orders: +# hooks: [ completed_order ] +# callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks '' +# callback_class_kwargs: +# time_dependence_func: !!python/name:cooperative_cuisine.scores.constant_score '' +# time_dependence_kwargs: { } +# static_score: 100 +# score_on_specific_kwarg: meal_name +# score_map: { } +# +# 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 +# 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: - - init_orders - - 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 - - drop_off_on_cooking_equipment_plate_dispenser - - on_item_transition - - progress_started - - progress_finished - - content_ready - - dispenser_item_returned - - additional_state_update - - game_ended_step - - score_changed - - fire_extinguished - - pick_up_on_cooking_equipment - - - 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_events: +# hooks: +# - init_orders +# - 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 +# - drop_off_on_cooking_equipment_plate_dispenser +# - on_item_transition +# - progress_started +# - progress_finished +# - content_ready +# - dispenser_item_returned +# - additional_state_update +# - game_ended_step +# - score_changed +# - fire_extinguished +# - pick_up_on_cooking_equipment +# +# +# 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: diff --git a/cooperative_cuisine/configs/layouts/mazes/m-basic.layout b/cooperative_cuisine/configs/layouts/with_addons/m-basic.layout similarity index 100% rename from cooperative_cuisine/configs/layouts/mazes/m-basic.layout rename to cooperative_cuisine/configs/layouts/with_addons/m-basic.layout diff --git a/cooperative_cuisine/configs/layouts/mazes/empty_large.layout b/cooperative_cuisine/configs/layouts/with_addons/moonlander.layout similarity index 100% rename from cooperative_cuisine/configs/layouts/mazes/empty_large.layout rename to cooperative_cuisine/configs/layouts/with_addons/moonlander.layout diff --git a/cooperative_cuisine/environment.py b/cooperative_cuisine/environment.py index 6ad7bdd80a5c4b96aa6030fa23a6ed9d3ae84727..c754d995ee3bc227c8c6423072e9ffddc8d8b929 100644 --- a/cooperative_cuisine/environment.py +++ b/cooperative_cuisine/environment.py @@ -312,7 +312,7 @@ class Environment: self.overwrite_counters(self.counters) meals_to_be_ordered = self.recipe_validation.validate_environment(self.counters) - assert meals_to_be_ordered, "Need possible meals for order generation." + # assert meals_to_be_ordered, "Need possible meals for order generation." available_meals = {meal: self.item_info[meal] for meal in meals_to_be_ordered} self.order_manager.set_available_meals(available_meals) diff --git a/cooperative_cuisine/hook_addons/add_player_movement_info.py b/cooperative_cuisine/hook_addons/add_player_movement_info.py new file mode 100644 index 0000000000000000000000000000000000000000..2f38e96613992ba6cd25869c7c60ec7efe4543e9 --- /dev/null +++ b/cooperative_cuisine/hook_addons/add_player_movement_info.py @@ -0,0 +1,19 @@ +import numpy as np + +from datetime import datetime +from cooperative_cuisine.action import Action, ActionType +from cooperative_cuisine.environment import Environment +from cooperative_cuisine.hooks import HookCallbackClass + + +class AddPlayerMovementInfoHook(HookCallbackClass): + + def __call__(self, hook_ref: str, env: Environment, **kwargs): + assert "action" in kwargs + action: Action = kwargs["action"] + for player in env.players.values(): + if player.name == action.player: + player.player_info["last_movement"] = (action.action_data.tolist(), env.env_time.isoformat()) + break + + diff --git a/cooperative_cuisine/hook_addons/reset_player_info.py b/cooperative_cuisine/hook_addons/reset_player_info.py new file mode 100644 index 0000000000000000000000000000000000000000..8a919935f1b554e356ab1d752bef58de0f851536 --- /dev/null +++ b/cooperative_cuisine/hook_addons/reset_player_info.py @@ -0,0 +1,30 @@ +import numpy as np +from datetime import datetime, timedelta +from cooperative_cuisine.action import Action, ActionType +from cooperative_cuisine.environment import Environment +from cooperative_cuisine.hooks import HookCallbackClass + + +class ResetPlayerInfoHook(HookCallbackClass): + + def __init__(self, name: str, env: Environment, keys: list[str] = None, delay: float | int = None, delay_key: str | int = None, **kwargs): + super().__init__(name, env, **kwargs) + self.keys = keys + self.delay = delay + self.delay_key = delay_key + + def __call__(self, hook_ref: str, env: Environment, **kwargs): + for player in env.players.values(): + if self.keys is None: + player.player_info = {} + else: + for key in self.keys: + if key in player.player_info: + if self.delay is not None: + t = datetime.fromisoformat(player.player_info[key][self.delay_key]) + if timedelta(seconds=self.delay) < env.env_time - t: + player.player_info[key] = None + del player.player_info[key] + else: + del player.player_info[key] + diff --git a/cooperative_cuisine/hook_addons/restrict_facing_direction.py b/cooperative_cuisine/hook_addons/restrict_facing_direction.py new file mode 100644 index 0000000000000000000000000000000000000000..5b66d9fa9864911b15eb99b387e9d3df6fed2fa6 --- /dev/null +++ b/cooperative_cuisine/hook_addons/restrict_facing_direction.py @@ -0,0 +1,23 @@ +import numpy as np + +from cooperative_cuisine.action import Action, ActionType +from cooperative_cuisine.environment import Environment +from cooperative_cuisine.hooks import HookCallbackClass + + +class RestrictedFacingDirectionHook(HookCallbackClass): + def __init__(self, name: str, env: Environment, fixed_directions: list[list[int]] = None, **kwargs): + super().__init__(name, env, **kwargs) + self.fixed_directions = [np.array(d) for d in fixed_directions] if fixed_directions is not None else [] + + def _clip_to_closest_direction(self, direction: np.ndarray) -> np.ndarray: + if not self.fixed_directions: + return direction + direction = direction / np.linalg.norm(direction) + best_match = max(self.fixed_directions, key=lambda d: np.dot(direction, d / np.linalg.norm(d))) + return best_match + + def __call__(self, hook_ref: str, env: Environment, **kwargs): + for player in env.players.values(): + if player.facing_direction is not None: + player.facing_direction = self._clip_to_closest_direction(player.facing_direction) diff --git a/cooperative_cuisine/hook_addons/restricted_movement.py b/cooperative_cuisine/hook_addons/restricted_movement.py index b3d07a36a8b2b10e057cb8851822c5b4b7e0a17f..cbf8e2cd134daff9672c53b01b1acae61693c905 100644 --- a/cooperative_cuisine/hook_addons/restricted_movement.py +++ b/cooperative_cuisine/hook_addons/restricted_movement.py @@ -22,3 +22,5 @@ class RestrictedMovementHook(HookCallbackClass): action.action_data[0] = 0 if "r" in self.ignore_dims and action.action_data[0] > 0: action.action_data[0] = 0 + + diff --git a/cooperative_cuisine/pygame_2d_vis/drawing.py b/cooperative_cuisine/pygame_2d_vis/drawing.py index fb4807fabf71d31e55a3e674c4a534bd59e3e9c2..1f463386b8bacd39b4b28fcaf9eb0af9de3605c0 100644 --- a/cooperative_cuisine/pygame_2d_vis/drawing.py +++ b/cooperative_cuisine/pygame_2d_vis/drawing.py @@ -248,18 +248,20 @@ class Visualizer: if "items" in state: for (name, pos) in state["items"]: - pos[0] = pos[0] * grid_size - pos[1] = pos[1] * grid_size - - self.draw_item(pos=pos, item={"type": name}, screen=screen, grid_size=grid_size) + self.draw_item(pos=pos, item={"type": name}, screen=screen) - for idx, col in zip(controlled_player_idxs, [colors["red"], colors["blue"]]): - pygame.draw.circle( - screen, - col, - (np.array(state["players"][int(idx)]["pos"]) + 0.5) * self.grid_size, - (self.grid_size / 2), - ) + if "PlayerHighlighting" in self.config and "controlled_player_colors" in self.config["PlayerHighlighting"]: + controlled_player_colors = list(map(lambda c: colors[c] if c in colors else c, self.config["PlayerHighlighting"]["controlled_player_colors"])) + else: + controlled_player_colors = [colors["red"], colors["blue"]] + if controlled_player_colors: + for idx, color in zip(controlled_player_idxs, controlled_player_colors): + pygame.draw.circle( + screen, + color, + (np.array(state["players"][int(idx)]["pos"]) + 0.5) * self.grid_size, + (self.grid_size / 2), + ) self.draw_players( screen, @@ -406,8 +408,7 @@ class Visualizer: if "ground" in state: for pos, ground in state["ground"]: if ground in self.config: - self.draw_thing(surface, [(pos[0] * grid_size) + block_size, (pos[1] * grid_size) + block_size], - grid_size, self.config[ground]["parts"]) + self.draw_thing(surface, pos, self.config[ground]["parts"]) def draw_image( self, @@ -461,15 +462,31 @@ class Visualizer: color: RGB, facing: npt.NDArray[float] | list[float], is_robot: bool, + player_info: dict = None, ): - pygame.draw.circle( - screen, - color, - self.model_to_world_coords(pos - facing * 0.25), - self.grid_size * 0.18 if is_robot else self.grid_size * 0.2, - ) - sprite = self.config["Cook"]["parts"] if not is_robot else self.config["RobotChef"]["parts"] - self.draw_thing(screen, pos, sprite, scale=1.0, orientation=facing.tolist()) + sprite_config = self.config["Cook"] if not is_robot else self.config["RobotChef"] + if "add_circle_color" in sprite_config: + pygame.draw.circle( + screen, + color, + self.model_to_world_coords(pos - facing * 0.25), + self.grid_size * 0.18 if is_robot else self.grid_size * 0.2, + ) + parts = sprite_config["parts"] + if "based_on_movement_data" in sprite_config and player_info and "last_movement" in player_info: + direction = None + match player_info["last_movement"][0]: + case [0.0, 1.0]: + direction = "down" + case [1.0, 0.0]: + direction = "right" + case [0.0, -1.0]: + direction = "up" + case [-1.0, 0.0]: + direction = "left" + if direction is not None and direction in sprite_config["based_on_movement_data"]: + parts = sprite_config["based_on_movement_data"][direction] + self.draw_thing(screen, pos, parts, scale=1.0, orientation=facing.tolist()) def draw_players( self, @@ -489,6 +506,7 @@ class Visualizer: pos = player_dict["pos"] facing = np.array(player_dict["facing_direction"], dtype=float) + player_info = player_dict["player_info"] if self.USE_PLAYER_COOK_SPRITES: if "player_type" in player_dict["player_info"]: @@ -497,7 +515,7 @@ class Visualizer: robot = False self.draw_cook( - screen, pos, colors[self.player_colors[p_idx]], facing, is_robot=robot + screen, pos, colors[self.player_colors[p_idx]], facing, is_robot=robot, player_info=player_info ) else: player_radius = 0.4 diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py index af1afb34a06dafd09fb40043f409ed8280227564..6f8c2580c5cdf702b22f9e2334b28187766b67f8 100644 --- a/cooperative_cuisine/pygame_2d_vis/gui.py +++ b/cooperative_cuisine/pygame_2d_vis/gui.py @@ -45,6 +45,7 @@ from cooperative_cuisine.utils import ( ) from cooperative_cuisine.pygame_2d_vis.generate_layout_thumbnail import layout_thumbnail +DEFAULT_VIS_CONFIG = ROOT_DIR / "pygame_2d_vis" / "visualization.yaml" class MenuStates(Enum): """Enumeration of "Page" types in the 2D pygame vis.""" @@ -172,8 +173,10 @@ class PyGameGUI: self.manager_id = random.choice(manager_ids) - with open(ROOT_DIR / "pygame_2d_vis" / "visualization.yaml", "r") as file: - self.visualization_config = yaml.safe_load(file) + self.current_visualisation_config_path = None + self.visualization_config = None + self.vis = None + self.set_vis_config(DEFAULT_VIS_CONFIG) self.language = self.visualization_config["Gui"]["language"] self.skip_tutorial = self.visualization_config["Gui"]["skip_tutorial"] @@ -211,7 +214,7 @@ class PyGameGUI: self.kitchen_height = 1 self.kitchen_aspect_ratio = 1 self.images_path = ROOT_DIR / "pygame_gui" / "images" - self.vis = Visualizer(self.visualization_config) + self.last_score: float = 0 self.switch_score_color: bool = False @@ -238,6 +241,14 @@ class PyGameGUI: } self.item_info_file_paths = sorted(list(self.item_info_file_paths_dict.keys())) + self.visuaization_config_file_paths_dict = { + p.name.replace("visualization", "vis"): p for p in (ROOT_DIR / "pygame_2d_vis").rglob("vis*.yaml") + } + self.visuaization_config_file_paths_dict.update( + {p.name.replace("visualization", "vis"): p for p in (ROOT_DIR / "configs").glob("vis*.yaml")} + ) + self.visuaization_config_file_paths = sorted(list(self.visuaization_config_file_paths_dict.keys())) + self.current_layout_idx = 0 self.selected_layout = "basic.layout" @@ -449,6 +460,13 @@ class PyGameGUI: if event.type == pygame.JOYBUTTONDOWN: key_set.next_player() + def set_vis_config(self, vis_config_path): + # GUI Elements etc. will not be updated + self.current_visualisation_config_path = vis_config_path + with open(vis_config_path, "r") as file: + self.visualization_config = yaml.safe_load(file) + self.vis = Visualizer(self.visualization_config) + def set_window_size(self): """Sets the window size based on fullscreen or not.""" if self.fullscreen: @@ -642,6 +660,16 @@ class PyGameGUI: "right": "right", }, ) + self.visualization_config_selection = pygame_gui.elements.UIDropDownMenu( + relative_rect=r, + manager=self.manager, + options_list=self.visuaization_config_file_paths, + starting_option=[c for c in self.visuaization_config_file_paths if "vis.yaml" == c][0], + anchors={ + "top_target": self.item_info_selection, + "right": "right", + }, + ) smooth_options = ["Smooth Paths", "Don't Smooth Paths"] self.smooth_paths_selection = pygame_gui.elements.UIDropDownMenu( relative_rect=r, @@ -649,10 +677,13 @@ class PyGameGUI: options_list=smooth_options, starting_option=smooth_options[1], anchors={ - "top_target": self.item_info_selection, + "top_target": self.visualization_config_selection, "right": "right", }, ) + + + self.press_a_image.set_dimensions(new_dims) if not self.CONNECT_WITH_STUDY_SERVER: assert len(self.layout_file_paths) != 0, "No layout files." @@ -1151,6 +1182,7 @@ class PyGameGUI: self.env_config_selection, self.item_info_selection, self.smooth_paths_selection, + self.visualization_config_selection, self.agent_selection_scroll_space, self.number_bots_label, self.tutorial_image, @@ -1219,6 +1251,7 @@ class PyGameGUI: # config_elements self.env_config_selection, self.item_info_selection, + self.visualization_config_selection, ] # only show fullscreen and quit button in debug and not arcade @@ -1909,6 +1942,10 @@ class PyGameGUI: item_info, layout, environment_config, _ = load_config_files(item_info_path, layout_path, environment_config_path) num_players = 1 if tutorial else self.number_players + vis_config_path = self.visuaization_config_file_paths_dict[self.visualization_config_selection.selected_option] + if vis_config_path != self.current_visualisation_config_path: + print(f"Loading new visualization config: {vis_config_path} (old: {self.current_visualisation_config_path})") + self.set_vis_config(vis_config_path) seed = int(random.random() * 100000) creation_json = CreateEnvironmentConfig( diff --git a/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/coin.png b/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/coin.png new file mode 100644 index 0000000000000000000000000000000000000000..8a2af4b47f01ef070ef913727fdc85de7ea2a194 Binary files /dev/null and b/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/coin.png differ diff --git a/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/comet_master.png b/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/comet_master.png new file mode 100644 index 0000000000000000000000000000000000000000..4fa35db6c1a9a0d5cfbb04f17f924d30c81fed63 Binary files /dev/null and b/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/comet_master.png differ diff --git a/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/spaceship_master.png b/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/spaceship_master.png new file mode 100644 index 0000000000000000000000000000000000000000..587d8edd7c898051b9302331b1bebfb09dcbeacf Binary files /dev/null and b/cooperative_cuisine/pygame_2d_vis/images/moonlander_assets/spaceship_master.png differ diff --git a/cooperative_cuisine/pygame_2d_vis/visualization.yaml b/cooperative_cuisine/pygame_2d_vis/visualization.yaml index cb74d082d49224ef890d323391862befb5bc4bbe..05aec53169f3667b7daeada70e6d298203b55a4f 100644 --- a/cooperative_cuisine/pygame_2d_vis/visualization.yaml +++ b/cooperative_cuisine/pygame_2d_vis/visualization.yaml @@ -28,7 +28,7 @@ GameWindow: game_border_color: black background_color: lemonchiffon1 # optimization - cache_flags: [ Counters, Background ] # [None] + cache_flags: [ Counters, Background ] # [None] # reduced_background: true # false if moveable counter or updated background (coins etc.) Orders: @@ -39,6 +39,10 @@ Kitchen: ground_tiles_color: sgigray76 background_lines: gray79 +PlayerHighlighting: + controlled_player_colors: [ red, blue ] + + Counter: parts: # - type: rect @@ -304,12 +308,14 @@ OnionSoupPlate: size: 0.3 Cook: + add_circle_color: true parts: - type: image path: images/pixel_cook_masked.png size: 1 RobotChef: + add_circle_color: true parts: - type: image path: images/robot_chef.png diff --git a/cooperative_cuisine/pygame_2d_vis/visualization_moonlander.yaml b/cooperative_cuisine/pygame_2d_vis/visualization_moonlander.yaml new file mode 100644 index 0000000000000000000000000000000000000000..87249014505120b157c87d61553dd2e8fff06b9e --- /dev/null +++ b/cooperative_cuisine/pygame_2d_vis/visualization_moonlander.yaml @@ -0,0 +1,491 @@ +# colors: https://www.webucator.com/article/python-color-constants-module/ + +Gui: + language: "de" + use_player_cook_sprites: True + show_interaction_range: False + show_counter_centers: False + press_button_to_continue: True + start_in_fullscreen: False + force_debug_elements: False + force_always_on_top: False + skip_tutorial: False + audio_level: 0.1 + default_agent_script: IPyHopAgent + hide_agents: [ ] + +GameWindow: + screen_margin_proportion: 0.15 + min_width: 900 + min_height: 600 + buttons_width: 180 + buttons_height: 60 + FPS: 60 + + order_bar_height: 100 + + game_border_size: 1 + game_border_color: black + background_color: lemonchiffon1 + # optimization + cache_flags: [None] # [ Counters, Background ] # [None] # + reduced_background: false # false if moveable counter or updated background (coins etc.) + +Orders: + show_ingredients: False + show_source_ingredients: False + +Kitchen: + ground_tiles_color: black + background_lines: black + +PlayerHighlighting: + controlled_player_colors: [ ] + +Counter: + parts: [] + # - type: rect + # height: 1 + # width: 1 + # color: whitesmoke +# - type: image +# 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 +# path: images/cutting_board_large.png +# size: 0.75 +# center_offset: [ 0, -0.05 ] + + +PlateDispenser: + parts: [] + +Trashcan: + parts: [] +# - type: image +# path: images/trash6.png +# size: 0.88 + +#TomatoDispenser: +# parts: +# - color: orangered1 +# type: rect +# height: 0.8 +# width: 0.8 +# +#LettuceDispenser: +# parts: +# - color: palegreen3 +# type: rect +# height: 0.8 +# width: 0.8 +# +#OnionDispenser: +# parts: +# - color: deeppink3 +# type: rect +# height: 0.8 +# width: 0.8 +# +#MeatDispenser: +# parts: +# - color: indianred1 +# type: rect +# height: 0.8 +# width: 0.8 +# +#BunDispenser: +# parts: +# - color: sandybrown +# type: rect +# height: 0.8 +# width: 0.8 + +Dispenser: + parts: [] +# - type: circle +# color: black +# radius: 0.35 +# center_offset: [ 0, -0.05 ] +# - type: circle +# color: gray83 +# radius: 0.33 +# center_offset: [ 0, -0.05 ] + + +# item_offset: [ 0, -0.05 ] +# item_scale: 0.9 + +ServingWindow: + parts: [] +# - type: image +# path: images/star.png +# 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 + +Stove: + parts: [] +# - type: image +# path: images/stove3.png +# size: 0.8 +# center_offset: [ 0, -0.05 ] + +Sink: + parts: [] +# - type: image +# path: images/sink1.png +# size: 0.85 +# center_offset: [ 0, -0.12 ] + +SinkAddon: + parts: [] +# - type: image +# path: images/drip2.png +# size: 0.75 +# center_offset: [ 0, -0.05 ] + +# Tools +Extinguisher: + parts: [] +# - type: image +# path: images/fire_extinguisher.png +# size: 0.85 +# center_offset: [ 0, -0.05 ] + +# Effects +Fire: + parts: + - type: image + path: images/fire.png + size: 1 + +Fire1: + parts: + - type: image + path: images/fire.png + size: 1.0 + +Fire2: + parts: + - type: image + path: images/fire2.png + size: 1.0 + +Fire3: + parts: + - type: image + path: images/fire3.png + size: 1.0 + + +# Items +Tomato: + parts: [] +# - type: image +# path: images/tomato.png +# size: 0.8 + +Onion: + parts: + - type: image + path: images/onion.png + size: 0.8 + +Bun: + parts: + - type: image + path: images/bun.png + size: 0.9 + +Lettuce: + parts: [] +# - type: image +# path: images/lettuce.png +# size: 0.9 + +Meat: + parts: + - type: image + path: images/meat.png + size: 1 + +ChoppedLettuce: + parts: + - type: image + path: images/lettuce_cut4.png + size: 0.85 + +ChoppedTomato: + parts: + - type: image + path: images/tomato_cut.png + size: 0.9 + +ChoppedOnion: + parts: + - type: image + path: images/onion_cut.png + size: 0.95 + +RawPatty: + parts: + - type: image + path: images/raw_patty.png + size: 0.9 + +CookedPatty: + parts: + - type: image + path: images/cooked_patty.png + size: 0.9 + +Burger: + parts: + - type: image + path: images/burger.png + size: 0.9 + +Salad: + parts: + - type: image + path: images/salad.png + size: 0.8 + +TomatoSoup: + parts: + - type: image + path: images/tomato_soup_pot.png + size: 1.05 + center_offset: [ -0.02, -0.1 ] + +TomatoSoupPlate: + parts: + - type: image + path: images/tomato_soup_plate.png + size: 0.6 + +OnionSoup: + parts: + - type: image + path: images/onion_soup_pot.png + size: 1.05 + center_offset: [ -0.02, -0.1 ] + - type: image + path: images/onion_cut.png + size: 0.2 + center_offset: [ -0.02, -0.1 ] + +OnionSoupPlate: + parts: + - type: image + path: images/onion_soup_plate.png + size: 0.6 + - type: image + path: images/onion_cut.png + size: 0.3 + +Cook: + add_circle_color: false + based_on_movement_data: + left: + - type: image + path: images/moonlander_assets/spaceship_master_left_turn.png + size: 1 + right: + - type: image + path: images/moonlander_assets/spaceship_master_right_turn.png + size: 1 + parts: + - type: image + path: images/moonlander_assets/spaceship_master.png + size: 1 + +RobotChef: + parts: + - type: image + path: images/robot_chef.png + size: 1 + +Plate: + parts: [] + +DirtyPlate: + parts: [] + +Pot: + parts: + - type: image + path: images/pot_smaller.png + size: 1.05 + center_offset: [ -0.02, -0.1 ] + +Pan: + parts: + - type: image + path: images/pan.png + size: 1.1 + +DeepFryer: + parts: + - type: image + path: images/deepfryer1.png + size: 0.8 + +Oven: + parts: + - type: image + path: images/pizza_oven.png + size: 1 + +Basket: + parts: + - type: image + path: images/basket1.png + size: 0.8 + +Peel: + parts: + - type: image + path: images/pizza_wood.png + size: 1.2 + center_offset: [ 0, 0.2 ] + +Potato: + parts: + - type: image + path: images/potato2.png + size: 0.7 + +RawChips: + parts: + - type: image + path: images/raw_fries.png + size: 0.8 + +Chips: + parts: + - type: image + path: images/fries2.png + size: 0.8 + +Fish: + parts: + - type: image + path: images/fish3.png + size: 0.9 + +ChoppedFish: + parts: + - type: image + path: images/cut_fish.png + size: 0.8 + +FriedFish: + parts: + - type: image + path: images/fried_fish.png + size: 0.8 + +FishAndChips: + parts: + - type: image + path: images/fries2.png + size: 0.8 + center_offset: [ -0.1, 0 ] + - type: image + path: images/fried_fish.png + 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 + path: images/pizza_dough.png + size: 0.7 + +PizzaBase: + parts: + - type: image + path: images/pizza_base.png + size: 0.9 + +Sausage: + parts: + - type: image + path: images/sausage.png + size: 0.8 + +ChoppedSausage: + parts: + - type: image + path: images/sausage_chopped.png + size: 0.8 + +Cheese: + parts: + - type: image + path: images/cheese3.png + size: 0.7 + +GratedCheese: + parts: + - type: image + path: images/grated_cheese.png + size: 1.1 + +Pizza: + parts: + - type: image + path: images/pizza.png + size: 0.9 + +Water: + parts: + - type: rect + height: 1 + width: 1 + color: blue + +Lava: + parts: + - type: rect + height: 1 + width: 1 + color: red + +Target: + parts: + - type: image + path: images/moonlander_assets/coin.png + size: 1 \ No newline at end of file diff --git a/cooperative_cuisine/pygame_2d_vis/visualization_no_caching.yaml b/cooperative_cuisine/pygame_2d_vis/visualization_no_caching.yaml new file mode 100644 index 0000000000000000000000000000000000000000..28dcb2c5390112a3ee760b04017dc18a074dad8e --- /dev/null +++ b/cooperative_cuisine/pygame_2d_vis/visualization_no_caching.yaml @@ -0,0 +1,493 @@ +# colors: https://www.webucator.com/article/python-color-constants-module/ + +Gui: + language: "de" + use_player_cook_sprites: True + show_interaction_range: False + show_counter_centers: False + press_button_to_continue: True + start_in_fullscreen: False + force_debug_elements: False + force_always_on_top: False + skip_tutorial: False + audio_level: 0.1 + default_agent_script: IPyHopAgent + hide_agents: [ ] + +GameWindow: + screen_margin_proportion: 0.15 + min_width: 900 + min_height: 600 + buttons_width: 180 + buttons_height: 60 + FPS: 60 + + order_bar_height: 100 + + game_border_size: 1 + game_border_color: black + background_color: lemonchiffon1 + # optimization + cache_flags: [None] # [ Counters, Background ] # [None] # + reduced_background: false # false if moveable counter or updated background (coins etc.) + +Orders: + show_ingredients: False + show_source_ingredients: False + +Kitchen: + ground_tiles_color: sgigray76 + background_lines: gray79 + +PlayerHighlighting: + controlled_player_colors: [ red, blue ] + +Counter: + parts: + # - type: rect + # height: 1 + # width: 1 + # color: whitesmoke + - type: image + 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 + path: images/cutting_board_large.png + size: 0.75 + center_offset: [ 0, -0.05 ] + + +PlateDispenser: + parts: + - type: image + path: images/plate_dispenser.png + size: 1 + +Trashcan: + parts: + - type: image + path: images/trash6.png + size: 0.88 + +#TomatoDispenser: +# parts: +# - color: orangered1 +# type: rect +# height: 0.8 +# width: 0.8 +# +#LettuceDispenser: +# parts: +# - color: palegreen3 +# type: rect +# height: 0.8 +# width: 0.8 +# +#OnionDispenser: +# parts: +# - color: deeppink3 +# type: rect +# height: 0.8 +# width: 0.8 +# +#MeatDispenser: +# parts: +# - color: indianred1 +# type: rect +# height: 0.8 +# width: 0.8 +# +#BunDispenser: +# parts: +# - color: sandybrown +# type: rect +# height: 0.8 +# width: 0.8 + +Dispenser: + parts: + - type: circle + color: black + radius: 0.35 + center_offset: [ 0, -0.05 ] + - type: circle + color: gray83 + radius: 0.33 + center_offset: [ 0, -0.05 ] + + + item_offset: [ 0, -0.05 ] + item_scale: 0.9 + +ServingWindow: + parts: + - type: image + path: images/star.png + 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 + +Stove: + parts: + - type: image + path: images/stove3.png + size: 0.8 + center_offset: [ 0, -0.05 ] + +Sink: + parts: + - type: image + path: images/sink1.png + size: 0.85 + center_offset: [ 0, -0.12 ] + +SinkAddon: + parts: + - type: image + path: images/drip2.png + size: 0.75 + center_offset: [ 0, -0.05 ] + +# Tools +Extinguisher: + parts: + - type: image + path: images/fire_extinguisher.png + size: 0.85 + center_offset: [ 0, -0.05 ] + +# Effects +Fire: + parts: + - type: image + path: images/fire.png + size: 1 + +Fire1: + parts: + - type: image + path: images/fire.png + size: 1.0 + +Fire2: + parts: + - type: image + path: images/fire2.png + size: 1.0 + +Fire3: + parts: + - type: image + path: images/fire3.png + size: 1.0 + + +# Items +Tomato: + parts: + - type: image + path: images/tomato.png + size: 0.8 + +Onion: + parts: + - type: image + path: images/onion.png + size: 0.8 + +Bun: + parts: + - type: image + path: images/bun.png + size: 0.9 + +Lettuce: + parts: + - type: image + path: images/lettuce.png + size: 0.9 + +Meat: + parts: + - type: image + path: images/meat.png + size: 1 + +ChoppedLettuce: + parts: + - type: image + path: images/lettuce_cut4.png + size: 0.85 + +ChoppedTomato: + parts: + - type: image + path: images/tomato_cut.png + size: 0.9 + +ChoppedOnion: + parts: + - type: image + path: images/onion_cut.png + size: 0.95 + +RawPatty: + parts: + - type: image + path: images/raw_patty.png + size: 0.9 + +CookedPatty: + parts: + - type: image + path: images/cooked_patty.png + size: 0.9 + +Burger: + parts: + - type: image + path: images/burger.png + size: 0.9 + +Salad: + parts: + - type: image + path: images/salad.png + size: 0.8 + +TomatoSoup: + parts: + - type: image + path: images/tomato_soup_pot.png + size: 1.05 + center_offset: [ -0.02, -0.1 ] + +TomatoSoupPlate: + parts: + - type: image + path: images/tomato_soup_plate.png + size: 0.6 + +OnionSoup: + parts: + - type: image + path: images/onion_soup_pot.png + size: 1.05 + center_offset: [ -0.02, -0.1 ] + - type: image + path: images/onion_cut.png + size: 0.2 + center_offset: [ -0.02, -0.1 ] + +OnionSoupPlate: + parts: + - type: image + path: images/onion_soup_plate.png + size: 0.6 + - type: image + path: images/onion_cut.png + size: 0.3 + +Cook: + add_circle_color: true + parts: + - type: image + path: images/pixel_cook_masked.png + size: 1 + +RobotChef: + add_circle_color: true + parts: + - type: image + path: images/robot_chef.png + size: 1 + +Plate: + parts: + - type: image + path: images/plate_clean.png + size: 0.8 + +DirtyPlate: + parts: + - type: image + path: images/plate_dirty.png + size: 0.8 + +Pot: + parts: + - type: image + path: images/pot_smaller.png + size: 1.05 + center_offset: [ -0.02, -0.1 ] + +Pan: + parts: + - type: image + path: images/pan.png + size: 1.1 + +DeepFryer: + parts: + - type: image + path: images/deepfryer1.png + size: 0.8 + +Oven: + parts: + - type: image + path: images/pizza_oven.png + size: 1 + +Basket: + parts: + - type: image + path: images/basket1.png + size: 0.8 + +Peel: + parts: + - type: image + path: images/pizza_wood.png + size: 1.2 + center_offset: [ 0, 0.2 ] + +Potato: + parts: + - type: image + path: images/potato2.png + size: 0.7 + +RawChips: + parts: + - type: image + path: images/raw_fries.png + size: 0.8 + +Chips: + parts: + - type: image + path: images/fries2.png + size: 0.8 + +Fish: + parts: + - type: image + path: images/fish3.png + size: 0.9 + +ChoppedFish: + parts: + - type: image + path: images/cut_fish.png + size: 0.8 + +FriedFish: + parts: + - type: image + path: images/fried_fish.png + size: 0.8 + +FishAndChips: + parts: + - type: image + path: images/fries2.png + size: 0.8 + center_offset: [ -0.1, 0 ] + - type: image + path: images/fried_fish.png + 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 + path: images/pizza_dough.png + size: 0.7 + +PizzaBase: + parts: + - type: image + path: images/pizza_base.png + size: 0.9 + +Sausage: + parts: + - type: image + path: images/sausage.png + size: 0.8 + +ChoppedSausage: + parts: + - type: image + path: images/sausage_chopped.png + size: 0.8 + +Cheese: + parts: + - type: image + path: images/cheese3.png + size: 0.7 + +GratedCheese: + parts: + - type: image + path: images/grated_cheese.png + size: 1.1 + +Pizza: + parts: + - type: image + path: images/pizza.png + size: 0.9 + +Water: + parts: + - type: rect + height: 1 + width: 1 + color: blue + +Lava: + parts: + - type: rect + height: 1 + width: 1 + color: red + +Target: + parts: + - type: rect + height: 1 + width: 1 + color: gold1 \ No newline at end of file