Exemplo n.º 1
0
 def test_6x8_r2_vonNeumann_ca2d(self):
     matrix = adjacency.cellular_automaton2d(rows=6,
                                             cols=8,
                                             r=2,
                                             neighbourhood='von Neumann')
     with open(
             os.path.join(THIS_DIR, 'resources',
                          'adjacency_6x8_r2_vonNeumann_ca2d.txt'),
             'r') as content_file:
         content = content_file.read()
     expected = eval(content)
     self.assertEqual(expected, matrix)
Exemplo n.º 2
0
 def test_3x3_r1_vonNeumann_ca2d(self):
     matrix = adjacency.cellular_automaton2d(rows=3,
                                             cols=3,
                                             r=1,
                                             neighbourhood='von Neumann')
     expected = [[1., 1., 1., 1., 0., 0., 1., 0., 0.],
                 [1., 1., 1., 0., 1., 0., 0., 1., 0.],
                 [1., 1., 1., 0., 0., 1., 0., 0., 1.],
                 [1., 0., 0., 1., 1., 1., 1., 0., 0.],
                 [0., 1., 0., 1., 1., 1., 0., 1., 0.],
                 [0., 0., 1., 1., 1., 1., 0., 0., 1.],
                 [1., 0., 0., 1., 0., 0., 1., 1., 1.],
                 [0., 1., 0., 0., 1., 0., 1., 1., 1.],
                 [0., 0., 1., 0., 0., 1., 1., 1., 1.]]
     self.assertEqual(expected, matrix)
Exemplo n.º 3
0
 def test_3x3_r0_Moore_ca2d(self):
     matrix = adjacency.cellular_automaton2d(rows=3,
                                             cols=3,
                                             r=0,
                                             neighbourhood='Moore')
     expected = [[1., 0., 0., 0., 0., 0., 0., 0., 0.],
                 [0., 1., 0., 0., 0., 0., 0., 0., 0.],
                 [0., 0., 1., 0., 0., 0., 0., 0., 0.],
                 [0., 0., 0., 1., 0., 0., 0., 0., 0.],
                 [0., 0., 0., 0., 1., 0., 0., 0., 0.],
                 [0., 0., 0., 0., 0., 1., 0., 0., 0.],
                 [0., 0., 0., 0., 0., 0., 1., 0., 0.],
                 [0., 0., 0., 0., 0., 0., 0., 1., 0.],
                 [0., 0., 0., 0., 0., 0., 0., 0., 1.]]
     self.assertEqual(expected, matrix)
Exemplo n.º 4
0
 def test_4x3_r1_Moore_ca2d(self):
     matrix = adjacency.cellular_automaton2d(rows=4,
                                             cols=3,
                                             r=1,
                                             neighbourhood='Moore')
     expected = [
         [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0],
         [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0],
         [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0],
         [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
         [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
         [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
         [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
         [1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
         [1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
         [1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
     ]
     self.assertEqual(expected, matrix)