From 885a516fe33cd074057bc4bb4d13a97bbd2b33de Mon Sep 17 00:00:00 2001 From: Simon Pirkelmann Date: Fri, 10 Sep 2021 01:22:17 +0200 Subject: [PATCH] implemented won text and set consistent seed --- gauss-turing/game/gauss_turing.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gauss-turing/game/gauss_turing.py b/gauss-turing/game/gauss_turing.py index 97823df..0b8940d 100644 --- a/gauss-turing/game/gauss_turing.py +++ b/gauss-turing/game/gauss_turing.py @@ -290,7 +290,7 @@ class Game: # TODO fix number of commands at 5 self.cmds = [Command('forward'), Command('left', color=RED), Command('left', color=BLUE), Command('P0'), Command('-')] - self.state = 'game_over' + self.state = 'won' self.prg = Program(self.robot, self.board, self.cmds) @@ -303,7 +303,7 @@ class Game: int((self.board.tiles.shape[0] + 2) * self.scale_fac * 1.2))) self.game_over_text = myfont.render('GAME OVER', False, BLACK) - self.won_text = myfont.render('YOU WON', False, GREEN) + self.won_text = myfont.render('YOU WON', False, BLACK) self.run_text = myfont.render('RUN', False, tuple(BLACK)) self.stop_text = myfont_small.render('STOP', False, tuple(BLACK)) self.step_text = myfont_small.render('STEP', False, tuple(BLACK)) @@ -382,7 +382,12 @@ class Game: pygame.time.wait(1500) self.state = 'reset' elif self.state == 'won': - self.screen.blit(self.won_text, (50, 00)) + won_surf = pygame.Surface((self.screen.get_width() // 2, self.screen.get_height() // 2)) + won_surf.fill(tuple(GREEN)) + won_surf.blit(self.won_text, + ((won_surf.get_width() - self.won_text.get_width()) // 2, + (won_surf.get_height() - self.won_text.get_height()) // 2)) + self.screen.blit(won_surf, (self.screen.get_width() // 4, self.screen.get_height() // 4)) pygame.display.update() pygame.time.wait(1500) self.state = 'reset' @@ -483,7 +488,9 @@ class Game: pygame.time.wait(100) if __name__ == "__main__": - random.seed(42) + seed = 2 + random.seed(seed) + np.random.seed(seed) game = Game(dimx=7, dimy=4, robotx=3, roboty=1) game.run()