Presentation is loading. Please wait.

Presentation is loading. Please wait.

Team 17c ****** Pathfinding

Similar presentations


Presentation on theme: "Team 17c ****** Pathfinding"β€” Presentation transcript:

1 Team 17c ****** Pathfinding
William Little Steven Moore Josh Spain

2 Abstract Four pathing algorithms are used to optimize the path from a starting point to and ending point within a maze. The maze has been mapped to a graph such that the maze has both decision points and steps that correspond to vertices and edges. Dijkstra, Best-First, A*, and Pivot Search are the algorithms used. Dijkstra is the most thorough, Best-First strives for speed, A* and Pivot Search look for a median point between the two.

3 Introduction The main goal of our project is to identify the shortest possible route, from entrance to exit, within a randomized maze, given the maze has dead ends, obstacles, and variations in terrain.

4 the problem formally: A π‘”π‘Ÿπ‘Žπ‘β„Ž can be described a finite collection of vertices and edges that connect those vertices. Let 𝐾(𝑉,𝐸) be a graph with vertex set 𝑉= 𝑣 1 , 𝑣 2 ,…, 𝑣 π‘š and edge set 𝐸 = (𝑣 𝑖 , 𝑣 𝑗 ) | 𝑣 𝑖 π‘Žπ‘›π‘‘ 𝑣 𝑗 βˆˆπ‘‰, 𝑣 𝑖 β‰  𝑣 𝑗 .

5 the problem formally coNt:
A π‘šπ‘Žπ‘§π‘’, 𝑀, can be described in a similar way. Let 𝑀(𝐷,𝑆,𝑂, 𝐺) be a maze with decision set 𝐷, step set 𝑆, obstruction set 𝑂, and gate set 𝐺.

6 the problem formally coNt:
Within 𝑀: The decision set is the vertex set. 𝐷= 𝑑 1 , 𝑑 2 ,…, 𝑑 π‘š The step set is the edge set. 𝑆= (𝑑 𝑖 , 𝑑 𝑗 ) | 𝑑 𝑖 π‘Žπ‘›π‘‘ 𝑑 𝑗 ∈𝐷, 𝑑 𝑖 β‰  𝑑 𝑗 The length of each step is equal to 1.

7 the problem formally coNt:
Within 𝑀: The obstruction set is the set of all obstructions within 𝑀. 𝑂= π‘œ 1 , π‘œ 2 ,…, π‘œ 𝑛 Obstructions are the weights associated with each 𝑠𝑑𝑒𝑝 in 𝑀. Each π‘œ 𝑛 ∈ β„€ β‰₯ where: π‘Šπ‘Žπ‘™π‘™π‘  = 0 π‘‚π‘‘β„Žπ‘’π‘Ÿ π‘œπ‘π‘ π‘‘π‘Ÿπ‘’π‘π‘‘π‘–π‘œπ‘›π‘  = π‘Ÿπ‘Žπ‘›π‘‘π‘œπ‘š β„€ > | π‘Ÿπ‘Žπ‘›π‘‘π‘œπ‘š β„€ > β‰ 1 Steps which are not considered obstructions have a placeholder in the obstruction set equal to 1

8 the problem formally coNt:
The cardinality of 𝑠𝑒𝑑 𝑆 is equivalent to that of 𝑠𝑒𝑑 𝑂. |𝑆|≑|𝑂| The gate set is the set that contains the starting point π‘ π‘‘π‘Žπ‘Ÿπ‘‘ and ending point π‘“π‘–π‘›π‘–π‘ β„Ž within 𝑀. 𝐺= π‘ π‘‘π‘Žπ‘Ÿπ‘‘,π‘“π‘–π‘›π‘–π‘ β„Ž

9 the problem formally coNt:
A π‘π‘Žπ‘‘β„Ž from π‘ π‘‘π‘Žπ‘Ÿπ‘‘ to π‘“π‘–π‘›π‘–π‘ β„Ž is as sequence of distinct steps: 𝑑 1 , 𝑑 2 , 𝑑 2 , 𝑑 3 ,…, 𝑑 π‘˜βˆ’1 , 𝑑 π‘˜ Where 𝑑 1 =π‘ π‘‘π‘Žπ‘Ÿπ‘‘ and 𝑑 π‘˜ =π‘“π‘–π‘›π‘–π‘ β„Ž

10 the problem formally coNt:
Our goal is to identify the shortest path (𝑃 π‘ β„Žπ‘œπ‘Ÿπ‘‘π‘’π‘ π‘‘ ) from π‘ π‘‘π‘Žπ‘Ÿπ‘‘ to π‘“π‘–π‘›π‘–π‘ β„Ž within 𝑀(𝐷,𝑆,𝑂,𝐺). Let 𝑃 π‘Žπ‘™π‘™ be the set of all possible π‘π‘Žπ‘‘β„Ž π‘™π‘’π‘›π‘”π‘‘β„Žπ‘  within 𝑀 from π‘ π‘‘π‘Žπ‘Ÿπ‘‘ to π‘“π‘–π‘›π‘–π‘ β„Ž. 𝑃 π‘Žπ‘™π‘™ ={ 𝑝 1 , 𝑝 2 ,…, 𝑝 𝑖 ,… 𝑝 π‘Ÿ } Each 𝑝 𝑖 is determined by the summation of each step in the path multiplied by its’ associated weight from the obstruction set. 𝑠 𝑙,π‘₯ βˆ— π‘œ 𝑀,π‘₯ 𝑠 𝑙,π‘₯ is the 𝑠𝑑𝑒𝑝 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘Žπ‘  π‘π‘œπ‘ π‘–π‘‘π‘–π‘œπ‘› π‘₯ in 𝑆 π‘œ 𝑀,π‘₯ is the π‘œπ‘π‘ π‘‘π‘Ÿπ‘’π‘π‘‘π‘–π‘œπ‘› π‘€π‘’π‘–π‘”β„Žπ‘‘ π‘Žπ‘‘ π‘π‘œπ‘ π‘–π‘‘π‘–π‘œπ‘› π‘₯ in 𝑂 Therefore the shortest π‘π‘Žπ‘‘β„Ž within 𝑀(𝐷,𝑆,𝑂,𝐺) is: 𝑃 π‘ β„Žπ‘œπ‘Ÿπ‘‘π‘’π‘ π‘‘ =min( 𝑃 π‘Žπ‘™π‘™ )

11 Constraints: βˆƒ at least π‘œπ‘›π‘’ path from π‘ π‘‘π‘Žπ‘Ÿπ‘‘ to π‘“π‘–π‘›π‘–π‘ β„Ž within in 𝑀.
There must exist π‘œπ‘π‘ π‘‘π‘Ÿπ‘’π‘π‘‘π‘–π‘œπ‘›π‘  within 𝑀 which will either vary the weight of some of the 𝑠𝑑𝑒𝑝𝑠 or completely obstruct movement from one π‘‘π‘’π‘π‘–π‘ π‘–π‘œπ‘› π‘π‘œπ‘–π‘›π‘‘ to another.

12 To Simplify: 4 2 2 3 2 3 2 1 3 3 1 1 1 5 1 2 2 1 2

13 Algorithms: Dijkstra’s
Dijkstra’s algorithm works by visiting vertices in the graph starting with the object’s starting point. It then repeatedly examines the closest not- yet-examined vertex, adding its vertices to the set of vertices to be examined. It expands outwards from the starting point until it reaches the goal.

14 Algorithms: Dijkstra’s
def dijkstra_search(graph, start, goal): frontier = PriorityQueue() frontier.put(start, 0) came_from = {} cost_so_far = {} came_from[start] = None cost_so_far[start] = length = while not frontier.empty(): current = frontier.get() if current == goal: length = cost_so_far[current] break for next in graph.neighbors(current, True): new_cost = cost_so_far[current] + graph.cost(current, next) if next not in cost_so_far or new_cost < cost_so_far[next]: cost_so_far[next] = new_cost priority = new_cost frontier.put(next, priority) came_from[next] = current return came_from, cost_so_far, length Dijkstra’s Dijkstra’s algorithm works by visiting vertices in the graph starting with the object’s starting point. It then repeatedly examines the closest not- yet-examined vertex, adding its vertices to the set of vertices to be examined. It expands outwards from the starting point until it reaches the goal.

15 Algorithms cont: Best First
Best-First-Search algorithm works in a similar way, except that it uses aΒ heuristic. The heuristic is an estimate of how far from the goal any vertex is. Instead of selecting the vertex closest to the starting point, it selects the vertex closest to the goal. Best First isΒ notΒ guaranteed to find a shortest path, but it runs much quicker than Dijkstra’s because the heuristic function helps find the goal very quickly.

16 Algorithms cont: def best_first_search(graph, start, goal): #A greedy, depth-first algorithm that disregards edge weights. frontier = PriorityQueue() frontier.put(start, 0) came_from = {} cost_so_far = {} came_from[start] = None cost_so_far[start] = length = while not frontier.empty(): current = frontier.get() if current == goal: length = cost_so_far[current] break for next in graph.neighbors(current, True): new_cost = cost_so_far[current] + graph.cost(current, next) if next not in cost_so_far or new_cost < cost_so_far[next]: cost_so_far[next] = new_cost priority = heuristic(goal, next) frontier.put(next, priority) came_from[next] = current return came_from, cost_so_far, length

17 Algorithms Cont: A* A* combines the pieces of information that Dijkstra’s algorithm uses, favoring vertices that are close to the starting point,Β andΒ information that Best First uses ,favoring vertices that are close to the goal.

18 Algorithms Cont: def a_star_search(graph, start, goal): frontier = PriorityQueue() frontier.put(start, 0) came_from = {} cost_so_far = {} came_from[start] = None cost_so_far[start] = length = while not frontier.empty(): current = frontier.get() if current == goal: length = cost_so_far[current] break for next in graph.neighbors(current, True): new_cost = cost_so_far[current] + graph.cost(current, next) if next not in cost_so_far or new_cost < cost_so_far[next]: cost_so_far[next] = new_cost priority = new_cost + heuristic(goal, next) frontier.put(next, priority) came_from[next] = current return came_from, cost_so_far, length

19 Algorithms cont: Pivot Search
Pivot Search is a hybrid algorithm that encompasses both aspects of A* and Best-First Search. The idea behind it is that Best-First Search is great for solving quickly and A* is great for solving accurately. So why not try to combine fast and accurate to make a super algorithm? What's the worst that could happen?

20 Algorithms cont: def pivot_search(graph, start, goal, p): frontier = PriorityQueue() frontier.put(start, 0) came_from = {} cost_so_far = {} came_from[start] = None cost_so_far[start] = length = while not frontier.empty(): current = frontier.get() if graph.in_weights(current): bestfirst = False else: bestfirst = True if current == goal: length = cost_so_far[current] break for next in graph.neighbors(current, True): new_cost = cost_so_far[current] + graph.cost(current, next) if next not in cost_so_far or new_cost < cost_so_far[next]: cost_so_far[next] = new_cost if bestfirst: priority = heuristic(goal, next) else: priority = new_cost/p + heuristic(goal, next) frontier.put(next, priority) came_from[next] = current return came_from, cost_so_far, length

21 Experiment: 10 Runs Unresolvable Cases: 0

22 Experiment: 100 Runs Unresolvable Cases: 4

23 Experiment: 1000 Runs Unresolvable Cases: 48

24 Experiment: Runs Unresolvable Cases: 467

25 Experiment: Runs Unresolvable Cases: 4996

26 Future Work Further work on the Pivot Search is needed in order to optimize it. How we make the transition from A* to Best First is basic at best. We believe that coming up with a better way to make the transitions between A* and Best-First would greatly improve its efficiency. Working with mazes was a good start but we are more interested in larger maps without each step being defined by walls. Something more geared toward a game environment.

27 Questions Why is A* such a widely used algorithm?
It is used because of its performance and accuracy. Where would Best-First preform well? Best First preforms well when there are small number of obstructions within the maze. What is the difference between a paths length and a paths weight? Path length is the actual distance of the path; the weight is cost of traveling the path. When a maze is mapped to a graph, what are the vertices? Vertices are places to make a decision on where to move next within the maze. What is the purpose of a heuristic? Heuristic methods can be used to speed up the process of finding a satisfactory solution.


Download ppt "Team 17c ****** Pathfinding"

Similar presentations


Ads by Google