Exemple #1
0
 def test_step__line_of_sight_policy(self):
     grid = ['L.L.#']
     next_grid = ['#.L.#']
     g = GameOfLife(grid,
                    extinction_threshold=4,
                    neighbour_policy='line-of-sight')
     self.assertEqual(g.step(), next_grid)
Exemple #2
0
 def test_step__new_life(self):
     grid = ['L.#', 'L.#', '#..']
     next_grid = ['#.#', 'L.#', '#..']
     g = GameOfLife(grid,
                    extinction_threshold=4,
                    neighbour_policy='adjacent')
     self.assertEqual(g.step(), next_grid)
Exemple #3
0
 def test_step__some_die(self):
     grid = ['.#.', '###', '.#.']
     next_grid = ['.#.', '#L#', '.#.']
     g = GameOfLife(grid,
                    extinction_threshold=4,
                    neighbour_policy='adjacent')
     self.assertListEqual(g.step(), next_grid)
Exemple #4
0
def test_game_of_life_beacon():
    game = GameOfLife(beacon[0])

    for state in beacon[1:]:
        game.step()
        assert (game.board == state)
Exemple #5
0
def test_game_of_life_toad():
    game = GameOfLife(toad[0])

    for state in toad[1:]:
        game.step()
        assert (game.board == state)
Exemple #6
0
def test_game_of_life_blinker():
    game = GameOfLife(blinker[0])

    for state in blinker[1:]:
        game.step()
        assert (game.board == state)