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

Visualizing meals

parent 3ba507ea
No related branches found
No related tags found
1 merge request!1340-visualisierungsregeln
......@@ -11,9 +11,7 @@ import numpy.typing as npt
from overcooked_simulator.game_items import (
CuttableItem,
Item,
ProgressibleItem,
Plate,
Tomato,
Pot,
CookingEquipment,
Soup,
......@@ -129,9 +127,12 @@ class ServingWindow(Counter):
return None
def can_score(self, item):
if isinstance(item, Plate):
if isinstance(item, Plate) and item.holds is not None:
if isinstance(item.holds, Soup):
return item.holds.finished
elif item.holds.name == "Salad":
return True
return False
def can_drop_off(self, item: Item) -> bool:
return self.can_score(item)
......@@ -189,13 +190,21 @@ class PlateReturn(Counter):
class Dispenser(Counter):
def __init__(self, pos, dispensing):
self.dispensing = dispensing
super().__init__(pos)
super().__init__(
pos,
CuttableItem(
name=self.dispensing,
finished_name=item_loopkup[self.dispensing]["finished_name"],
),
)
def pick_up(self, on_hands: bool = True):
return CuttableItem(
returned = CuttableItem(
name=self.dispensing,
finished_name=item_loopkup[self.dispensing]["finished_name"],
)
print(self.occupied_by)
return returned
def drop_off(self, item: Item) -> Item | None:
return None
......
......@@ -11,10 +11,10 @@ from overcooked_simulator.simulation_runner import Simulator
def main():
simulator = Simulator(Path(ROOT_DIR, "layouts", "basic.layout"), 600)
simulator = Simulator(Path(ROOT_DIR, "game_content/layouts", "basic.layout"), 600)
player_one_name = "p1"
player_two_name = "p2"
simulator.register_player(Player(player_one_name, np.array([200.0, 200.0])))
simulator.register_player(Player(player_one_name, np.array([350.0, 200.0])))
simulator.register_player(Player(player_two_name, np.array([100.0, 200.0])))
# TODO maybe read the player names and keyboard keys from config file?
......
......@@ -12,7 +12,7 @@ from overcooked_simulator.counters import (
Counter,
CuttingBoard,
Trash,
TomatoDispenser,
Dispenser,
ServingWindow,
PlateReturn,
Stove,
......@@ -66,7 +66,8 @@ class Environment:
"B": CuttingBoard,
"X": Trash,
"W": lambda pos: ServingWindow(pos, self.game_score),
"T": TomatoDispenser,
"T": lambda pos: Dispenser(pos, "Tomato"),
"L": lambda pos: Dispenser(pos, "Lettuce"),
"P": PlateReturn,
"E": None,
"U": Stove, # Stove with pot: U because it looks like a pot
......
......@@ -12,6 +12,7 @@ from overcooked_simulator.game_items import (
Item,
CookingEquipment,
Meal,
Soup,
)
from overcooked_simulator.overcooked_environment import Action
from overcooked_simulator.simulation_runner import Simulator
......@@ -258,12 +259,8 @@ class PyGameGUI:
if isinstance(item, CookingEquipment) and item.content:
self.draw_item(pos, item.content)
if isinstance(item, Meal) and item.parts:
if (
isinstance(item, Meal)
and isinstance(item, ProgressibleItem)
and item.parts
):
if isinstance(item, Soup) and item.parts:
if item.parts:
if not item.finished:
match len(item.parts):
case 1:
......@@ -287,6 +284,10 @@ class PyGameGUI:
rect.center = pos
self.screen.blit(image, rect)
if isinstance(item, Meal) and item.parts and not isinstance(item, Soup):
for i, o in enumerate(item.parts):
self.draw_item(np.abs([pos[0], pos[1] - (i * 5)]), o)
def draw_progress_bar(self, pos, current, needed):
"""Visualize progress of progressing item as a green bar under the item."""
if current != 0:
......@@ -328,11 +329,13 @@ class PyGameGUI:
)
if counter.occupied_by is not None:
# Multiple plates on plate return:
if isinstance(counter.occupied_by, list):
for i, o in enumerate(counter.occupied_by):
self.draw_item(
np.abs([counter.pos[0], counter.pos[1] - (i * 3)]), o
)
# All other items:
else:
self.draw_item(counter.pos, 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