Skip to content

Commit

Permalink
Fix edge cases caught by pylint
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 637869856
Change-Id: Ida1bc9fe47ec76eef11c0dd157f8b58158782a66
  • Loading branch information
jagapiou authored and Copybara-Service committed May 28, 2024
1 parent 957ce59 commit 1f795b1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,17 @@ def create_avatar_objects(
if player_idx % 2 == 0:
row_player = True
color = (50, 100, 200)
elif player_idx % 2 == 1:
else:
row_player = False
color = (200, 100, 50)
elif role == "bach_fan":
row_player = True
color = (50, 100, 200)
elif role == "stravinsky_fan":
row_player = False
color = (200, 100, 50)
else:
if role == "bach_fan":
row_player = True
color = (50, 100, 200)
elif role == "stravinsky_fan":
row_player = False
color = (200, 100, 50)
raise ValueError(f"Unsupported role: {role}")
avatar = create_avatar_object(player_idx, color, row_player)
avatar_objects.append(avatar)
readiness_marker = the_matrix.create_ready_to_interact_marker(player_idx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,17 @@ def create_avatar_objects(
if player_idx % 2 == 0:
row_player = True
color = (50, 100, 200)
elif player_idx % 2 == 1:
else:
row_player = False
color = (200, 100, 50)
elif role == "bach_fan":
row_player = True
color = (50, 100, 200)
elif role == "stravinsky_fan":
row_player = False
color = (200, 100, 50)
else:
if role == "bach_fan":
row_player = True
color = (50, 100, 200)
elif role == "stravinsky_fan":
row_player = False
color = (200, 100, 50)
raise ValueError(f"Unsupported role: {role}")

avatar = create_avatar_object(player_idx, color, row_player)
avatar_objects.append(avatar)
Expand Down
11 changes: 6 additions & 5 deletions meltingpot/configs/substrates/fruit_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,13 +1160,14 @@ def create_avatar_objects(roles: Sequence[str],
# farmers and odd numbered players to be apple farmers.
if player_idx % 2 == 1:
specialty = "apple"
elif player_idx % 2 == 0:
else:
specialty = "banana"
elif role == "apple_farmer":
specialty = "apple"
elif role == "banana_farmer":
specialty = "banana"
else:
if role == "apple_farmer":
specialty = "apple"
elif role == "banana_farmer":
specialty = "banana"
raise ValueError(f"Unsupported role: {role}")
game_object = create_avatar_object(player_idx,
specialty,
max_stamina_bar_states - 1)
Expand Down
6 changes: 5 additions & 1 deletion meltingpot/configs/substrates/paintball__capture_the_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ def create_flag_prefab(team: str):
flag_color = RED_COLOR
elif team == "blue":
flag_color = BLUE_COLOR
else:
raise ValueError(f"Unsupported team : {team}")

prefab = {
"name": "{}_flag".format(team),
Expand Down Expand Up @@ -714,7 +716,7 @@ def _even_vs_odd_team_assignment(num_players,
for player_idx in range(0, num_players):
if player_idx % 2 == 0:
team = "red"
elif player_idx % 2 == 1:
else:
team = "blue"
game_object = create_avatar_object(player_idx, team,
override_taste_kwargs=taste_kwargs)
Expand All @@ -733,6 +735,8 @@ def _low_vs_high_team_assignment(num_players,
team = "blue"
elif player_idx > median:
team = "red"
else:
raise ValueError("num_players must be even")
game_object = create_avatar_object(player_idx, team,
override_taste_kwargs=taste_kwargs)
avatar_objects.append(game_object)
Expand Down
4 changes: 3 additions & 1 deletion meltingpot/configs/substrates/paintball__king_of_the_hill.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def _even_vs_odd_team_assignment(num_players,
for player_idx in range(0, num_players):
if player_idx % 2 == 0:
team = "red"
elif player_idx % 2 == 1:
else:
team = "blue"
game_object = create_avatar_object(player_idx, team,
override_taste_kwargs=taste_kwargs)
Expand All @@ -713,6 +713,8 @@ def _low_vs_high_team_assignment(num_players,
team = "blue"
elif player_idx > median:
team = "red"
else:
raise ValueError("num_players must be even")
game_object = create_avatar_object(player_idx, team,
override_taste_kwargs=taste_kwargs)
avatar_objects.append(game_object)
Expand Down
10 changes: 2 additions & 8 deletions meltingpot/configs/substrates/reaction_graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,9 @@ def create_cell_prefab(compound_name, compounds, reactivity_levels,

if sprites:
def get_palette(sprite_color):
if len(sprite_color) == 3:
x_color = EMPTY_COLOR[0:3]
a_color = (252, 252, 252)
elif len(sprite_color) == 4:
x_color = EMPTY_COLOR
a_color = (252, 252, 252, 255)
return {
"x": x_color,
"a": a_color,
"x": EMPTY_COLOR[0:len(sprite_color)],
"a": (252,) * len(sprite_color),
"b": sprite_color,
"c": multiply_tuple(sprite_color, 0.2),
"d": sprite_color
Expand Down

0 comments on commit 1f795b1

Please sign in to comment.