本文整理匯總了Python中game_of_life.GameOfLife.set_alive_cells方法的典型用法代碼示例。如果您正苦於以下問題:Python GameOfLife.set_alive_cells方法的具體用法?Python GameOfLife.set_alive_cells怎麽用?Python GameOfLife.set_alive_cells使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類game_of_life.GameOfLife
的用法示例。
在下文中一共展示了GameOfLife.set_alive_cells方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestGameOfLife
# 需要導入模塊: from game_of_life import GameOfLife [as 別名]
# 或者: from game_of_life.GameOfLife import set_alive_cells [as 別名]
class TestGameOfLife(unittest.TestCase):
def setUp(self):
self.game_of_life = GameOfLife()
self._cells_alive = None
def tearDown(self):
self._cells_alive = None
self.game_of_life = None
def test_any_live_cell_with_fewer_than_two_live_neighbours_dies_example_1(self):
self.game_of_life.set_alive_cells(((0, 0),))
self._assert_cells_are_dead_in_next_generation((0, 0))
def test_any_live_cell_with_fewer_than_two_live_neighbours_dies_example_2(self):
self.game_of_life.set_alive_cells(((0, 0), (0, 1)))
self._assert_cells_are_dead_in_next_generation(((0, 0), (0, 1)))
def test_any_live_cell_with_fewer_than_two_live_neighbours_dies_example_3(self):
self.game_of_life.set_alive_cells(((0, 0),
(1, 0)))
self._assert_cells_are_dead_in_next_generation(((0, 0),
(1, 0)))
def test_any_live_cell_with_more_than_three_live_neighbours_dies_example_1(self):
self.game_of_life.set_alive_cells(( (0, 1),
(1, 0), (1, 1), (1, 2),
(2, 1)))
self._assert_cells_are_dead_in_next_generation((1, 1))
def test_any_live_cell_with_more_than_three_live_neighbours_dies_example_2(self):
self.game_of_life.set_alive_cells(((0, 0), (0, 1),
(1, 0), (1, 1), (1, 2),
(2, 1)))
self._assert_cells_are_dead_in_next_generation((1, 1))
def test_any_live_cell_with_more_than_three_live_neighbours_dies_example_3(self):
self.game_of_life.set_alive_cells(((0, 0), (0, 1), (0, 2),
(1, 0), (1, 1), (1, 2),
(2, 1)))
self._assert_cells_are_dead_in_next_generation((1, 1))
def test_any_live_cell_with_more_than_three_live_neighbours_dies_example_4(self):
self.game_of_life.set_alive_cells(((0, 0), (0, 1), (0, 2),
(1, 0), (1, 1), (1, 2),
(2, 0), (2, 1)))
self._assert_cells_are_dead_in_next_generation((1, 1))
def test_any_live_cell_with_more_than_three_live_neighbours_dies_example_5(self):
self.game_of_life.set_alive_cells(((0, 0), (0, 1), (0, 2),
(1, 0), (1, 1), (1, 2),
(2, 0), (2, 1), (2, 2)))
self._assert_cells_are_dead_in_next_generation((1, 1))
def test_any_live_cell_with_two_or_three_live_neighbours_lives_on_example_1(self):
self.game_of_life.set_alive_cells(( (0, 1),
(1, 0), (1, 2),
(2, 1)))
self._assert_cells_are_alive_in_next_generation(( (0, 1),
(1, 0), (1, 2),
(2, 1)))
def test_any_live_cell_with_two_or_three_live_neighbours_lives_on_example_2(self):
self.game_of_life.set_alive_cells(( (0, 1),
(1, 0), (1, 1), (1, 2),
(2, 1)))
self._assert_cells_are_alive_in_next_generation(( (0, 1),
(1, 0), (1, 2),
(2, 1)))
def test_any_dead_cell_with_exactly_three_live_neighbours_becomes_alive(self):
self.game_of_life.set_alive_cells(( (0, 1),
(1, 0), (1, 1), (1, 2),
(2, 1)))
self._assert_cells_are_alive_in_next_generation(((0, 0), (0, 2),
(2, 0), (2, 2)))
def test_suggested_example(self):
self.game_of_life.set_alive_cells(( (1, 4),
(2, 3), (2, 4)))
self._assert_exactly_these_cells_are_alive_in_next_generation(
((1, 3), (1, 4),
(2, 3), (2, 4)))
def test_oscillation(self):
initially_alive_cells = ((0, 0), (0, 1), (0, 2))
self.game_of_life.set_alive_cells(initially_alive_cells)
self._assert_exactly_these_cells_are_alive_in_next_generation(
((-1, 1),
( 0, 1),
( 1, 1)))
self._assert_exactly_these_cells_are_alive_in_next_generation(initially_alive_cells)
def test_glider(self):
self.game_of_life.set_alive_cells(
( (0, 1),
(1, 2),
(2, 0), (2, 1), (2, 2)))
self._assert_exactly_these_cells_are_alive_in_next_generation(
(
#.........這裏部分代碼省略.........