示例#1
0
 def test_neighboring_points_simple(self):
     game = Game(6, 6)
     game.field[3][2] = Cell.RED
     best_path_and_squre = game.check_neighboring_points(
         3, 2, 3, 2, [((3, 2))], [], 0, time.time())
     self.assertEqual(best_path_and_squre, (([], 0)))
     game.field[3][4] = Cell.RED
     game.field[2][3] = Cell.RED
     game.field[3][3] = Cell.BLUE
     game.field[4][3] = Cell.RED
     best_path_and_squre = game.check_neighboring_points(
         4, 3, 4, 3, [((4, 3))], [], 0, time.time())
     self.assertEqual(best_path_and_squre, (([(4, 3), (3, 2), (2, 3),
                                              (3, 4)], 2.0)))
示例#2
0
    def test_neighboring_points_vertical_border(self):
        game = Game(5, 5)
        game.field[0][2] = Cell.BLUE
        game.field[4][2] = Cell.BLUE
        game.field[0][1] = Cell.RED
        game.field[1][2] = Cell.RED
        game.field[3][2] = Cell.RED
        game.field[0][3] = Cell.RED
        game.field[4][3] = Cell.RED
        game.field[4][1] = Cell.RED

        best_path_and_squre = game.check_neighboring_points(
            4, 1, 4, 1, [((4, 1))], [], 0, time.time())
        self.assertEqual(best_path_and_squre,
                         (([(4, 1), (3, 2), (4, 3), (5, 3), (6, 2),
                            (5, 1)], 4.0)))

        best_path_and_squre = game.check_neighboring_points(
            0, 3, 0, 3, [((0, 3))], [], 0, time.time())
        self.assertEqual(best_path_and_squre, (([(0, 3), (-1, 3), (-2, 2),
                                                 (-1, 1), (0, 1),
                                                 (1, 2)], 4.0)))
示例#3
0
    def test_neighboring_points_horiz_border(self):
        game = Game(5, 5)
        game.field[1][0] = Cell.BLUE
        game.field[1][4] = Cell.BLUE
        game.field[1][1] = Cell.RED
        game.field[0][4] = Cell.RED
        game.field[1][3] = Cell.RED
        game.field[0][0] = Cell.RED
        game.field[2][0] = Cell.RED
        game.field[2][4] = Cell.RED

        best_path_and_squre = game.check_neighboring_points(
            2, 4, 2, 4, [((2, 4))], [], 0, time.time())
        self.assertEqual(best_path_and_squre,
                         (([(2, 4), (1, 3), (0, 4), (0, 5), (1, 6),
                            (2, 5)], 4.0)))

        best_path_and_squre = game.check_neighboring_points(
            0, 0, 0, 0, [((0, 0))], [], 0, time.time())
        self.assertEqual(best_path_and_squre, (([(0, 0), (1, 1),
                                                 (2, 0), (2, -1), (1, -2),
                                                 (0, -1)], 4.0)))