Ejemplo n.º 1
0
	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 = '-'
Ejemplo n.º 2
0
	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 = '*'\
Ejemplo n.º 3
0
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])
Ejemplo n.º 4
0
	def test_future_4(self):
		x = Life(5, 3, [['-','0','-'], ['-','-','-'], ['-','-','-'], ['-','-','-'], ['-','-','-']])
		x.moat_grid()
		x.count()
		x.future()
		self.assertEqual(x.grid[2][2].state, '-')
Ejemplo n.º 5
0
	def test_future_3(self):
		x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','*','*'], ['.','.','*']])
		x.moat_grid()
		x.count()
		x.future()
		self.assertEqual(x.grid[2][3].state, '.')
Ejemplo n.º 6
0
	def test_count_3(self):
		x = Life(5, 3, [['.','*','.'], ['.','.','.'], ['*','.','*'], ['*','.','*'], ['.','.','*']])
		x.moat_grid()
		x.count()
		self.assertEqual(x.grid[1][2].count, 0)
Ejemplo n.º 7
0
	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))	
Ejemplo n.º 8
0
	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))
Ejemplo n.º 9
0
	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))
Ejemplo n.º 10
0
	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))
Ejemplo n.º 11
0
	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))
Ejemplo n.º 12
0
	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))
Ejemplo n.º 13
0
	def test_moat_grid_3(self):
		x = Life(2, 2, [['.','.'], ['*','*']])
		grid = len(x.grid)
		x.moat_grid()
		self.assertEqual(grid + 2, len(x.grid))
Ejemplo n.º 14
0
	def test_count_pop_3(self):
		x = Life(3, 10, [['.','.','*','.','.','.','.','.','*','.'], ['.','.','.','.','.','.','.','.','.','*'], ['.','.','*','.','.','*','*','.','.','*']])
		x.moat_grid()
		x.count_pop()
		self.assertEqual(x.population, 7)
Ejemplo n.º 15
0
	def test_count_pop_1(self):
		x = Life(2, 15, [['.','.','*','.','.','.','.','.','*','.','.','.','.','.','.'], ['.','-','.','.','.','.','.','.','.','*','.','.','.','.','.']])
		x.moat_grid()
		x.count_pop()
		self.assertEqual(x.population, 3)
Ejemplo n.º 16
0
	def test_simulate_3(self):
		x = Life(2, 2, [['.','.'], ['*','*']])
		x.moat_grid()
		x.simulate()
		x.generation = 1