diff --git a/cooperative_cuisine/pygame_2d_vis/drawing.py b/cooperative_cuisine/pygame_2d_vis/drawing.py index 0c67eaf1549e8e45510832cc5c9296591883715c..0bdd50c374fc59c9200b8c0e3336f0b8883ea308 100644 --- a/cooperative_cuisine/pygame_2d_vis/drawing.py +++ b/cooperative_cuisine/pygame_2d_vis/drawing.py @@ -22,10 +22,6 @@ from cooperative_cuisine.state_representation import ( EffectState, ) -USE_PLAYER_COOK_SPRITES = True -SHOW_INTERACTION_RANGE = False -SHOW_COUNTER_CENTERS = False - def calc_angle(vec_a: list[float], vec_b: list[float]) -> float: a = pygame.math.Vector2(vec_a) @@ -86,6 +82,22 @@ class Visualizer: self.fire_time_steps = 8 self.observation_screen = None + self.USE_PLAYER_COOK_SPRITES = ( + config["use_player_cook_sprites"] + if "use_player_cook_sprites" in config + else True + ) + self.SHOW_INTERACTION_RANGE = ( + config["show_interaction_range"] + if "show_interaction_range" in config + else False + ) + self.SHOW_COUNTER_CENTERS = ( + config["show_counter_centers"] + if "show_counter_centers" in config + else False + ) + def create_player_colors(self, n) -> None: """Create different colors for the players. The color hues are sampled uniformly in HSV-Space, then the corresponding colors from the defined colors list are looked up. @@ -329,7 +341,7 @@ class Visualizer: facing = np.array(player_dict["facing_direction"], dtype=float) - if USE_PLAYER_COOK_SPRITES: + if self.USE_PLAYER_COOK_SPRITES: pygame.draw.circle( screen, colors[self.player_colors[p_idx]], @@ -368,7 +380,7 @@ class Visualizer: ), ) - if SHOW_INTERACTION_RANGE: + if self.SHOW_INTERACTION_RANGE: pygame.draw.circle( screen, colors["blue"], @@ -753,7 +765,7 @@ class Visualizer: item=effect, ) - if SHOW_COUNTER_CENTERS: + if self.SHOW_COUNTER_CENTERS: pos = np.array(counter["pos"]) * grid_size pygame.draw.circle(screen, colors["green1"], pos, 3) pygame.draw.circle(screen, colors["green1"], pos, 3) diff --git a/cooperative_cuisine/pygame_2d_vis/visualization.yaml b/cooperative_cuisine/pygame_2d_vis/visualization.yaml index 0dc39c17f30086a999c7c9b18c9873810d4f580c..e52e34b0874c7af97efb7ffe213280c4db61f06e 100644 --- a/cooperative_cuisine/pygame_2d_vis/visualization.yaml +++ b/cooperative_cuisine/pygame_2d_vis/visualization.yaml @@ -1,5 +1,11 @@ # colors: https://www.webucator.com/article/python-color-constants-module/ +Gui: + use_player_cook_sprites: True + show_interaction_range: False + show_counter_centers: False + + GameWindow: screen_margin: 100 min_width: 900