diff --git a/overcooked_simulator/order.py b/overcooked_simulator/order.py index b61c9218f7adce6b059933eaf27d66c9bb9e8ee1..0c954882a3ef3eb0708ffb63a71abc090814f562 100644 --- a/overcooked_simulator/order.py +++ b/overcooked_simulator/order.py @@ -51,7 +51,7 @@ import uuid from abc import abstractmethod from collections import deque from datetime import datetime, timedelta -from typing import Callable, Tuple, Any, Deque, Protocol, TypedDict +from typing import Callable, Tuple, Any, Deque, Protocol, TypedDict, Type from overcooked_simulator.game_items import Item, Plate, ItemInfo @@ -62,6 +62,17 @@ ORDER_CATEGORY = "Order" """The string for the `category` value in the json state representation for all orders.""" +class OrderConfig(TypedDict): + """The configuration of the order in the `environment_config`under the `order` key.""" + + order_gen_class: Type[OrderGeneration] + """The class that should handle the order generation.""" + order_gen_kwargs: dict[str, Any] + """The additional kwargs for the order gen class.""" + serving_not_ordered_meals: Callable[[Item], Tuple[bool, float]] + """""" + + @dataclasses.dataclass class Order: """Datawrapper for Orders""" diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 84d6312821e9cb74b1e488d850e2e13f73429c99..4aee44b774204eec337a256003a2321cf3110f72 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -9,7 +9,7 @@ import sys from datetime import timedelta, datetime from enum import Enum from pathlib import Path -from typing import Literal +from typing import Literal, TypedDict import numpy as np import numpy.typing as npt @@ -24,7 +24,10 @@ from overcooked_simulator.game_items import ( ItemInfo, ItemType, ) -from overcooked_simulator.order import OrderAndScoreManager +from overcooked_simulator.order import ( + OrderAndScoreManager, + OrderConfig, +) from overcooked_simulator.player import Player, PlayerConfig from overcooked_simulator.state_representation import StateRepresentation from overcooked_simulator.utils import create_init_env_time, get_closest @@ -79,6 +82,15 @@ class Action: # TODO Abstract base class for different environments +class EnvironmentConfig(TypedDict): + plates: PlateConfig + game: dict[Literal["time_limit_seconds"], int] + meals: dict[Literal["all"] | Literal["list"], bool | list[str]] + orders: OrderConfig + player_config: PlayerConfig + layout_chars: dict[str, str] + + class Environment: """Environment class which handles the game logic for the overcooked-inspired environment. @@ -101,9 +113,13 @@ class Environment: """Are the configs just the path to the files.""" if self.as_files: with open(env_config, "r") as file: - self.environment_config = yaml.load(file, Loader=yaml.Loader) + self.environment_config: EnvironmentConfig = yaml.load( + file, Loader=yaml.Loader + ) else: - self.environment_config = yaml.load(env_config, Loader=yaml.Loader) + self.environment_config: EnvironmentConfig = yaml.load( + env_config, Loader=yaml.Loader + ) self.layout_config = layout_config """The layout config for the environment""" # self.counter_side_length = 1 # -> this changed! is 1 now