当前位置: 首页>>代码示例>>Python>>正文


Python Life.moat_grid方法代码示例

本文整理汇总了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 = '-'
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:9,代码来源:TestLife.py

示例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 = '*'\
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:9,代码来源:TestLife.py

示例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])
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:32,代码来源:RunLife.py

示例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, '-')
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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, '.')
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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)
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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))	
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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))
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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))
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:8,代码来源:TestLife.py

示例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))
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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))
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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))
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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))
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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)
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py

示例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)
开发者ID:hyunji-seo,项目名称:cs313e-life,代码行数:7,代码来源:TestLife.py


注:本文中的Life.Life.moat_grid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。