本文整理汇总了Python中Life.Life.moat_grid方法的典型用法代码示例。如果您正苦于以下问题:Python Life.moat_grid方法的具体用法?Python Life.moat_grid怎么用?Python Life.moat_grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Life.Life
的用法示例。
在下文中一共展示了Life.moat_grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fut_curr_3
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_fut_curr_3(self):
x = Life(5, 3, [['-','-','-'], ['0','1','0'], ['0','-','-'], ['-','-','0'], ['*','0','-']])
x.future = '-'
x.moat_grid()
x.fut_curr()
x.grid[2][3].count = 0
x.grid[2][3].state = '-'
示例2: test_fut_curr_2
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_fut_curr_2(self):
x = Life(5, 3, [['.','.','.'], ['*','.','.'], ['*','*','*'], ['.','.','*'], ['.','.','*']])
x.future = '*'
x.moat_grid()
x.fut_curr()
x.grid[2][2].count = 0
x.grid[2][2].state = '*'\
示例3: print
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
import sys
from Life import Life, AbstractCell, ConwayCell, FredkinCell, life_read
# ---------------------
# Life ConwayCell 21x13
# ---------------------
print("*** Life ConwayCell 21x13 ***")
"""
Simulate 12 evolutions.
Print every grid (i.e. 0, 1, 2, 3, ... 12)
"""
row, col, grid = life_read(sys.stdin)
x = Life(row, col, grid)
x.moat_grid()
x.print_grid(12, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
# ---------------------
# Life ConwayCell 20x29
# ---------------------
print("*** Life ConwayCell 20x29 ***")
"""
Simulate 28 evolutions.
Print every 4th grid (i.e. 0, 4, 8, ... 28)
"""
row, col, grid = life_read(sys.stdin)
x = Life(row, col, grid)
x.moat_grid()
x.print_grid(28,[4,8,12,16,20,24,28])
示例4: test_future_4
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_future_4(self):
x = Life(5, 3, [['-','0','-'], ['-','-','-'], ['-','-','-'], ['-','-','-'], ['-','-','-']])
x.moat_grid()
x.count()
x.future()
self.assertEqual(x.grid[2][2].state, '-')
示例5: test_future_3
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_future_3(self):
x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','*','*'], ['.','.','*']])
x.moat_grid()
x.count()
x.future()
self.assertEqual(x.grid[2][3].state, '.')
示例6: test_count_3
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_count_3(self):
x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','.','*'], ['.','.','*']])
x.moat_grid()
x.count()
self.assertEqual(x.grid[1][2].count, 0)
示例7: test_is_self_3
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_is_self_3(self):
x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','.','*'], ['.','.','*']])
x.moat_grid()
row = 2
col = 4
self.assertEqual(True, x.is_self(row, col, 2, 4))
示例8: test_is_self_2
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_is_self_2(self):
x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','.','*'], ['.','.','*']])
x.moat_grid()
row = 1
col = 4
self.assertEqual(False, x.is_self(row, col, 1, 1))
示例9: test_is_self_1
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_is_self_1(self):
x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','.','*'], ['.','.','*']])
x.moat_grid()
row = 3
col = 3
self.assertEqual(True, x.is_self(row, col, 3, 3))
示例10: test_is_conway_6
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_is_conway_6(self):
x = Life(5, 3, [['0','0','0'], ['*','-','-'], ['-','-','*'], ['-','-','*'], ['-','-','*']])
x.moat_grid()
x.grid[0][0].type_cell = 'Conway'
self.assertEqual(True, x.is_conway(0, 0))
示例11: test_is_conway_5
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_is_conway_5(self):
x = Life(5, 3, [['0','0','0'], ['*','-','-'], ['-','-','*'], ['-','-','*'], ['-','-','*']])
x.moat_grid()
x.grid[2][3].type_cell = 'Fredkin'
self.assertEqual(False, x.is_conway(2, 3))
示例12: test_is_conway_2
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_is_conway_2(self):
x = Life(5, 3, [['.','.','.'], ['*','.','.'], ['*','*','*'], ['.','.','*'], ['.','.','*']])
x.moat_grid()
x.grid[2][3].type_cell = 'Conway'
self.assertEqual(True, x.is_conway(2, 3))
示例13: test_moat_grid_3
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_moat_grid_3(self):
x = Life(2, 2, [['.','.'], ['*','*']])
grid = len(x.grid)
x.moat_grid()
self.assertEqual(grid + 2, len(x.grid))
示例14: test_count_pop_3
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_count_pop_3(self):
x = Life(3, 10, [['.','.','*','.','.','.','.','.','*','.'], ['.','.','.','.','.','.','.','.','.','*'], ['.','.','*','.','.','*','*','.','.','*']])
x.moat_grid()
x.count_pop()
self.assertEqual(x.population, 7)
示例15: test_count_pop_1
# 需要导入模块: from Life import Life [as 别名]
# 或者: from Life.Life import moat_grid [as 别名]
def test_count_pop_1(self):
x = Life(2, 15, [['.','.','*','.','.','.','.','.','*','.','.','.','.','.','.'], ['.','-','.','.','.','.','.','.','.','*','.','.','.','.','.']])
x.moat_grid()
x.count_pop()
self.assertEqual(x.population, 3)