From b83ba205c42e5676c9fe18ce14a6a2344236ed7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Schr=C3=B6der?= <fschroeder@techfak.uni-bielefeld.de> Date: Fri, 9 Feb 2024 14:47:17 +0100 Subject: [PATCH] Add drop-off interaction with cooking equipment The code now includes a new hook called 'drop_off_on_cooking_equipment'. This hook is used to track and score instances of players dropping off items on the cooking equipment in the Overcooked game simulator. This enhancement will allow for more detailed game simulations and scoring capabilities. --- overcooked_simulator/counters.py | 7 +++++++ .../game_content/environment_config_rl.yaml | 8 +++++++- overcooked_simulator/hooks.py | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/overcooked_simulator/counters.py b/overcooked_simulator/counters.py index 8ce066ab..2923aa71 100644 --- a/overcooked_simulator/counters.py +++ b/overcooked_simulator/counters.py @@ -61,6 +61,7 @@ from overcooked_simulator.hooks import ( DROP_ON_SINK_ADDON, PICK_UP_FROM_SINK_ADDON, PLATE_OUT_OF_KITCHEN_TIME, + DROP_OFF_ON_COOKING_EQUIPMENT, ) if TYPE_CHECKING: @@ -197,6 +198,12 @@ class Counter: if self.occupied_by is None: self.occupied_by = item elif self.occupied_by.can_combine(item): + self.hook( + DROP_OFF_ON_COOKING_EQUIPMENT, + item=item, + equipment=self.occupied_by, + counter=self, + ) return self.occupied_by.combine(item) return None diff --git a/overcooked_simulator/game_content/environment_config_rl.yaml b/overcooked_simulator/game_content/environment_config_rl.yaml index 1b32b457..1d7d6ec1 100644 --- a/overcooked_simulator/game_content/environment_config_rl.yaml +++ b/overcooked_simulator/game_content/environment_config_rl.yaml @@ -123,7 +123,13 @@ extra_setup_functions: callback_class: !!python/name:overcooked_simulator.scores.ScoreViaHooks '' callback_class_kwargs: static_score: -1 - + combine: + func: !!python/name:overcooked_simulator.hooks.hooks_via_callback_class '' + kwargs: + hooks: [ drop_off_on_cooking_equipment ] + callback_class: !!python/name:overcooked_simulator.scores.ScoreViaHooks '' + callback_class_kwargs: + static_score: 20 # json_states: # func: !!python/name:overcooked_simulator.recording.class_recording_with_hooks '' # kwargs: diff --git a/overcooked_simulator/hooks.py b/overcooked_simulator/hooks.py index fc79f8e3..503f0874 100644 --- a/overcooked_simulator/hooks.py +++ b/overcooked_simulator/hooks.py @@ -107,6 +107,8 @@ ACTION_PUT = "action_put" ACTION_INTERACT_START = "action_interact_start" +DROP_OFF_ON_COOKING_EQUIPMENT = "drop_off_on_cooking_equipment" + class Hooks: def __init__(self, env): -- GitLab