diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 9ec02b2bfa990b885344f2f8db8ea66c6378cedf..82accaa215db61e80746aa63e89c533e1495de27 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -7,7 +7,7 @@ from datetime import timedelta from enum import Enum from pathlib import Path from threading import Lock -from typing import Literal +from typing import Literal, Any import numpy as np import numpy.typing as npt @@ -82,16 +82,25 @@ class Environment: def __init__(self, env_config_path: Path, layout_path, item_info_path: Path): self.lock = Lock() + """temporal lock for GUI until it uses the json state.""" self.players: dict[str, Player] = {} + """the player, keyed by their id/name.""" with open(env_config_path, "r") as file: - self.environment_config = yaml.load(file, Loader=yaml.Loader) + self.environment_config: dict[str, Any] = yaml.load( + file, Loader=yaml.Loader + ) + """The environment configuration dictionary. Maybe in the future also a dataclass.""" self.layout_path: Path = layout_path + """The path to the layout file. Loaded by `Environment.parse_layout_file` method. """ # self.counter_side_length = 1 # -> this changed! is 1 now self.item_info_path: Path = item_info_path - self.item_info = self.load_item_info() + """The path to the `item_info.yml`. A default file is in `ROOT_DIR / "game_content" / "item_info.yaml"`.""" + self.item_info: dict[str, ItemInfo] = self.load_item_info() + """The loaded item info dict. Keys are the item names.""" self.validate_item_info() + if self.environment_config["meals"]["all"]: self.allowed_meal_names = set( [ @@ -102,7 +111,8 @@ class Environment: ) else: self.allowed_meal_names = set(self.environment_config["meals"]["list"]) - + """The allowed meals depend on the `environment_config.yml` configured behaviour. Either all meals that + are possible or only a limited subset.""" self.order_and_score = OrderAndScoreManager( order_config=self.environment_config["orders"], available_meals={ @@ -111,6 +121,7 @@ class Environment: if info.type == ItemType.Meal and item in self.allowed_meal_names }, ) + """The manager for the orders and score update.""" plate_transitions = { item: { "seconds": info.seconds, @@ -200,9 +211,13 @@ class Environment: ), "+": SinkAddon, } + """Map of the characters in the layout file to callables returning the object/counter. In the future, + maybe replaced with a factory and the characters defined elsewhere in an config.""" self.kitchen_height: int = 0 + """The height of the kitchen, is set by the `Environment.parse_layout_file` method""" self.kitchen_width: int = 0 + """The width of the kitchen, is set by the `Environment.parse_layout_file` method""" ( self.counters, @@ -217,9 +232,11 @@ class Environment: `create_init_env_time`.""" self.order_and_score.create_init_orders(self.env_time) self.beginning_time = self.env_time + """The relative env time when it started.""" self.env_time_end = self.env_time + timedelta( seconds=self.environment_config["game"]["time_limit_seconds"] ) + """The relative env time when it will stop/end""" log.debug(f"End time: {self.env_time_end}") def get_env_time(self):