def test_mutation_7(self):
        sol = s.Solution()
        path1 = pa.Path(self.start)
        path1.step_list = [st.Step(5, LEFT), st.Step(4, UP), st.Step(1, LEFT)]
        path2 = pa.Path(pt.Point(2, 1))
        path2.step_list = [
            st.Step(2, RIGHT),
            st.Step(1, DOWN),
            st.Step(3, RIGHT)
        ]
        sol.path_list = [path1, path2]

        v.draw_plots(sol.parse_to_list_of_points(), (10, 10))
        op.mutation(sol)
        v.draw_plots(sol.parse_to_list_of_points(), (10, 10))
Exemplo n.º 2
0
    def test_concat_4(self):
        path = pa.Path()
        step_list = []
        path.step_list = step_list
        path.concat_same_direction_steps()

        self.assertEqual(path.step_list, [])
Exemplo n.º 3
0
    def test_add_step(self):
        path = pa.Path()
        path.add_step(self.step1)
        path.add_step(self.step2)
        path.add_step(self.step3)

        self.assertEqual(path.step_list, self.step_list)
Exemplo n.º 4
0
    def test_concat_5(self):
        path = pa.Path()
        step1 = st.Step(4, RIGHT)
        step_list = [step1]
        path.step_list = step_list
        path.concat_same_direction_steps()

        self.assertEqual(path.step_list, [st.Step(4, RIGHT)])
Exemplo n.º 5
0
    def test_remove_zero_steps_2(self):
        path = pa.Path()
        step1 = st.Step(0, LEFT)
        step2 = st.Step(0, RIGHT)
        step_list = [step1, step2]
        path.step_list = step_list
        path.remove_zero_steps()

        self.assertEqual(path.step_list, [])
Exemplo n.º 6
0
 def test_split_4(self):
     path = pa.Path()
     step1 = st.Step(10, LEFT)
     step2 = st.Step(5, UP)
     step3 = st.Step(0, RIGHT)
     step4 = st.Step(6, DOWN)
     step5 = st.Step(10, RIGHT)
     step_list = [step1, step2, step3, step4, step5]
     path.step_list = step_list
     path.split_step(2)
     print(path)
Exemplo n.º 7
0
    def test_remove_zero_steps_1(self):
        path = pa.Path()
        step1 = st.Step(0, LEFT)
        step2 = st.Step(0, RIGHT)
        step3 = st.Step(3, RIGHT)
        step4 = st.Step(6, RIGHT)
        step5 = st.Step(0, UP)
        step_list = [step1, step2, step3, step4, step5]
        path.step_list = step_list
        path.remove_zero_steps()

        self.assertEqual(
            path.step_list,
            [st.Step(3, RIGHT), st.Step(6, RIGHT)])
Exemplo n.º 8
0
    def test_concat_1(self):
        path = pa.Path()
        step1 = st.Step(4, LEFT)
        step2 = st.Step(4, RIGHT)
        step3 = st.Step(3, RIGHT)
        step4 = st.Step(6, RIGHT)
        step5 = st.Step(10, UP)
        step_list = [step1, step2, step3, step4, step5]
        path.step_list = step_list
        path.concat_same_direction_steps()

        self.assertEqual(
            path.step_list,
            [st.Step(4, LEFT),
             st.Step(13, RIGHT),
             st.Step(10, UP)])
Exemplo n.º 9
0
    def test_concat_3(self):
        path = pa.Path()
        step1 = st.Step(4, RIGHT)
        step2 = st.Step(3, RIGHT)
        step3 = st.Step(3, RIGHT)
        step4 = st.Step(3, LEFT)
        step5 = st.Step(3, RIGHT)
        step6 = st.Step(5, RIGHT)
        step7 = st.Step(1, RIGHT)
        step_list = [step1, step2, step3, step4, step5, step6, step7]
        path.step_list = step_list
        path.concat_same_direction_steps()

        self.assertEqual(
            path.step_list,
            [st.Step(10, RIGHT),
             st.Step(3, LEFT),
             st.Step(9, RIGHT)])
Exemplo n.º 10
0
    def test_convert_to_point_list(self):
        start = pt.Point(3, 4)
        p_list = [
            pt.Point(3, 4),
            pt.Point(2, 4),
            pt.Point(1, 4),
            pt.Point(0, 4),
            pt.Point(-1, 4),
            pt.Point(-2, 4),
            pt.Point(-2, 3),
            pt.Point(-2, 2),
            pt.Point(-2, 1),
            pt.Point(-2, 0),
            pt.Point(-1, 0)
        ]

        path = pa.Path(start)
        path.step_list = self.step_list
        point_list = path.convert_point_list()
        self.assertEqual(point_list, p_list)
 def setUp(self):
     self.start = pt.Point(9, 7)
     self.solution = s.Solution()
     self.path = pa.Path(self.start)
     self.path_before_mut = pa.Path(pt.Point(9, 7))
Exemplo n.º 12
0
 def create_solution(self, board):
     for p1, p2 in board.point_list:
         path = pa.Path(p1, p2)
         path.create_random_path(board.dimensions)
         self.path_list.append(path)