Fixing bugs: Really dont touch screen when running on server

This commit is contained in:
Dominik Moritz Roth 2022-08-14 17:21:52 +02:00
parent 82a43b85d0
commit b490c8ffd9

View File

@ -66,7 +66,7 @@ class ColumbusEnv(gym.Env):
return self.rng.random() return self.rng.random()
def _ensure_surface(self): def _ensure_surface(self):
if not self.surface or self.visible and not self.screen: if not self.surface or not self.screen:
self.surface = pygame.Surface((self.width, self.height)) self.surface = pygame.Surface((self.width, self.height))
if self.visible: if self.visible:
self.screen = pygame.display.set_mode( self.screen = pygame.display.set_mode(
@ -296,8 +296,9 @@ class ColumbusEnv(gym.Env):
self._disturb_next = (1.0, 0.5) self._disturb_next = (1.0, 0.5)
def render(self, mode='human', dont_show=False, chol=None): def render(self, mode='human', dont_show=False, chol=None):
self._handle_user_input() if mode == 'human':
self.visible = self.visible or not dont_show self._handle_user_input()
self.visible = self.visible and not dont_show
self._ensure_surface() self._ensure_surface()
pygame.draw.rect(self.surface, (0, 0, 0), pygame.draw.rect(self.surface, (0, 0, 0),
pygame.Rect(0, 0, self.width, self.height)) pygame.Rect(0, 0, self.width, self.height))