diff --git a/overcooked_simulator/gui_2d_vis/drawing.py b/overcooked_simulator/gui_2d_vis/drawing.py index 56b63bc0603b076cb08342b13238d90596bdc7b4..ab6f706063a63b6e5c2368c63ae60f070543af00 100644 --- a/overcooked_simulator/gui_2d_vis/drawing.py +++ b/overcooked_simulator/gui_2d_vis/drawing.py @@ -92,8 +92,10 @@ class Visualizer: ) if "view_restriction" in state and state["view_restriction"]: - direction = state["view_restriction"][0] - angel = state["view_restriction"][1] + direction = np.array(state["view_restriction"][0]) + pos = np.array(state["view_restriction"][1]) + angel = state["view_restriction"][2] + # rotate direction vector in both direction with the angel # draw 2 large rect which are rotated so that one edge is the viewing border diff --git a/overcooked_simulator/overcooked_environment.py b/overcooked_simulator/overcooked_environment.py index 64757f8c2b6fe36bcb4b4d4090048f05891f4dc7..fc7cbc1cbf4e1d9573e140624b6ea9ba0652c744 100644 --- a/overcooked_simulator/overcooked_environment.py +++ b/overcooked_simulator/overcooked_environment.py @@ -622,6 +622,7 @@ class Environment: ).total_seconds(), "view_restriction": [ self.players[player_id].facing_direction.tolist(), + self.players[player_id].pos.tolist(), 40.0, ] if FOG_OF_WAR diff --git a/overcooked_simulator/utils.py b/overcooked_simulator/utils.py index edf11d72e8b4a5cbaa8672d9da727d6e4d3c312f..bb0fac2a6fd55e19c037cdefeea37328f8f9e53c 100644 --- a/overcooked_simulator/utils.py +++ b/overcooked_simulator/utils.py @@ -100,3 +100,9 @@ def add_list_of_manager_ids_arguments(parser): default=[uuid.uuid4().hex], help="List of manager IDs that can create environments.", ) + + +def angle_between(p1, p2): + ang1 = np.arctan2(*p1[::-1]) + ang2 = np.arctan2(*p2[::-1]) + return np.rad2deg((ang1 - ang2) % (2 * np.pi))