From bf7f6f8743571cd1298206dec0991f5d620212a1 Mon Sep 17 00:00:00 2001 From: fheinrich <fheinrich@techfak.uni-bielefeld.de> Date: Thu, 7 Dec 2023 17:09:35 +0100 Subject: [PATCH] Stove viz --- overcooked_simulator/counters.py | 1 + overcooked_simulator/layouts/basic.layout | 2 +- .../overcooked_environment.py | 11 +++++---- overcooked_simulator/pygame_gui/pygame_gui.py | 23 ++++++++++++++++++- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/overcooked_simulator/counters.py b/overcooked_simulator/counters.py index 7f06b7c7..32476e8b 100644 --- a/overcooked_simulator/counters.py +++ b/overcooked_simulator/counters.py @@ -215,6 +215,7 @@ class Trash(Counter): class Stove(Counter): + def pick_up(self): ... diff --git a/overcooked_simulator/layouts/basic.layout b/overcooked_simulator/layouts/basic.layout index d4d883fc..f077e3ee 100644 --- a/overcooked_simulator/layouts/basic.layout +++ b/overcooked_simulator/layouts/basic.layout @@ -1,5 +1,5 @@ EEEEEEEEEEE -ECCCCTCCCCE +ECCUCTCCCCE ECEEEEEEECE ECEEEEEEECE EWEEEEEEEEE diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 93a9bd93..48f67595 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -6,7 +6,6 @@ if TYPE_CHECKING: from overcooked_simulator.player import Player from pathlib import Path import numpy as np -import numpy.typing as npt from scipy.spatial import distance_matrix from overcooked_simulator.counters import ( @@ -16,6 +15,7 @@ from overcooked_simulator.counters import ( TomatoDispenser, ServingWindow, PlateReturn, + Stove, ) @@ -69,6 +69,7 @@ class Environment: "T": TomatoDispenser, "P": PlateReturn, "E": None, + "U": Stove, # Stove with pot: U because it looks like a pot } self.counters: list[Counter] = self.create_counters(self.layout_path) @@ -192,7 +193,7 @@ class Environment: old_pos_other = collided_player.pos.copy() collided_player.move(pushing_vector * (collided_player.move_dist / 2)) if self.detect_collision_counters( - collided_player + collided_player ) or self.detect_collision_world_bounds(player): collided_player.move_abs(old_pos_other) player.move_abs(old_pos) @@ -226,9 +227,9 @@ class Environment: Returns: True if the player is intersecting with any object in the environment. """ return ( - len(self.get_collided_players(player)) != 0 - or self.detect_collision_counters(player) - or self.detect_collision_world_bounds(player) + len(self.get_collided_players(player)) != 0 + or self.detect_collision_counters(player) + or self.detect_collision_world_bounds(player) ) def get_collided_players(self, player: Player) -> list[Player]: diff --git a/overcooked_simulator/pygame_gui/pygame_gui.py b/overcooked_simulator/pygame_gui/pygame_gui.py index a708b088..b9b68c49 100644 --- a/overcooked_simulator/pygame_gui/pygame_gui.py +++ b/overcooked_simulator/pygame_gui/pygame_gui.py @@ -11,8 +11,9 @@ from overcooked_simulator.counters import ( TomatoDispenser, PlateReturn, ServingWindow, +^^ Stove, ) -from overcooked_simulator.game_items import ProgressibleItem, Plate, HoldableItem +from overcooked_simulator.game_items import ProgressibleItem, Plate, HoldableItem, Pot from overcooked_simulator.game_items import Tomato from overcooked_simulator.overcooked_environment import Action from overcooked_simulator.simulation_runner import Simulator @@ -31,6 +32,9 @@ BACKGROUND_LINES_COLOR = (200, 200, 200) KNIFE_COLOR = (120, 120, 120) PLATE_RETURN_COLOR = (170, 170, 240) BOARD_COLOR = (239, 193, 151) +POT_COLOR = (220, 220, 220) +# STOVE_COLOR = (60, 60, 60) +# STOVE_HEATING_PLATE_COLOR = (252, 123, 73) USE_COOK_SPRITE = False @@ -218,6 +222,10 @@ class PyGameGUI: if item.holds is not None: self.draw_item(pos, item.holds) + if isinstance(item, Pot): + pot_size = 20 + pygame.draw.circle(self.screen, GREY, pos, pot_size) + if isinstance(item, ProgressibleItem) and not item.finished: self.draw_progress_bar(pos, item.progressed_steps, item.steps_needed) @@ -289,6 +297,7 @@ class PyGameGUI: ) pygame.draw.rect(self.screen, RED, board_rect) self.draw_item(counter.pos, Tomato()) + if isinstance(counter, ServingWindow): board_size = 33 board_rect = pygame.Rect( @@ -299,6 +308,18 @@ class PyGameGUI: ) pygame.draw.rect(self.screen, YELLOW, board_rect) + if isinstance(counter, Stove): + stove_width = 35 + stove_height = 25 + stove_rect = pygame.Rect( + counter.pos[0] - (stove_width / 2), + counter.pos[1] - (stove_height / 2), + stove_width, + stove_height, + ) + pygame.draw.rect(self.screen, BLACK, stove_rect) + pygame.draw.circle(self.screen, RED, center=counter.pos, radius=10) + if counter.occupied_by is not None: if isinstance(counter.occupied_by, list): for i, o in enumerate(counter.occupied_by): -- GitLab