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

Merge branch '117-put-drawing-constants-in-vis-config' into 'dev'

Resolve "Put drawing constants in vis config"

Closes #117

See merge request scs/cocosy/overcooked-simulator!83
parents a1f34c47 af78587a
No related branches found
No related tags found
1 merge request!83Resolve "Put drawing constants in vis config"
Pipeline #48656 passed
...@@ -22,10 +22,6 @@ from cooperative_cuisine.state_representation import ( ...@@ -22,10 +22,6 @@ from cooperative_cuisine.state_representation import (
EffectState, 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: def calc_angle(vec_a: list[float], vec_b: list[float]) -> float:
a = pygame.math.Vector2(vec_a) a = pygame.math.Vector2(vec_a)
...@@ -86,6 +82,22 @@ class Visualizer: ...@@ -86,6 +82,22 @@ class Visualizer:
self.fire_time_steps = 8 self.fire_time_steps = 8
self.observation_screen = None 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: def create_player_colors(self, n) -> None:
"""Create different colors for the players. The color hues are sampled uniformly in HSV-Space, """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. then the corresponding colors from the defined colors list are looked up.
...@@ -329,7 +341,7 @@ class Visualizer: ...@@ -329,7 +341,7 @@ class Visualizer:
facing = np.array(player_dict["facing_direction"], dtype=float) facing = np.array(player_dict["facing_direction"], dtype=float)
if USE_PLAYER_COOK_SPRITES: if self.USE_PLAYER_COOK_SPRITES:
pygame.draw.circle( pygame.draw.circle(
screen, screen,
colors[self.player_colors[p_idx]], colors[self.player_colors[p_idx]],
...@@ -368,7 +380,7 @@ class Visualizer: ...@@ -368,7 +380,7 @@ class Visualizer:
), ),
) )
if SHOW_INTERACTION_RANGE: if self.SHOW_INTERACTION_RANGE:
pygame.draw.circle( pygame.draw.circle(
screen, screen,
colors["blue"], colors["blue"],
...@@ -753,7 +765,7 @@ class Visualizer: ...@@ -753,7 +765,7 @@ class Visualizer:
item=effect, item=effect,
) )
if SHOW_COUNTER_CENTERS: if self.SHOW_COUNTER_CENTERS:
pos = np.array(counter["pos"]) * grid_size pos = np.array(counter["pos"]) * grid_size
pygame.draw.circle(screen, colors["green1"], pos, 3) pygame.draw.circle(screen, colors["green1"], pos, 3)
pygame.draw.circle(screen, colors["green1"], pos, 3) pygame.draw.circle(screen, colors["green1"], pos, 3)
......
# colors: https://www.webucator.com/article/python-color-constants-module/ # 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: GameWindow:
screen_margin: 100 screen_margin: 100
min_width: 900 min_width: 900
......
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