path-finding

AI: Fastest algorithm to find if path exists?

那年仲夏 提交于 2019-12-05 21:28:52
问题 I am looking for a pathfinding algorithm to use for an AI controlling an entity in a 2D grid that needs to find a path from A to B. It does not have to be the shortest path but it needs to be calculated very fast. The grid is static (never changes) and some grid cells are occupied by obstacles. I'm currently using A* but it is too slow for my purposes because it always tries to calculate the fastest path. The main performance problem occurs when the path does not exist, in which case A* will

Number of simple mutations to change one string to another?

半城伤御伤魂 提交于 2019-12-05 17:46:46
I'm sure you've all heard of the "Word game", where you try to change one word to another by changing one letter at a time, and only going through valid English words. I'm trying to implement an A* Algorithm to solve it (just to flesh out my understanding of A*) and one of the things that is needed is a minimum-distance heuristic. That is, the minimum number of one of these three mutations that can turn an arbitrary string a into another string b: 1) Change one letter for another 2) Add one letter at a spot before or after any letter 3) Remove any letter Examples aabca => abaca: aabca abca

How do I get the shortest route in a labyrinth?

别来无恙 提交于 2019-12-05 17:24:22
I want to make a code giving the shortest route when given a labyrinth as a matrix. In this case, the matrix representation of this labyrinth is as follows. ## [,1] [,2] [,3] [,4] ## [1,] 2 0 0 0 ## [2,] 1 1 0 1 ## [3,] 0 1 0 0 ## [4,] 1 1 1 3 , where 0 denotes inaccessible points, 1 denotes accessible points. 2 denotes the starting point, and 3 denotes the destination. And, the desired result is this : c(4,1,4,4,1,1) , where 1 denotes East, 2 denotes North, 3 denotes West, and 4 denotes South. I guess that one possible code might be a function giving the shortest route as a vector when it is

Algorithm like Bellman-Ford, only for multiple start, single destination?

江枫思渺然 提交于 2019-12-05 14:46:15
Algorithms like the Bellman-Ford algorithm and Dijkstra's algorithm exist to find the shortest path from a single starting vertex on a graph to every other vertex. However, in the program I'm writing, the starting vertex changes a lot more often than the destination vertex does. What algorithm is there that does the reverse--that is, given a single destination vertex, to find the shortest path from every starting vertex? Just reverse all the edges, and treated destination as start node. Problem solved. If this is an undirected graph: I think inverting the problem would give you advantages.

Updating Shortest path distances matrix if one edge weight is decreased

会有一股神秘感。 提交于 2019-12-05 13:17:49
We are given a weighed graph G and its Shortest path distance's matrix delta. So that delta(i,j) denotes the weight of shortest path from i to j (i and j are two vertexes of the graph). delta is initially given containing the value of the shortest paths. Suddenly weight of edge E is decreased from W to W'. How to update delta(i,j) in O(n^2)? (n=number of vertexes of graph) The problem is NOT computing all-pair shortest paths again which has the best O(n^3) complexity. the problem is UPDATING delta, so that we won't need to re-compute all-pair shortest paths. More clarified : All we have is a

R - Finding least cost path through raster image (maze)?

一笑奈何 提交于 2019-12-05 10:27:41
How can I find a non-linear path through raster image data? e.g., least cost algorithm? Starting and ending points are known and given as: Start point = (0,0) End point = (12,-5) For example, extract the approximate path of a winding river through a (greyscale) raster image. # fake up some noisy, but reproducible, "winding river" data set.seed(123) df <- data.frame(x=seq(0,12,by=.01), y=sapply(seq(0,12,by=.01), FUN = function(i) 10*sin(i)+rnorm(1))) # convert to "pixels" of raster data # assumption: image color is greyscale, only need one numeric value, v img <- data.frame(table(round(df$y,0),

Path finding Algorithms : A* Vs Jump Point Search

匆匆过客 提交于 2019-12-05 03:43:32
I know that A* is better than Dijkstra's algorithm because it takes heuristic values into account, but from A* and Jump Point search which is the most efficient algorithm for finding the shortest path in an environment with obstacles? and what are the differences? Jump Point Search is an improved A* based on some conditions on the graph. Thus, if you meet these conditions (uniform-cost grid mostly), JPS is strictly better than A* (same optimality, best cases can be order of magnitudes better and worse case is probably the same complexity but with a slightly worse constant), but if you do not

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

Path finding for games

风格不统一 提交于 2019-12-04 12:37:03
问题 What are some path finding algorithms used in games of all types? (Of all types where characters move, anyway) Is Dijkstra's ever used? I'm not really looking to code anything; just doing some research, though if you paste pseudocode or something, that would be fine (I can understand Java and C++). I know A* is like THE algorithm to use in 2D games. That's great and all, but what about 2D games that are not grid-based? Things like Age of Empires, or Link's Awakening. There aren't distinct

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