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

Add recipe graph and info to cooperative cuisine

Recipe graphs now include the names of 'interactive_counter' and 'equipment' in Cooperative Cuisine. Updated the random agent to also receive recipe graphs information. These changes were implemented to enhance functionality and efficiently retrieve required information.
parent 182a4708
No related branches found
No related tags found
No related merge requests found
Pipeline #50667 passed
......@@ -13,6 +13,9 @@
### Added
- Recipe graphs contain the names of the interactive counters and equipment
- Random agent also gets the recipe graph information.
### Changed
- `CooperativeCuisine` occurrences to `Cooperative Cuisine`
......@@ -23,6 +26,8 @@
### Fixed
- Random Order generation does not depend on other sampling of random numbers.
### Security
## [1.1.1] (2024-04-03)
......
......@@ -50,10 +50,12 @@ async def agent():
parser.add_argument("--player_id", type=str)
parser.add_argument("--player_hash", type=str)
parser.add_argument("--step_time", type=float, default=0.1)
parser.add_argument("--recipe_graph", type=str, default="")
args = parser.parse_args()
async with (connect(args.uri) as websocket):
recipe_graph = json.loads(args.recipe_graph)
await websocket.send(
json.dumps({"type": "ready", "player_hash": args.player_hash})
)
......
......@@ -1756,6 +1756,7 @@ class PyGameGUI:
f'--uri {player_info["websocket_url"]}',
f"--player_hash {player_hash}",
f"--player_id {player_id}",
f"--recipe_graph '{json.dumps(self.level_info['recipe_graphs'])}'",
]
),
shell=True,
......
......@@ -34,6 +34,9 @@ class MealGraphDict(TypedDict):
"""A dictionary mapping cooking step names to their layout coordinates."""
score: float
"""The max possible score of the meal."""
info: dict[str, list[str]]
"""The names of the `interactive_counter` and `equipment` (not the ids of the individual). Is not reduced to the
meal."""
class Validation:
......@@ -70,6 +73,21 @@ class Validation:
self.recipe_graph_dicts: dict | None = None
"""A dictionary containing recipe graphs for each meal. For visualisation of the recipes."""
self.interactive_counter = [
c
for c in self.item_info
if self.item_info[c].type == ItemType.Equipment
and not self.item_info[c].equipment
]
"""The list of names of stationary mentioned equipments like stove, cutting board but not pot etc."""
self.equipments = [
eq
for eq in self.item_info
if self.item_info[eq].type == ItemType.Equipment
and self.item_info[eq].equipment
]
"""The list of names of the equipments in the environment."""
@staticmethod
def infer_recipe_graph(item_info) -> DiGraph:
"""Generate a graph from ingredients and meals and their dependencies.
......@@ -210,6 +228,10 @@ class Validation:
"edges": list(graph.edges),
"layout": layout,
"score": score,
"info": {
"interactive_counter": self.interactive_counter,
"equipment": self.equipments,
},
}
with open(generated_graph_layouts_path, "w") as f:
self.recipe_graph_dicts[graph_hash] = graph_dict
......
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