From 9b484700112a19bc7a5dd4396f7180333eb50eaf Mon Sep 17 00:00:00 2001 From: Islam Elnabarawy Date: Mon, 24 Jun 2019 16:12:31 -0500 Subject: [PATCH] Add worker and army counts to render display --- sc2/renderer.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sc2/renderer.py b/sc2/renderer.py index e7523691c..7e72d5ae1 100644 --- a/sc2/renderer.py +++ b/sc2/renderer.py @@ -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 @@ -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) @@ -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, @@ -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()