Beispiel #1
0
    def test_step_rule_4(self):
        initial_state = [[0, 1, 0], [0, 1, 1], [0, 0, 0]]
        next_state = np.array([[0, 1, 1], [0, 1, 1], [0, 0, 0]])

        game = GameOfLife(initial_state=initial_state)
        game.step()
        game_state = game.get_state()
        self.assertTrue(np.array_equal(game_state, next_state))
Beispiel #2
0
    def test_run(self):
        initial_state = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
        final_state = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])

        game = GameOfLife(initial_state=initial_state)
        game.run(generations=2)
        game_state = game.get_state()
        self.assertTrue(np.array_equal(game_state, final_state))