Ejemplo n.º 1
0
    def test_move_single_row_negative(self):
        pmap = [[0, 1, 0, 0, 0]]
        motion = [0, -1]
        p_move = 1.0
        answer = move(pmap, motion, p_move)

        correct_answer = [[1, 0, 0, 0, 0]]
        self.assertEqual(answer, correct_answer)
Ejemplo n.º 2
0
    def test_move_column(self):
        pmap = [[0, 0], [1, 0], [0, 0], [0, 0], [0, 0]]
        motion = [1, 0]
        p_move = 1.0
        answer = move(pmap, motion, p_move)

        correct_answer = [[0, 0], [0, 0], [1, 0], [0, 0], [0, 0]]
        self.assertEqual(answer, correct_answer)
Ejemplo n.º 3
0
    def test_move_single_row_with_move_error_edge(self):
        pmap = [[0, 0, 0, 0, 1]]
        motion = [0, 1]
        p_move = 0.8
        answer = move(pmap, motion, p_move)

        correct_answer = [[0.8, 0, 0, 0, 0.2]]
        for row_index in range(len(answer)):
            for tile_index in range(len(answer[row_index])):
                difference = answer[row_index][tile_index] - correct_answer[
                    row_index][tile_index]
                # make sure that the difference between the elements is negligible
                self.assertLess(difference, abs(.000000001))
Ejemplo n.º 4
0
    def test_move_column_with_error(self):
        pmap = [[0, 0], [1, 0], [0, 0], [0, 0], [0, 0]]
        motion = [1, 0]
        p_move = 0.8
        answer = move(pmap, motion, p_move)

        correct_answer = [[0, 0], [0.2, 0], [0.8, 0], [0, 0], [0, 0]]
        print(answer)
        for row_index in range(len(answer)):
            for tile_index in range(len(answer[row_index])):
                difference = answer[row_index][tile_index] - correct_answer[
                    row_index][tile_index]
                # make sure that the difference between the elements is negligible
                self.assertLess(difference, abs(.000000001))