コード例 #1
0
ファイル: test_system.py プロジェクト: nahumj/turing-ga
 def test_next(self):
     rules = [
         Rule("A", 0, 1, True, "B"),
         Rule("B", 0, 1, False, "A"),
         Rule("C", 0, 1, False, "B"),
         Rule("A", 1, 1, False, "C"),
         Rule("B", 1, 1, True, "B"),
         Rule("C", 1, 1, True, "HALT"),
     ]
     m = Machine(rules)
     t = Tape()
     s = System(m, t)
     s.next()
     self.assertEqual(s.steps, 1)
コード例 #2
0
ファイル: test_system.py プロジェクト: nahumj/turing-ga
 def test_get_state_tape_contents_and_index(self):
     rules = [
         Rule("A", 0, 1, True, "B"),
         Rule("B", 0, 1, False, "A"),
         Rule("C", 0, 1, False, "B"),
         Rule("A", 1, 1, False, "C"),
         Rule("B", 1, 1, True, "B"),
         Rule("C", 1, 1, True, "HALT"),
     ]
     m = Machine(rules)
     t = Tape()
     s = System(m, t)
     s.next()
     state, contents, index = s.get_state_tape_contents_and_head_index()
     self.assertEqual(state, "B")
     self.assertEqual(contents, [1, 0])
     self.assertEqual(index, 1)