From 070d8f6d9984ebec27b645b61afd448c74cb6bbb Mon Sep 17 00:00:00 2001 From: fheinrich <fheinrich@techfak.uni-bielefeld.de> Date: Thu, 21 Dec 2023 15:23:57 +0100 Subject: [PATCH] Read grid size from viz config. Or change flag to use fixed window width, with grid size beeing rescaled --- .../game_content/layouts/basic.layout | 3 +-- .../game_content/player_config.yaml | 2 +- .../overcooked_environment.py | 2 +- overcooked_simulator/pygame_gui/pygame_gui.py | 22 ++++++++++++++----- .../pygame_gui/visualization.yaml | 2 ++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/overcooked_simulator/game_content/layouts/basic.layout b/overcooked_simulator/game_content/layouts/basic.layout index 9d755936..36384db9 100644 --- a/overcooked_simulator/game_content/layouts/basic.layout +++ b/overcooked_simulator/game_content/layouts/basic.layout @@ -6,5 +6,4 @@ W________ C________ C_______# #_______X -#P#S+#S+# - +#P#S+#S+# \ 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 4ae0190c..4e863b3d 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.1 +move_dist: 0.2 interaction_range: 1.6 \ No newline at end of file diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index cd869d03..99f555e9 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -189,7 +189,7 @@ class Environment: self.kitchen_width = current_x current_y += 1 - self.kitchen_height = int(self.kitchen_height + 1.5) + self.kitchen_height = int(self.kitchen_height + 2.5) self.kitchen_width = int(self.kitchen_width + 0.5) return counters, designated_player_positions, free_positions diff --git a/overcooked_simulator/pygame_gui/pygame_gui.py b/overcooked_simulator/pygame_gui/pygame_gui.py index 9c4dc97e..0861be90 100644 --- a/overcooked_simulator/pygame_gui/pygame_gui.py +++ b/overcooked_simulator/pygame_gui/pygame_gui.py @@ -89,12 +89,6 @@ class PyGameGUI: self.screen = None self.FPS = 60 self.simulator = simulator - self.grid_size = 40 - self.window_width, self.window_height = ( - simulator.env.kitchen_width * self.grid_size, - simulator.env.kitchen_height * self.grid_size, - ) - self.player_names = player_names self.player_keys = player_keys @@ -109,6 +103,22 @@ class PyGameGUI: with open(ROOT_DIR / "pygame_gui" / "visualization.yaml", "r") as file: self.visualization_config = yaml.safe_load(file) + self.RESCALE_GRID = True + if self.RESCALE_GRID: + self.window_width = 700 + kitchen_aspect_ratio = ( + simulator.env.kitchen_height / simulator.env.kitchen_width + ) + print(kitchen_aspect_ratio) + self.window_height = int(self.window_width * kitchen_aspect_ratio) + self.grid_size = int(self.window_width / simulator.env.kitchen_width) + else: + self.grid_size = self.visualization_config["KitchenGridSizePixels"] + self.window_width, self.window_height = ( + simulator.env.kitchen_width * self.grid_size, + simulator.env.kitchen_height * self.grid_size, + ) + self.images_path = ROOT_DIR / "pygame_gui" / "images" self.player_colors = self.create_player_colors() diff --git a/overcooked_simulator/pygame_gui/visualization.yaml b/overcooked_simulator/pygame_gui/visualization.yaml index 69dfe4e4..914ae74e 100644 --- a/overcooked_simulator/pygame_gui/visualization.yaml +++ b/overcooked_simulator/pygame_gui/visualization.yaml @@ -1,5 +1,7 @@ # colors: https://www.webucator.com/article/python-color-constants-module/ +KitchenGridSizePixels: 30 + Kitchen: ground_tiles_color: sgigray76 background_lines: gray79 -- GitLab