示例#1
0
 def test_realistic_road(self):
     # Test Case 2 (more realistic road)
     road = build_road(14, [80, 60, 40, 20])
     lane_change_cost = 1.0 / 100.0
     init = [len(road) - 1, 0]
     goal = [len(road) - 1, len(road[0]) - 1]
     cost = 0.293333333333
     
     self.assertAlmostEqual(cost, plan(road=road, 
                                       lane_change_cost=lane_change_cost,
                                       goal=goal,
                                       init=init), 10)
示例#2
0
 def test_fast_left_lane(self):
     # Test Case 1 (FAST left lane)
     road = build_road(8, [100, 10, 1])
     lane_change_cost = 1.0 / 1000.0
     init = [len(road) - 1, 0]
     goal = [len(road) - 1, len(road[0]) - 1]
     cost = 1.244
     
     self.assertAlmostEqual(cost, plan(road=road, 
                                       lane_change_cost=lane_change_cost,
                                       goal=goal,
                                       init=init), 3)
示例#3
0
文件: tests.py 项目: eokyere/udacity
    def test_realistic_road(self):
        # Test Case 2 (more realistic road)
        road = build_road(14, [80, 60, 40, 20])
        lane_change_cost = 1.0 / 100.0
        init = [len(road) - 1, 0]
        goal = [len(road) - 1, len(road[0]) - 1]
        cost = 0.293333333333

        self.assertAlmostEqual(
            cost,
            plan(road=road,
                 lane_change_cost=lane_change_cost,
                 goal=goal,
                 init=init), 10)
示例#4
0
文件: tests.py 项目: eokyere/udacity
    def test_fast_left_lane(self):
        # Test Case 1 (FAST left lane)
        road = build_road(8, [100, 10, 1])
        lane_change_cost = 1.0 / 1000.0
        init = [len(road) - 1, 0]
        goal = [len(road) - 1, len(road[0]) - 1]
        cost = 1.244

        self.assertAlmostEqual(
            cost,
            plan(road=road,
                 lane_change_cost=lane_change_cost,
                 goal=goal,
                 init=init), 3)
示例#5
0
 def test_slalom(self):
     # Test Case 4 (Slalom)
     road = [[50, 50, 50, 50, 50, 40,  0, 40, 50, 50,  0, 50, 50, 50, 50], # left lane: 50 km/h
             [40, 40, 40, 40,  0, 30, 20, 30,  0, 40, 40, 40, 40, 40, 40],
             [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]] # right lane: 30 km/h
     lane_change_cost = 1.0 / 65.0
     init = [len(road) - 1, 0]
     goal = [len(road) - 1, len(road[0]) - 1]
     cost = 0.450641025641
     
     self.assertAlmostEqual(cost, plan(road=road, 
                                       lane_change_cost=lane_change_cost,
                                       goal=goal,
                                       init=init), 10)
示例#6
0
 def test_obstacles_included(self):
     # Test Case 3 (Obstacles included)
     road = [[50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 50, 50, 50, 50, 50], # left lane: 50 km/h
             [40, 40, 40, 40, 40, 30, 20, 30, 40, 40, 40, 40, 40, 40, 40],
             [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]] # right lane: 30 km/h
     lane_change_cost = 1.0 / 500.0
     init = [len(road) - 1, 0]
     goal = [len(road) - 1, len(road[0]) - 1]
     cost = 0.355333333333
     
     self.assertAlmostEqual(cost, plan(road=road, 
                                       lane_change_cost=lane_change_cost,
                                       goal=goal,
                                       init=init), 10)
示例#7
0
文件: tests.py 项目: eokyere/udacity
    def test_slalom(self):
        # Test Case 4 (Slalom)
        road = [
            [50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 0, 50, 50, 50,
             50],  # left lane: 50 km/h
            [40, 40, 40, 40, 0, 30, 20, 30, 0, 40, 40, 40, 40, 40, 40],
            [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
        ]  # right lane: 30 km/h
        lane_change_cost = 1.0 / 65.0
        init = [len(road) - 1, 0]
        goal = [len(road) - 1, len(road[0]) - 1]
        cost = 0.450641025641

        self.assertAlmostEqual(
            cost,
            plan(road=road,
                 lane_change_cost=lane_change_cost,
                 goal=goal,
                 init=init), 10)
示例#8
0
文件: tests.py 项目: eokyere/udacity
    def test_obstacles_included(self):
        # Test Case 3 (Obstacles included)
        road = [
            [50, 50, 50, 50, 50, 40, 0, 40, 50, 50, 50, 50, 50, 50,
             50],  # left lane: 50 km/h
            [40, 40, 40, 40, 40, 30, 20, 30, 40, 40, 40, 40, 40, 40, 40],
            [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
        ]  # right lane: 30 km/h
        lane_change_cost = 1.0 / 500.0
        init = [len(road) - 1, 0]
        goal = [len(road) - 1, len(road[0]) - 1]
        cost = 0.355333333333

        self.assertAlmostEqual(
            cost,
            plan(road=road,
                 lane_change_cost=lane_change_cost,
                 goal=goal,
                 init=init), 10)