a-star

How to set target vertex in QuickGraph Dijkstra or A*

二次信任 提交于 2019-12-05 03:33:28
问题 I am using QuickGraph version 3.6 and I found function SetRootVertex, but no SetTagretVertex. I need this because I am searching short paths in huge graph and this would speed up program a lot. Clases in question are DijkstraShortestPathAlgorithm and AStarShortestPathAlgorithm. 回答1: I don't think there is a way to this without using events. You could wrap the necessary code in one extension method, making things clear, e.g.: public static class Extensions { class AStarWrapper<TVertex, TEdge>

Why A* is faster if i use 4xManhattan Distances as Heuristic for 15-Puzzle

对着背影说爱祢 提交于 2019-12-05 03:17:47
问题 I have implemented an A* algorithm for solving the 15-puzzle. I made a research for finding some viable or admissible heuristics, looking for a fast solution, and i find that using 4*Manhattan Distance as heuristic always solve any 15-puzzle in less than a second. I tried this and effectively works. I tried to find a answer for that but i cant find it. Any one can explain this? 回答1: 4* manhattan distance is not admissible heuristic, this makes the algorithm behave "closer" to greedy best

Heuristic function for finding the path using A star

会有一股神秘感。 提交于 2019-12-05 02:11:04
问题 I am trying to find a optimal solution for the following problem The numbers denoted inside each node are represented as (x,y) . The adjacent nodes to a node always have a y value that is (current nodes y value +1). There is a cost of 1 for a change in the x value when we go from one node to its adjacent There is no cost for going from node to its adjacent, if there is no change in the value of x . No 2 nodes with the same y value are considered adjacent. The optimal solution is the one with

Can somebody explain in Manhattan dstance for the 8 puzzle in java for me?

天大地大妈咪最大 提交于 2019-12-04 21:33:50
i am writing an A* algorithm which can solve the 8-puzzle in Java, so far i have implemented DFS, BFS, A* using the number of tiles out of place and i just need to implement it using the heuristic for the Manhattan distance. As you are probably aware the Manhattan distance is the sum of each tiles displacement in relation to its current position and its index in the goal state. I have googled around and found these stack over flow topics: Calculating Manhattan Distance Manhattan distance in A* Which returned the following code: int manhattanDistanceSum = 0; for (int x = 0; x < N; x++) // x

Finding minimum cut-sets between bounded subgraphs

佐手、 提交于 2019-12-04 19:15:27
问题 If a game map is partitioned into subgraphs, how to minimize edges between subgraphs? I have a problem, Im trying to make A* searches through a grid based game like pacman or sokoban, but i need to find "enclosures". What do i mean by enclosures? subgraphs with as few cut edges as possible given a maximum size and minimum size for number of vertices for each subgraph that act as a soft constraints. Alternatively you could say i am looking to find bridges between subgraphs, but its generally

Manhattan Heuristic function for A-star (A*)

杀马特。学长 韩版系。学妹 提交于 2019-12-04 12:33:21
问题 I found this algorithm here. I have a problem, I cant seem to understand how to set up and pass my heuristic function. static public Path<TNode> AStar<TNode>(TNode start, TNode destination, Func<TNode, TNode, double> distance, Func<TNode, double> estimate) where TNode : IHasNeighbours<TNode> { var closed = new HashSet<TNode>(); var queue = new PriorityQueue<double, Path<TNode>>(); queue.Enqueue(0, new Path<TNode>(start)); while (!queue.IsEmpty) { var path = queue.Dequeue(); if (closed

What is the point of IDA* vs A* algorithm

柔情痞子 提交于 2019-12-04 10:32:15
问题 I don't understand how IDA* saves memory space. From how I understand IDA* is A* with iterative deepening. What's the difference between the amount of memory A* uses vs IDA* . Wouldn't the last iteration of IDA* behave exactly like A* and use the same amount of memory. When I trace IDA* I realize that it also has to remember a priority queue of the nodes that are below the f(n) threshold. I understand that ID-Depth first search helps depth first search by allowing it to do a breadth first

Pathfinding on large map

放肆的年华 提交于 2019-12-04 08:59:10
问题 I'm creating a game with a 10,000 by 10,000 map. I would like for a user to be able to set a location and have the computer instantly find the best path. However, since the map is 10,000 by 10,000, there are 100,000,000 nodes, and to find this path through a conventional method such as A* or Dijkstra's would require a large amount of memory and a long time. So my question is: How can I find the best path? The algorithm I'm considering would divide the world into 100 sections, each with 1,000

A* Start path finding in HTML5 Canvas

大城市里の小女人 提交于 2019-12-04 07:06:14
I'm trying implement A* Start path finding in my games(which are written with JavaScript, HTML5 Canvas). Library for A* Start found this - http://46dogs.blogspot.com/2009/10/star-pathroute-finding-javascript-code.html and now I'm using this library for path finding. And with this library, I'm trying write a simple test, but stuck with one problem. I'm now done when in HTML5 canvas screen click with mouse show path until my mouse.x and mouse.y. Here is a screenshot: (Pink square: Player, Orange squares: path until my mouse.x/mouse.y) Code how I'm drawing the orange squares until my mouse.x

how to find the best three routes using A* algorithm

▼魔方 西西 提交于 2019-12-04 03:31:54
问题 In A* usually the result that you get is only one path. Is it possible though for a given origin and destination to have 3 recommended path according to A*? So the second returned is the second best path, and the third is the third best path.. I was thinking of maybe modifying the heuristic somehow to reflect this second and third best path.. What do you guys think? UPDATE: My implementation is in PHP and I am using a closed set. So if there's a way to do this, let me know. 回答1: This can be