Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion sc2/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def __init__(self, client, map_size, minimap_size) -> None:
self._text_minerals = None
self._text_score = None
self._text_time = None
self._text_workers = None
self._text_army = None

async def render(self, observation):
render_data = observation.observation.render_data
Expand Down Expand Up @@ -67,7 +69,15 @@ async def render(self, observation):
)
self._text_time = Label(
'', font_name='Arial', font_size=16, anchor_x='right', anchor_y='bottom',
x=self._minimap_size[0] - 10, y=self._minimap_size[1] + 10, color=(255, 255, 255, 255)
x=self._minimap_size[0] - 10, y=self._minimap_size[1] + 10, color=(180, 180, 180, 255)
)
self._text_workers = Label(
'', font_name='Arial', font_size=16, anchor_x='left', anchor_y='bottom',
x=10, y=self._minimap_size[1] + 35, color=(180, 180, 180, 255)
)
self._text_army = Label(
'', font_name='Arial', font_size=16, anchor_x='left', anchor_y='bottom',
x=10, y=self._minimap_size[1] + 10, color=(180, 180, 180, 255)
)
else:
self._map_image.set_data('RGB', map_pitch, map_data)
Expand All @@ -78,6 +88,10 @@ async def render(self, observation):
observation.observation.player_common.food_cap)
self._text_vespene.text = str(observation.observation.player_common.vespene)
self._text_minerals.text = str(observation.observation.player_common.minerals)
self._text_workers.text = "Workers: {} ({} idle)".format(
observation.observation.player_common.food_workers,
observation.observation.player_common.idle_worker_count)
self._text_army.text = "Army: {}".format(observation.observation.player_common.army_count)
if observation.observation.HasField('score'):
self._text_score.text = "{} score: {}".format(
score_pb._SCORE_SCORETYPE.values_by_number[observation.observation.score.score_type].name,
Expand All @@ -103,6 +117,8 @@ async def _update_window(self):
self._text_minerals.draw()
self._text_vespene.draw()
self._text_supply.draw()
self._text_workers.draw()
self._text_army.draw()

self._window.flip()

Expand Down