diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc4d9c2dab3419e8b7eec4204c77bb310b61648..9f6bf5503f21c162a9fbf67a53d5839a88dd91bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ ### Added +- Recipe graphs contain the names of the interactive counters and equipment +- Random agent also gets the recipe graph information. + Hook SCORE_CHANGED when the score is increased. ### Changed @@ -25,6 +28,8 @@ Hook SCORE_CHANGED when the score is increased. ### Fixed +- Random Order generation does not depend on other sampling of random numbers. + ### Security ## [1.1.1] (2024-04-03) diff --git a/cooperative_cuisine/configs/agents/random_agent.py b/cooperative_cuisine/configs/agents/random_agent.py index 6d8830d94c5570bc6642936a0f34b47b94a8c8bc..506f2a633a6baf42733f8cc9bdfa39fa8bf48a0c 100644 --- a/cooperative_cuisine/configs/agents/random_agent.py +++ b/cooperative_cuisine/configs/agents/random_agent.py @@ -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}) ) diff --git a/cooperative_cuisine/environment.py b/cooperative_cuisine/environment.py index 6136356b3441d9df15c20ae0c2f203f1400c1a4f..1892ce4f8a3e5e9c85fa8434d1b8ba4483454b4c 100644 --- a/cooperative_cuisine/environment.py +++ b/cooperative_cuisine/environment.py @@ -217,7 +217,7 @@ class Environment: self.order_manager: OrderManager = OrderManager( order_config=self.environment_config["orders"], hook=self.hook, - random=self.random, + random=Random(seed), ) """The manager for the orders and score update.""" diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py index ee930dd51a76e0d0c7cc96f3fe17384c38e19121..b52fed387fa743f6d0096c9f6bf9979faa238899 100644 --- a/cooperative_cuisine/pygame_2d_vis/gui.py +++ b/cooperative_cuisine/pygame_2d_vis/gui.py @@ -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, diff --git a/cooperative_cuisine/validation.py b/cooperative_cuisine/validation.py index 111edaf73d760b87e97e053b6b55b83420ae578c..c87d208a2a320a0aa67fc6535aa1095686926c2d 100644 --- a/cooperative_cuisine/validation.py +++ b/cooperative_cuisine/validation.py @@ -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