diff --git a/overcooked_simulator/game_content/layouts/basic.layout b/overcooked_simulator/game_content/layouts/basic.layout index 36384db97fe2a3ed42d102147071024f27773dcf..2e7395aa296304bae3d354eea5613affcc0ee6b0 100644 --- a/overcooked_simulator/game_content/layouts/basic.layout +++ b/overcooked_simulator/game_content/layouts/basic.layout @@ -1,9 +1,9 @@ -#QU#TNLB# -#_______M -#_______# -W________ -#__A__A__ -C________ -C_______# -#_______X -#P#S+#S+# \ No newline at end of file +#QU#T###NLB# +#__________M +#__________# +W___________ +#__A_____A__ +C___________ +C__________# +#__________X +#P#S+####S+# \ No newline at end of file diff --git a/overcooked_simulator/game_content/layouts/empty.layout b/overcooked_simulator/game_content/layouts/empty.layout index de0f1b9eb58638cd6a2b94b6ae4591bc72e6144d..2e7dfab89179c0b88c470ee8e601186e71f59460 100644 --- a/overcooked_simulator/game_content/layouts/empty.layout +++ b/overcooked_simulator/game_content/layouts/empty.layout @@ -1,3 +1,3 @@ -_____ -_____ -____P \ No newline at end of file +____ +APA_ +____ \ No newline at end of file diff --git a/overcooked_simulator/game_content/player_config.yaml b/overcooked_simulator/game_content/player_config.yaml index 4e863b3d5a470b3c094cfb4c75362f96011eeddc..7387659aa3919ca3315269cbe0ca97c3460aac89 100644 --- a/overcooked_simulator/game_content/player_config.yaml +++ b/overcooked_simulator/game_content/player_config.yaml @@ -1,3 +1,3 @@ radius: 0.4 -move_dist: 0.2 +move_dist: 0.12 interaction_range: 1.6 \ No newline at end of file diff --git a/overcooked_simulator/pygame_gui/__init__.py b/overcooked_simulator/gui_2d_vis/__init__.py similarity index 100% rename from overcooked_simulator/pygame_gui/__init__.py rename to overcooked_simulator/gui_2d_vis/__init__.py diff --git a/overcooked_simulator/pygame_gui/game_colors.py b/overcooked_simulator/gui_2d_vis/game_colors.py similarity index 100% rename from overcooked_simulator/pygame_gui/game_colors.py rename to overcooked_simulator/gui_2d_vis/game_colors.py diff --git a/overcooked_simulator/gui_2d_vis/gui_theme.json b/overcooked_simulator/gui_2d_vis/gui_theme.json new file mode 100644 index 0000000000000000000000000000000000000000..3ca11b55479e8d69bbbf8ab0e3fc4b46cad713e7 --- /dev/null +++ b/overcooked_simulator/gui_2d_vis/gui_theme.json @@ -0,0 +1,49 @@ +{ + "defaults": { + "colours": { + "normal_bg": "#45494e", + "hovered_bg": "#35393e", + "disabled_bg": "#25292e", + "selected_bg": "#193754", + "dark_bg": "#15191e", + "normal_text": "#c5cbd8", + "hovered_text": "#FFFFFF", + "selected_text": "#FFFFFF", + "disabled_text": "#6d736f", + "link_text": "#0000EE", + "link_hover": "#2020FF", + "link_selected": "#551A8B", + "text_shadow": "#777777", + "normal_border": "#DDDDDD", + "hovered_border": "#B0B0B0", + "disabled_border": "#808080", + "selected_border": "#8080B0", + "active_border": "#8080B0", + "filled_bar": "#f4251b", + "unfilled_bar": "#CCCCCC" + } + }, + "button": { + "colours": { + "normal_bg": "#45494e", + "hovered_bg": "#35393e", + "disabled_bg": "#25292e", + "selected_bg": "#193754", + "active_bg": "#193754", + "dark_bg": "#15191e", + "normal_text": "#c5cbd8", + "hovered_text": "#FFFFFF", + "selected_text": "#FFFFFF", + "disabled_text": "#6d736f", + "active_text": "#FFFFFF", + "normal_border": "#DDDDDD", + "hovered_border": "#B0B0B0", + "disabled_border": "#808080", + "selected_border": "#8080B0", + "active_border": "#8080B0" + }, + "misc": { + "tool_tip_delay": "1.5" + } + } +} \ No newline at end of file diff --git a/overcooked_simulator/pygame_gui/images/pixel_cook.png b/overcooked_simulator/gui_2d_vis/images/pixel_cook.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/pixel_cook.png rename to overcooked_simulator/gui_2d_vis/images/pixel_cook.png diff --git a/overcooked_simulator/pygame_gui/images/plate.png b/overcooked_simulator/gui_2d_vis/images/plate.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/plate.png rename to overcooked_simulator/gui_2d_vis/images/plate.png diff --git a/overcooked_simulator/pygame_gui/images/plate_clean.png b/overcooked_simulator/gui_2d_vis/images/plate_clean.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/plate_clean.png rename to overcooked_simulator/gui_2d_vis/images/plate_clean.png diff --git a/overcooked_simulator/pygame_gui/images/plate_dirty.png b/overcooked_simulator/gui_2d_vis/images/plate_dirty.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/plate_dirty.png rename to overcooked_simulator/gui_2d_vis/images/plate_dirty.png diff --git a/overcooked_simulator/pygame_gui/images/pot.png b/overcooked_simulator/gui_2d_vis/images/pot.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/pot.png rename to overcooked_simulator/gui_2d_vis/images/pot.png diff --git a/overcooked_simulator/pygame_gui/images/tomato.png b/overcooked_simulator/gui_2d_vis/images/tomato.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/tomato.png rename to overcooked_simulator/gui_2d_vis/images/tomato.png diff --git a/overcooked_simulator/pygame_gui/images/tomato_cut.png b/overcooked_simulator/gui_2d_vis/images/tomato_cut.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/tomato_cut.png rename to overcooked_simulator/gui_2d_vis/images/tomato_cut.png diff --git a/overcooked_simulator/pygame_gui/images/tomato_soup.png b/overcooked_simulator/gui_2d_vis/images/tomato_soup.png similarity index 100% rename from overcooked_simulator/pygame_gui/images/tomato_soup.png rename to overcooked_simulator/gui_2d_vis/images/tomato_soup.png diff --git a/overcooked_simulator/pygame_gui/pygame_gui.py b/overcooked_simulator/gui_2d_vis/overcooked_gui.py similarity index 59% rename from overcooked_simulator/pygame_gui/pygame_gui.py rename to overcooked_simulator/gui_2d_vis/overcooked_gui.py index 7e4dfae288fd10406731cddc8b1380e6c43c4970..7c910c07f9b6fadfd571a64eaf6d4f606fee333f 100644 --- a/overcooked_simulator/pygame_gui/pygame_gui.py +++ b/overcooked_simulator/gui_2d_vis/overcooked_gui.py @@ -3,10 +3,12 @@ import logging import math import sys from collections import deque +from enum import Enum import numpy as np import numpy.typing as npt import pygame +import pygame_gui import yaml from scipy.spatial import KDTree @@ -19,9 +21,9 @@ from overcooked_simulator.game_items import ( Meal, Plate, ) +from overcooked_simulator.gui_2d_vis.game_colors import BLUE +from overcooked_simulator.gui_2d_vis.game_colors import colors, Color from overcooked_simulator.overcooked_environment import Action -from overcooked_simulator.pygame_gui.game_colors import BLUE -from overcooked_simulator.pygame_gui.game_colors import colors, Color from overcooked_simulator.simulation_runner import Simulator USE_PLAYER_COOK_SPRITES = True @@ -29,6 +31,12 @@ SHOW_INTERACTION_RANGE = False SHOW_COUNTER_CENTERS = False +class MenuStates(Enum): + Start = "Start" + Game = "Game" + End = "End" + + def create_polygon(n, length): if n == 0: return np.array([0, 0]) @@ -86,9 +94,11 @@ class PyGameGUI: player_names: list[str], player_keys: list[pygame.key], ): - self.screen = None + self.game_screen = None self.FPS = 60 - self.simulator = simulator + self.simulator: Simulator = simulator + self.running = True + self.player_names = player_names self.player_keys = player_keys @@ -100,28 +110,53 @@ class PyGameGUI: ] # TODO cache loaded images? - with open(ROOT_DIR / "pygame_gui" / "visualization.yaml", "r") as file: + with open(ROOT_DIR / "gui_2d_vis" / "visualization.yaml", "r") as file: self.visualization_config = yaml.safe_load(file) + self.screen_margin = self.visualization_config["GameWindow"]["screen_margin"] + self.window_width = self.visualization_config["GameWindow"]["start_width"] + self.window_height = self.visualization_config["GameWindow"]["start_height"] + + self.main_window = pygame.display.set_mode( + ( + self.window_width, + self.window_height, + ) + ) + + self.game_width, self.game_height = 0, 0 + + self.images_path = ROOT_DIR / "pygame_gui" / "images" + + self.image_cache_dict = {} + + self.menu_state = MenuStates.Start + self.manager: pygame_gui.UIManager + + def init_window_sizes(self): if self.visualization_config["GameWindow"]["WhatIsFixed"] == "window_width": - self.window_width = self.visualization_config["GameWindow"]["size"] + game_width = self.visualization_config["GameWindow"]["size"] kitchen_aspect_ratio = ( - simulator.env.kitchen_height / simulator.env.kitchen_width + self.simulator.env.kitchen_height / self.simulator.env.kitchen_width ) - self.window_height = int(self.window_width * kitchen_aspect_ratio) - self.grid_size = int(self.window_width / simulator.env.kitchen_width) + game_height = int(game_width * kitchen_aspect_ratio) + grid_size = int(game_width / self.simulator.env.kitchen_width) elif self.visualization_config["GameWindow"]["WhatIsFixed"] == "grid": - self.grid_size = self.visualization_config["GameWindow"]["size"] - self.window_width, self.window_height = ( - simulator.env.kitchen_width * self.grid_size, - simulator.env.kitchen_height * self.grid_size, + grid_size = self.visualization_config["GameWindow"]["size"] + game_width, game_height = ( + self.simulator.env.kitchen_width * grid_size, + self.simulator.env.kitchen_height * grid_size, ) + else: + game_width, game_height = 0, 0 + grid_size = 0 - self.images_path = ROOT_DIR / "pygame_gui" / "images" + window_width, window_height = ( + game_width + (2 * self.screen_margin), + game_height + (2 * self.screen_margin), + ) - self.player_colors = self.create_player_colors() - - self.image_cache_dict = {} + return window_width, window_height, game_width, game_height, grid_size def create_player_colors(self) -> list[Color]: number_player = len(self.simulator.env.players) @@ -192,11 +227,14 @@ class PyGameGUI: def draw_background(self): """Visualizes a game background.""" block_size = self.grid_size // 2 # Set the size of the grid block + self.game_screen.fill( + colors[self.visualization_config["Kitchen"]["ground_tiles_color"]] + ) for x in range(0, self.window_width, block_size): for y in range(0, self.window_height, block_size): rect = pygame.Rect(x, y, block_size, block_size) pygame.draw.rect( - self.screen, + self.game_screen, self.visualization_config["Kitchen"]["background_lines"], rect, 1, @@ -208,7 +246,7 @@ class PyGameGUI: image = self.image_cache_dict[cache_entry] else: image = pygame.image.load( - ROOT_DIR / "pygame_gui" / img_path + ROOT_DIR / "gui_2d_vis" / img_path ).convert_alpha() self.image_cache_dict[cache_entry] = image @@ -217,7 +255,7 @@ class PyGameGUI: image = pygame.transform.rotate(image, rot_angle) rect = image.get_rect() rect.center = pos - self.screen.blit(image, rect) + self.game_screen.blit(image, rect) def draw_players(self, state): """Visualizes the players as circles with a triangle for the facing direction. @@ -244,13 +282,13 @@ class PyGameGUI: color1 = self.player_colors[p_idx] color2 = colors["white"] - pygame.draw.circle(self.screen, color2, pos, size) - pygame.draw.circle(self.screen, BLUE, pos, size, width=1) - pygame.draw.circle(self.screen, colors[color1], pos, size // 2) + pygame.draw.circle(self.game_screen, color2, pos, size) + pygame.draw.circle(self.game_screen, BLUE, pos, size, width=1) + pygame.draw.circle(self.game_screen, colors[color1], pos, size // 2) facing = player.facing_direction pygame.draw.polygon( - self.screen, + self.game_screen, BLUE, ( ( @@ -267,14 +305,20 @@ class PyGameGUI: if SHOW_INTERACTION_RANGE: pygame.draw.circle( - self.screen, + self.game_screen, BLUE, player.facing_point * self.grid_size, player.interaction_range * self.grid_size, width=1, ) pygame.draw.circle( - self.screen, colors["red1"], player.facing_point * self.grid_size, 4 + self.game_screen, + colors["red1"], + player.facing_point * self.grid_size, + 4, + ) + pygame.draw.circle( + self.game_screen, colors["red1"], player.facing_point, 4 ) if player.holding is not None: @@ -287,7 +331,7 @@ class PyGameGUI: counter: Counter = player.current_nearest_counter pos = counter.pos * self.grid_size pygame.draw.rect( - self.screen, + self.game_screen, colors[self.player_colors[p_idx]], rect=pygame.Rect( pos[0] - (self.grid_size // 2), @@ -325,7 +369,7 @@ class PyGameGUI: if "center_offset" in part: dx, dy = np.array(part["center_offset"]) * self.grid_size rect = pygame.Rect(pos[0] + dx, pos[1] + dy, height, width) - pygame.draw.rect(self.screen, color, rect) + pygame.draw.rect(self.game_screen, color, rect) else: rect = pygame.Rect( pos[0] - (height / 2), @@ -333,19 +377,19 @@ class PyGameGUI: height, width, ) - pygame.draw.rect(self.screen, color, rect) + pygame.draw.rect(self.game_screen, color, rect) case "circle": radius = part["radius"] * self.grid_size color = colors[part["color"]] if "center_offset" in part: pygame.draw.circle( - self.screen, + self.game_screen, color, - pos + (np.array(part["center_offset"])*self.grid_size), + pos + (np.array(part["center_offset"]) * self.grid_size), radius, ) else: - pygame.draw.circle(self.screen, color, pos, radius) + pygame.draw.circle(self.game_screen, color, pos, radius) def draw_item(self, pos: npt.NDArray[float], item: Item, scale: float = 1.0): """Visualization of an item at the specified position. On a counter or in the hands of the player. @@ -390,7 +434,7 @@ class PyGameGUI: progress_width, bar_height, ) - pygame.draw.rect(self.screen, colors["green1"], progress_bar) + pygame.draw.rect(self.game_screen, colors["green1"], progress_bar) def draw_counter(self, counter): """Visualization of a counter at its position. If it is occupied by an item, it is also shown. @@ -431,9 +475,7 @@ class PyGameGUI: for counter in state["counters"]: self.draw_counter(counter) if SHOW_COUNTER_CENTERS: - pygame.draw.circle( - self.screen, colors["green1"], counter.pos * self.grid_size, 3 - ) + pygame.draw.circle(self.game_screen, colors["green1"], counter.pos, 3) def draw(self, state): """Main visualization function. @@ -441,15 +483,191 @@ class PyGameGUI: Args: state: The game state returned by the environment. """ - self.screen.fill( - colors[self.visualization_config["Kitchen"]["ground_tiles_color"]] - ) + self.draw_background() self.draw_counters(state) self.draw_players(state) + self.manager.draw_ui(self.game_screen) + + def init_ui_elements(self): + self.manager = pygame_gui.UIManager((self.window_width, self.window_height)) + self.manager.get_theme().load_theme(ROOT_DIR / "gui_2d_vis" / "gui_theme.json") + + button_width, button_height = 200, 60 + self.start_button = pygame_gui.elements.UIButton( + relative_rect=pygame.Rect( + ( + (self.window_width // 2) - button_width // 2, + (self.window_height / 2) - button_height // 2, + ), + (button_width, button_height), + ), + text="Start Game", + manager=self.manager, + ) + self.start_button.can_hover() + + self.quit_button = pygame_gui.elements.UIButton( + relative_rect=pygame.Rect( + ( + (self.window_width - button_width), + 0, + ), + (button_width, button_height), + ), + text="Quit Game", + manager=self.manager, + ) + self.quit_button.can_hover() + + self.finished_button = pygame_gui.elements.UIButton( + relative_rect=pygame.Rect( + ( + (self.window_width - button_width), + (self.window_height - button_height), + ), + (button_width, button_height), + ), + text="End screen", + manager=self.manager, + ) + self.finished_button.can_hover() + + self.back_button = pygame_gui.elements.UIButton( + relative_rect=pygame.Rect( + ( + (0), + (self.window_height - button_height), + ), + (button_width, button_height), + ), + text="Back to Start", + manager=self.manager, + ) + self.back_button.can_hover() + + self.score_rect = pygame.Rect( + ( + (self.window_width // 2) - button_width // 2, + (self.window_height / 2) - button_height // 2, + ), + (button_width, button_height), + ) - pygame.display.flip() + self.score_label = pygame_gui.elements.UILabel( + text=f"Your score: _", + relative_rect=self.score_rect, + manager=self.manager, + object_id="#score_label", + ) + + layout_file_paths = [ + str(p.name) + for p in (ROOT_DIR / "game_content" / "layouts").glob("*.layout") + ] + assert len(layout_file_paths) != 0, "No layout files." + dropdown_width, dropdown_height = 200, 40 + self.layout_selection = pygame_gui.elements.UIDropDownMenu( + relative_rect=pygame.Rect( + ( + 0, + 0, + ), + (dropdown_width, dropdown_height), + ), + manager=self.manager, + options_list=layout_file_paths, + starting_option=layout_file_paths[-1], + ) + + def setup_windows(self): + ( + self.window_width, + self.window_height, + self.game_width, + self.game_height, + self.grid_size, + ) = self.init_window_sizes() + + self.game_screen = pygame.Surface( + ( + self.game_width, + self.game_height, + ), + ) + + self.main_window = pygame.display.set_mode( + ( + self.window_width, + self.window_height, + ) + ) + self.player_colors = self.create_player_colors() + + def setup_simulation(self, config_path, layout_path): + self.simulator = Simulator(config_path, layout_path, 600) + number_player = len(self.player_names) + for i in range(number_player): + player_name = f"p{i}" + self.simulator.register_player(player_name) + self.simulator.start() + + def manage_button_visibility(self): + match self.menu_state: + case MenuStates.Start: + self.back_button.hide() + self.quit_button.show() + self.start_button.show() + self.score_label.hide() + self.finished_button.hide() + self.layout_selection.show() + case MenuStates.Game: + self.start_button.hide() + self.back_button.show() + self.score_label.hide() + self.finished_button.show() + self.layout_selection.hide() + case MenuStates.End: + self.start_button.hide() + self.back_button.show() + self.score_label.show() + self.score_label.set_text( + f"Your Score is {self.simulator.env.game_score.score}" + ) + self.finished_button.hide() + self.layout_selection.hide() + + def start_button_press(self): + self.menu_state = MenuStates.Game + + layout_path = ( + ROOT_DIR + / "game_content" + / "layouts" + / self.layout_selection.selected_option + ) + config_path = ROOT_DIR / "game_content" / "environment_config.yaml" + + self.setup_simulation(config_path, layout_path) + self.setup_windows() + self.init_ui_elements() + log.debug("Pressed start button") + + def back_button_press(self): + self.simulator.stop() + self.menu_state = MenuStates.Start + log.debug("Pressed back button") + + def quit_button_press(self): + self.simulator.stop() + self.running = False + log.debug("Pressed quit button") + + def finished_button_press(self): + self.simulator.stop() + self.menu_state = MenuStates.End + log.debug("Pressed finished button") def start_pygame(self): """Starts pygame and the gui loop. Each frame the game state is visualized and keyboard inputs are read.""" @@ -457,32 +675,81 @@ class PyGameGUI: pygame.init() pygame.font.init() - self.screen = pygame.display.set_mode((self.window_width, self.window_height)) + self.setup_windows() + self.init_ui_elements() + pygame.display.set_caption("Simple Overcooked Simulator") - self.screen.fill( - colors[self.visualization_config["Kitchen"]["ground_tiles_color"]] - ) clock = pygame.time.Clock() + self.manage_button_visibility() + # Game loop - running = True - while running: + self.running = True + while self.running: try: + time_delta = clock.tick(self.FPS) / 1000.0 + for event in pygame.event.get(): if event.type == pygame.QUIT: - running = False - if event.type in [pygame.KEYDOWN, pygame.KEYUP]: + self.running = False + if event.type == pygame_gui.UI_BUTTON_PRESSED: + match event.ui_element: + case self.start_button: + self.start_button_press() + case self.back_button: + self.back_button_press() + case self.finished_button: + self.finished_button_press() + case self.quit_button: + self.quit_button_press() + + self.manage_button_visibility() + + if ( + event.type in [pygame.KEYDOWN, pygame.KEYUP] + and self.menu_state == MenuStates.Game + ): self.handle_key_event(event) - self.handle_keys() - clock.tick(self.FPS) - state = self.simulator.get_state() - self.draw(state) + self.manager.process_events(event) + + # drawing: + + self.main_window.fill(colors["lemonchiffon1"]) + self.manager.draw_ui(self.main_window) + + match self.menu_state: + case MenuStates.Start: + pass + case MenuStates.Game: + self.draw_background() + + self.handle_keys() + + state = self.simulator.get_state() + self.draw(state) + + game_screen_rect = self.game_screen.get_rect() + game_screen_rect.center = [ + self.window_width // 2, + self.window_height // 2, + ] + + self.main_window.blit(self.game_screen, game_screen_rect) + + case MenuStates.End: + pygame.draw.rect( + self.game_screen, colors["cornsilk1"], self.score_rect + ) + self.manager.update(time_delta) + pygame.display.flip() except KeyboardInterrupt: - pygame.quit() self.simulator.stop() + pygame.quit() sys.exit() + self.simulator.stop() pygame.quit() + sys.exit() diff --git a/overcooked_simulator/pygame_gui/visualization.yaml b/overcooked_simulator/gui_2d_vis/visualization.yaml similarity index 98% rename from overcooked_simulator/pygame_gui/visualization.yaml rename to overcooked_simulator/gui_2d_vis/visualization.yaml index cc229b5e0a4332e9f12dab0c34c553735a38e7c8..021761424694300f516cd77cfd63e907ac60fa23 100644 --- a/overcooked_simulator/pygame_gui/visualization.yaml +++ b/overcooked_simulator/gui_2d_vis/visualization.yaml @@ -3,6 +3,9 @@ GameWindow: WhatIsFixed: window_width # entweder grid oder window_width size: 600 + screen_margin: 100 + start_width: 600 + start_height: 600 Kitchen: ground_tiles_color: sgigray76 diff --git a/overcooked_simulator/main.py b/overcooked_simulator/main.py index 239779f471d534e3e9e4cb186735b01c24630226..86caba35763a863735582b4f0e0fb32c3402bae7 100644 --- a/overcooked_simulator/main.py +++ b/overcooked_simulator/main.py @@ -7,7 +7,7 @@ from datetime import datetime import pygame from overcooked_simulator import ROOT_DIR -from overcooked_simulator.pygame_gui.pygame_gui import PyGameGUI +from overcooked_simulator.gui_2d_vis.overcooked_gui import PyGameGUI from overcooked_simulator.simulation_runner import Simulator log = logging.getLogger(__name__) @@ -50,12 +50,9 @@ def main(): pygame.K_i, ] keys2 = [pygame.K_a, pygame.K_d, pygame.K_w, pygame.K_s, pygame.K_f, pygame.K_e] - gui = PyGameGUI(simulator, [f"p{i}" for i in range(number_player)], [keys1, keys2]) - simulator.start() + gui = PyGameGUI(simulator, [f"p{i}" for i in range(number_player)], [keys1, keys2]) gui.start_pygame() - - simulator.stop() sys.exit() diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 62f260e6e1a8fd1b5edbfbed5d3a619f95f02e1d..8f5adf962fed07d207ac034821c4978edb3a3d47 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -160,7 +160,7 @@ class Environment: Args: layout_file: Path to the layout file. """ - current_y: float = 1.5 + current_y: float = 0.5 counters: list[Counter] = [] designated_player_positions: list[npt.NDArray] = [] free_positions: list[npt.NDArray] = [] @@ -173,7 +173,7 @@ class Environment: for line in lines: line = line.replace("\n", "").replace(" ", "") # remove newline char - current_x = 1.5 + current_x = 0.5 for character in line: character = character.capitalize() pos = np.array([current_x, current_y]) @@ -193,8 +193,7 @@ class Environment: self.kitchen_width = current_x current_y += 1 - self.kitchen_height = int(self.kitchen_height + 2.5) - self.kitchen_width = int(self.kitchen_width + 0.5) + self.kitchen_width -= 0.5 return counters, designated_player_positions, free_positions diff --git a/overcooked_simulator/simulation_runner.py b/overcooked_simulator/simulation_runner.py index c1f32c801836859f772109ff1585127f6d9974da..8ad41e28ae7bb2834297cadeaa2d06f915e1c87a 100644 --- a/overcooked_simulator/simulation_runner.py +++ b/overcooked_simulator/simulation_runner.py @@ -27,7 +27,7 @@ class Simulator(Thread): def __init__( self, - env_layout_path, + env_config_path, layout_path, frequency: int, item_info_path=ROOT_DIR / "game_content" / "item_info.yaml", @@ -40,7 +40,7 @@ class Simulator(Thread): self.step_frequency: int = frequency self.preferred_sleep_time_ns: float = 1e9 / self.step_frequency self.env: Environment = Environment( - env_layout_path, layout_path, item_info_path + env_config_path, layout_path, item_info_path ) super().__init__() diff --git a/setup.py b/setup.py index 69f30ff36f7dbc7780cf15b9f4f6971aa54da00d..b3ceeba705d5d329be64f2dc239e4de19dbc5056 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open("README.md") as readme_file: with open("CHANGELOG.md") as history_file: history = history_file.read() -requirements = ["numpy", "pygame", "scipy", "pytest>=3", "pyyaml"] +requirements = ["numpy", "pygame", "scipy", "pytest>=3", "pyyaml", "pygame-gui"] test_requirements = [ "pytest>=3",