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

Refactor docstrings for consistency and update environment name

Docstrings across classes and functions in different modules have been adjusted for consistency, specifically in how Return and Raise explanations are formatted. This makes the code more readable and uniform. Additionally, the environment name in 'environment.py' has been updated from "overcooked_sim" to "cooperative_cuisine_1".
parent 8e2492e8
No related branches found
No related tags found
No related merge requests found
......@@ -157,7 +157,8 @@ class Counter:
on_hands: Will the item be put on empty hands or on a cooking equipment.
player: The player name that tries to pick up from the counter.
Returns: The item which the counter is occupied by. None if nothing is there.
Returns:
The item which the counter is occupied by. None if nothing is there.
"""
self.hook(PRE_COUNTER_PICK_UP, counter=self, on_hands=on_hands, player=player)
if on_hands:
......@@ -202,8 +203,8 @@ class Counter:
item: The item for which to check, if it can be placed on the counter.
Returns: True if the item can be placed on the counter, False if not.
Returns:
True if the item can be placed on the counter, False if not.
"""
return self.occupied_by is None or self.occupied_by.can_combine(item)
......
......@@ -107,7 +107,7 @@ class Environment:
layout_config: Path | str,
item_info: Path | str,
as_files: bool = True,
env_name: str = "overcooked_sim",
env_name: str = "cooperative_cuisine_1",
seed: int = 56789223842348,
):
"""Constructor of the Environment.
......@@ -471,8 +471,8 @@ class Environment:
player_id: The player for which to get the state.
additional_key_values: Additional dict that is added to the state
Returns: The state of the game as a dict.
Returns:
The state of the game as a dict.
"""
if player_id in self.players:
self.hook(PRE_STATE, player_id=player_id)
......@@ -524,7 +524,8 @@ class Environment:
player_id: The player for which to get the state.
additional_key_values: Additional dict that is added to the state
Returns: The state of the game formatted as a json-string
Returns:
The state of the game formatted as a json-string
"""
state = self.get_state(player_id, additional_key_values)
......
......@@ -280,9 +280,9 @@ class EnvironmentHandler:
Args:
player_hash (str): The unique identifier of the player.
Returns: str: The state representation of the environment for a player. Is
Returns:
str: The state representation of the environment for a player. Is
`cooperative_cuisine.state_representation.StateRepresentation` as a json.
"""
if (
player_hash in self.player_data
......
"""
2D visualization of the CooperativeCuisine.
You can select the layout and start an environment:
You will play the levels accordingly to the study config:
- You can play the CooperativeCuisine. You can quit the application in the top right or end the level in the bottom right
- The orders are pictured in the top, the current score in the bottom left and the remaining time in the bottom
- The final screen after ending a level shows the score
......
......@@ -150,7 +150,8 @@ class Study:
Args:
num_participants: Number of participants wished to be added.
Returns: True of the participants fit in this study, False if not.
Returns:
True of the participants fit in this study, False if not.
"""
filled = (
self.num_connected_players + num_participants
......@@ -165,8 +166,11 @@ class Study:
Args:
level: LevelConfig which contains the paths to the env config, layout and item info files.
Returns: EnvironmentData which contains information about the newly created environment.
Raises: ValueError if the gameserver returned a conflict, HTTPError with 500 if the game server crashes.
Returns:
EnvironmentData which contains information about the newly created environment.
Raises:
ValueError if the gameserver returned a conflict, HTTPError with 500 if the game server crashes.
"""
item_info_path = expand_path(level["item_info_path"])
......@@ -279,9 +283,12 @@ class Study:
Args:
participant_id: The participant id which requests the connections.
Returns: The player info for the game server connections, level name and
information if the level is the last one and which recipes are possible in the level.
Raises: HTTPException(409) if the player is not found in the dictionary keys which saves the connections.
Returns:
The player info for the game server connections, level name and information if the level is the last
one and which recipes are possible in the level.
Raises:
HTTPException(409) if the player is not found in the dictionary keys which saves the connections.
"""
if participant_id in self.participant_id_to_player_info.keys():
player_info = self.participant_id_to_player_info[participant_id]
......@@ -446,9 +453,12 @@ class StudyManager:
Args:
participant_id: ID of the participant.
Returns: The player info for the game server connections, level name and
information if the level is the last one and which recipes are possible in the level.
Raises: HTTPException(409) if the player not registered in any study.
Returns:
The player info for the game server connections, level name and information if the level is the last one and
which recipes are possible in the level.
Raises:
HTTPException(409) if the player not registered in any study.
"""
if participant_id in self.running_tutorials.keys():
tutorial_env = self.running_tutorials[participant_id]
......@@ -596,7 +606,8 @@ async def get_game_connection(
Args:
participant_id: ID of the requesting participant.
Returns: A dict containing the game server connection information and information about the current level.
Returns:
A dict containing the game server connection information and information about the current level.
"""
player_info, level_info = study_manager.get_participant_game_connection(
......
......@@ -170,7 +170,8 @@ def get_closest(point: npt.NDArray[float], counters: list[Counter]):
point: The point in the env for which to find the closest counter
counters: List of objects with a `pos` attribute to compare to.
Returns: The closest counter for the given point.
Returns:
The closest counter for the given point.
"""
return counters[
......
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