def main(): # Initialisation de pygame pygame.init() # Creation d'un window builder builder = WindowBuilder(1000) builder.makeWindow() builder.createGrid() # Creation d'un modifier modifier = WindowModifier(builder.fenetre, builder.rect_width, builder.rect_height, builder.margin) # Controleur de la boucle continuer = True gameOn = False while continuer: for event in pygame.event.get(): if event.type == QUIT: continuer = False if event.type == MOUSEBUTTONDOWN and event.button == 1: modifier.modifyColors(event.pos[0], event.pos[1]) if event.type == KEYDOWN and event.key == K_SPACE: game = GameOfLife(modifier) gameOn = not gameOn if gameOn: game.nextGen() modifier.colors = game.colors time.sleep(0.3) modifier.redrawGrid()
def test_cell_with_less_than_two_neighbours_dies(self): expect = [[False, False, False], [False, False, False], [False, False, False]] board = [[False, False, False], [True, True, False], [False, False, False]] gameoflife = GameOfLife(board) gameoflife.nextGen() self.assertEqual(expect, gameoflife.board)
def test_cell_with_two_neighbours_lives(self): board = [[True, False, False], [False, True, False], [False, False, True]] expect = [[False, False, False], [False, True, False], [False, False, False]] gameoflife = GameOfLife(board) gameoflife.nextGen() self.assertEqual(expect, gameoflife.board)