diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 759e25139695f6f699e0168e9c4a3d97b3e2c886..06424229295ebdb3a3bb77fd9da41a1eab1d1299 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ pages: - apt-get update -qy - apt-get install -y python3-dev python3-pip graphviz graphviz-dev - pip install pdoc - - pip install ".[rl]" + - pip install . - pdoc --output-dir public cooperative_cuisine !cooperative_cuisine.reinforcement_learning --logo https://gitlab.ub.uni-bielefeld.de/uploads/-/system/project/avatar/6780/Cooking-Vector-Illustration-Icon-Graphics-4267218-1-580x435.jpg --docformat google --favicon overcooked-simulator/cooperative_cuisine/pygame_2d_vis/images/favicon.ico --footer-text "Developed@SCS" artifacts: paths: diff --git a/cooperative_cuisine/hooks.py b/cooperative_cuisine/hooks.py index 06b7a53dbf0c0f7e3a6b9963cbfe32867976fec8..9435c432e484dc917bfb2f40201a3ca55df82c19 100644 --- a/cooperative_cuisine/hooks.py +++ b/cooperative_cuisine/hooks.py @@ -199,6 +199,7 @@ class HookCallbackClass: - The **kwargs parameter allows for additional arguments to be passed to the callback function. Usage Example: + ```python # Create an instance of HookCallbackClass callback = HookCallbackClass("my_callback", my_env) @@ -212,11 +213,14 @@ class HookCallbackClass: # Call the callback my_callback("hook_reference", my_env) + ``` """ def __init__(self, name: str, env: Environment, **kwargs): self.name = name + """The name of the callback.""" self.env = env + """Reference to the environment.""" @abstractmethod def __call__(self, hook_ref: str, env: Environment, **kwargs): @@ -245,6 +249,25 @@ def hooks_via_callback_class( def add_dummy_callbacks(env): + """Checking the hooks-callback functionality. + + Args: + env: The environment object that represents the system environment. + + This method adds dummy callbacks to the given environment object. Each callback is registered for a specific hook using the `register_callback_for_hook` method of the environment. + + The callbacks are defined using the `partial` function from the `functools` module. This allows us to pass additional arguments to the callback while registering it. The `print_hook + *_callback` function is used as the callback function, and it prints a message to the console. + + Here are the hooks and corresponding messages that are registered: + + 1. SERVE_NOT_ORDERED_MEAL: Prints the message "You tried to serve a meal that was not ordered!" + 2. SINK_START_INTERACT: Prints the message "You started to use the Sink!" + 3. COMPLETED_ORDER: Prints the message "You completed an order!" + 4. TRASHCAN_USAGE: Prints the message "You used the trashcan!" + + These dummy callbacks can be used for testing or demonstration purposes. + """ env.register_callback_for_hook( SERVE_NOT_ORDERED_MEAL, partial( diff --git a/cooperative_cuisine/pygame_2d_vis/__init__.py b/cooperative_cuisine/pygame_2d_vis/__init__.py index f76fc15e4010460e9cb062aadf330b36249c7935..c5a1185e214dc7d99eb02ebc704666bfbfa44041 100644 --- a/cooperative_cuisine/pygame_2d_vis/__init__.py +++ b/cooperative_cuisine/pygame_2d_vis/__init__.py @@ -2,9 +2,11 @@ 2D visualization of the CooperativeCuisine. You can select the layout and start an environment: -- You can play the CooperativeCuisine. You can quit the application in the top right or end the level in the bottom right: [Screenshot](https://gitlab.ub.uni-bielefeld.de/scs/cocosy/overcooked-simulator/-/raw/main/overcooked_simulator/pygame_2d_vis/images/overcooked-start-screen.png?ref_type=heads) -- The orders are pictured in the top, the current score in the bottom left and the remaining time in the bottom: [Screenshot](https://gitlab.ub.uni-bielefeld.de/scs/cocosy/overcooked-simulator/-/raw/main/overcooked_simulator/pygame_2d_vis/images/overcooked-level-screen.png?ref_type=heads) -- The final screen after ending a level shows the score: [Screenshot](https://gitlab.ub.uni-bielefeld.de/scs/cocosy/overcooked-simulator/-/raw/main/overcooked_simulator/pygame_2d_vis/images/overcooked-end-screen.png?ref_type=heads) +- 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 + +.. include:: images/images_md_for_docs.md The keys for the control of the players are: @@ -12,9 +14,12 @@ The keys for the control of the players are: - Movement: `W`, `A`, `S`, `D`, - Pickup: `E` - Interact: `F` +- Swap Players (if configured): `SPACE` ### Player 2: - Movement: `⬆`, `⬅`, `⬇`, `➡` (arrow keys) - Pickup: `I` -- Interact: `SPACE` +- Interact: `O` +- Swap Players (if configured): `P` + """ diff --git a/cooperative_cuisine/pygame_2d_vis/images/images_md_for_docs.md b/cooperative_cuisine/pygame_2d_vis/images/images_md_for_docs.md new file mode 100644 index 0000000000000000000000000000000000000000..2870f1a15541f0eeb0298731962361f9daf9201a --- /dev/null +++ b/cooperative_cuisine/pygame_2d_vis/images/images_md_for_docs.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/cooperative_cuisine/pygame_2d_vis/images/overcooked-end-screen.png b/cooperative_cuisine/pygame_2d_vis/images/overcooked-end-screen.png deleted file mode 100644 index d678687d61277930d839882aa5f6956caeb5e9a6..0000000000000000000000000000000000000000 Binary files a/cooperative_cuisine/pygame_2d_vis/images/overcooked-end-screen.png and /dev/null differ diff --git a/cooperative_cuisine/pygame_2d_vis/images/overcooked-level-screen.png b/cooperative_cuisine/pygame_2d_vis/images/overcooked-level-screen.png deleted file mode 100644 index 0f2cc384aacabcd80d3b88542fd9a3345506b35d..0000000000000000000000000000000000000000 Binary files a/cooperative_cuisine/pygame_2d_vis/images/overcooked-level-screen.png and /dev/null differ diff --git a/cooperative_cuisine/pygame_2d_vis/images/overcooked-start-screen.png b/cooperative_cuisine/pygame_2d_vis/images/overcooked-start-screen.png deleted file mode 100644 index 420d1eedb6cf57a493aba7dbabe7e3ba80ecb1b4..0000000000000000000000000000000000000000 Binary files a/cooperative_cuisine/pygame_2d_vis/images/overcooked-start-screen.png and /dev/null differ diff --git a/cooperative_cuisine/recording.py b/cooperative_cuisine/recording.py index 8ed83ce2d24c649587e808620beb6d673b055d82..10597e8040674dcb85008c4e6a82a26b56613f31 100644 --- a/cooperative_cuisine/recording.py +++ b/cooperative_cuisine/recording.py @@ -78,9 +78,11 @@ class FileRecorder(HookCallbackClass): ): super().__init__(name, env, **kwargs) self.add_hook_ref = add_hook_ref + """If the name of the hook (the reference) should be included in the recording.""" log_path = log_path.replace("LOG_RECORD_NAME", name) log_path = Path(expand_path(log_path, env_name=env.env_name)) self.log_path = log_path + """The path to the recording file.""" log.info(f"Recorder record for {name} in file://{log_path}") os.makedirs(log_path.parent, exist_ok=True) diff --git a/cooperative_cuisine/scores.py b/cooperative_cuisine/scores.py index b0f968bd7cfc3d2e44bafd91827b7d4ba3e7ccab..b8cd11b739d66c2b59b37a15b49ed02e198dd379 100644 --- a/cooperative_cuisine/scores.py +++ b/cooperative_cuisine/scores.py @@ -84,9 +84,13 @@ class ScoreViaHooks(HookCallbackClass): ): super().__init__(name, env, **kwargs) self.score_map = score_map + """Mapping of hook references to scores.""" self.static_score = static_score + """The static score to be added if no other conditions are met.""" self.kwarg_filter = kwarg_filter + """Filtering condition for keyword arguments.""" self.score_on_specific_kwarg = score_on_specific_kwarg + """The specific keyword argument to score on.""" def __call__(self, hook_ref: str, env: Environment, **kwargs): if self.score_on_specific_kwarg: