Skip to content
Snippets Groups Projects
Commit bf7f6f87 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Stove viz

parent 7871acde
No related branches found
No related tags found
1 merge request!10Resolve "Pot and stove and cooking tomato soup"
...@@ -215,6 +215,7 @@ class Trash(Counter): ...@@ -215,6 +215,7 @@ class Trash(Counter):
class Stove(Counter): class Stove(Counter):
def pick_up(self): def pick_up(self):
... ...
......
EEEEEEEEEEE EEEEEEEEEEE
ECCCCTCCCCE ECCUCTCCCCE
ECEEEEEEECE ECEEEEEEECE
ECEEEEEEECE ECEEEEEEECE
EWEEEEEEEEE EWEEEEEEEEE
......
...@@ -6,7 +6,6 @@ if TYPE_CHECKING: ...@@ -6,7 +6,6 @@ if TYPE_CHECKING:
from overcooked_simulator.player import Player from overcooked_simulator.player import Player
from pathlib import Path from pathlib import Path
import numpy as np import numpy as np
import numpy.typing as npt
from scipy.spatial import distance_matrix from scipy.spatial import distance_matrix
from overcooked_simulator.counters import ( from overcooked_simulator.counters import (
...@@ -16,6 +15,7 @@ from overcooked_simulator.counters import ( ...@@ -16,6 +15,7 @@ from overcooked_simulator.counters import (
TomatoDispenser, TomatoDispenser,
ServingWindow, ServingWindow,
PlateReturn, PlateReturn,
Stove,
) )
...@@ -69,6 +69,7 @@ class Environment: ...@@ -69,6 +69,7 @@ class Environment:
"T": TomatoDispenser, "T": TomatoDispenser,
"P": PlateReturn, "P": PlateReturn,
"E": None, "E": None,
"U": Stove, # Stove with pot: U because it looks like a pot
} }
self.counters: list[Counter] = self.create_counters(self.layout_path) self.counters: list[Counter] = self.create_counters(self.layout_path)
...@@ -192,7 +193,7 @@ class Environment: ...@@ -192,7 +193,7 @@ class Environment:
old_pos_other = collided_player.pos.copy() old_pos_other = collided_player.pos.copy()
collided_player.move(pushing_vector * (collided_player.move_dist / 2)) collided_player.move(pushing_vector * (collided_player.move_dist / 2))
if self.detect_collision_counters( if self.detect_collision_counters(
collided_player collided_player
) or self.detect_collision_world_bounds(player): ) or self.detect_collision_world_bounds(player):
collided_player.move_abs(old_pos_other) collided_player.move_abs(old_pos_other)
player.move_abs(old_pos) player.move_abs(old_pos)
...@@ -226,9 +227,9 @@ class Environment: ...@@ -226,9 +227,9 @@ class Environment:
Returns: True if the player is intersecting with any object in the environment. Returns: True if the player is intersecting with any object in the environment.
""" """
return ( return (
len(self.get_collided_players(player)) != 0 len(self.get_collided_players(player)) != 0
or self.detect_collision_counters(player) or self.detect_collision_counters(player)
or self.detect_collision_world_bounds(player) or self.detect_collision_world_bounds(player)
) )
def get_collided_players(self, player: Player) -> list[Player]: def get_collided_players(self, player: Player) -> list[Player]:
......
...@@ -11,8 +11,9 @@ from overcooked_simulator.counters import ( ...@@ -11,8 +11,9 @@ from overcooked_simulator.counters import (
TomatoDispenser, TomatoDispenser,
PlateReturn, PlateReturn,
ServingWindow, 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.game_items import Tomato
from overcooked_simulator.overcooked_environment import Action from overcooked_simulator.overcooked_environment import Action
from overcooked_simulator.simulation_runner import Simulator from overcooked_simulator.simulation_runner import Simulator
...@@ -31,6 +32,9 @@ BACKGROUND_LINES_COLOR = (200, 200, 200) ...@@ -31,6 +32,9 @@ BACKGROUND_LINES_COLOR = (200, 200, 200)
KNIFE_COLOR = (120, 120, 120) KNIFE_COLOR = (120, 120, 120)
PLATE_RETURN_COLOR = (170, 170, 240) PLATE_RETURN_COLOR = (170, 170, 240)
BOARD_COLOR = (239, 193, 151) 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 USE_COOK_SPRITE = False
...@@ -218,6 +222,10 @@ class PyGameGUI: ...@@ -218,6 +222,10 @@ class PyGameGUI:
if item.holds is not None: if item.holds is not None:
self.draw_item(pos, item.holds) 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: if isinstance(item, ProgressibleItem) and not item.finished:
self.draw_progress_bar(pos, item.progressed_steps, item.steps_needed) self.draw_progress_bar(pos, item.progressed_steps, item.steps_needed)
...@@ -289,6 +297,7 @@ class PyGameGUI: ...@@ -289,6 +297,7 @@ class PyGameGUI:
) )
pygame.draw.rect(self.screen, RED, board_rect) pygame.draw.rect(self.screen, RED, board_rect)
self.draw_item(counter.pos, Tomato()) self.draw_item(counter.pos, Tomato())
if isinstance(counter, ServingWindow): if isinstance(counter, ServingWindow):
board_size = 33 board_size = 33
board_rect = pygame.Rect( board_rect = pygame.Rect(
...@@ -299,6 +308,18 @@ class PyGameGUI: ...@@ -299,6 +308,18 @@ class PyGameGUI:
) )
pygame.draw.rect(self.screen, YELLOW, board_rect) 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 counter.occupied_by is not None:
if isinstance(counter.occupied_by, list): if isinstance(counter.occupied_by, list):
for i, o in enumerate(counter.occupied_by): for i, o in enumerate(counter.occupied_by):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment