Skip to content
Snippets Groups Projects
Commit 01d04a57 authored by Florian Schröder's avatar Florian Schröder
Browse files

Merge branch '75-type-hint-class-for-environment-config' into 'main'

Resolve "Type hint class for environment config"

Closes #75

See merge request scs/cocosy/overcooked-simulator!37
parents 410e40fd 0aaf03dc
No related branches found
No related tags found
1 merge request!37Resolve "Type hint class for environment config"
Pipeline #45340 passed
......@@ -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"""
......
......@@ -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
......
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