java,algorithm,shortest-path,path-finding,a-star

Given your graph G=(V,E) where each v in V stands for a cell, and each edge (u,v) is possible move, you can create a new (weighted) graph G'=(V',E') as follows: V' = V_u U V_d U V_l U V_r - each group stands for the type of move you have...

.net,unity3d,path-finding,a-star

You are right. The Serialization is just for Loading/Saving Graphs to/from Files so you can preprocess them before runtime. I don't know what implementation of A* you are using. But for performance optimisation you could take a look here and here...

No, it is not correct for an arbitrary h function. Here is an example. Let's assume that we have a graph with 7 vertices and the following unweighted edges: {(1, 2), (2, 3), (3, 4), (4, 6), (2, 5), (5, 6), (6, 7)}. We can define h in the following...

You are using integers to calculate the costs. By casting the result from the square root to an int, you are basically throwing away the significance. Casting to an int is not the same as rounding. So in this case: getH(...): 4.9 --> 4 getH(...): 4.1 --> 4 In both...

c++,artificial-intelligence,a-star

The technical details are in the research paper, which can be found on Alban Grastien's web page. There is also a tutorial on aigamedev.com. It appears that an improved paper will appear at ICAPS 2014, but I don't believe the papers are online yet. If these resources are insufficient, a...

grid,2d,artificial-intelligence,path-finding,a-star

Do you mean they'd move diagonally on the grid? All you'd have to do is open up the node expanding code to also expand (+1, +1), (-1, -1), (+1, -1) and (-1, +1), turning it into orthogonal instead of cardinal. If your A* algorithm is correct, they will favour a...

On this line: currentTotalCost = currentCost + stepCost + heuristic(currentState, problem) You're trying to figure out the cost at the successor node: that should be the path to the current node, plus the step cost, plus the heuristic expected cost at the successor node. So I think you should be...

algorithm,graph-theory,path-finding,a-star

It might be possible yes, but A* is a popular algorithm for finding shortest paths in grid like graphs. For graphs in general there are a lot of other algorithms for shortest path calculation which will match your case better. It depends on your setting which one to use. If...

For a single query, A* is probably about as good as you can do. For many queries, you can convert your grid to an undirected, weighted graph consisting only of the hard-coded points where directly connected points have an edge between them and the edge weight is the distance between...

Conclusion: Heuristic functions that produce negative values are not inadmissible, per se, but have the potential to break the guarantees of A*. Interesting question. Fundamentally, the only requirement for admissibility is that a heuristic never over-estimates the distance to the goal. This is important, because an overestimate in the wrong...

r,algorithm,path-finding,a-star

There is e1071 and igraph. Not sure if they do A*, but they seem to have other shortest past algorithms.

java,algorithm,path,path-finding,a-star

Ok, so I've gone through your code and with the help of other's comments here I've managed to get it to work. I'm only posting the changed methods: Grid.getLowestFCostNodePos doesn't keep track of the X and Y values of the node with the lowest F: public int[] getLowestFCostNodePos(List<List<Integer>> openList, int...

c#,unity3d,artificial-intelligence,path-finding,a-star

I ended up using the C# Dictionary Data Structure in the end, and it's worked well, if anyone is interested.

I found the solution to my problem. When it was a struct, everytime I was passing around variables they were copies instead of references, so every new data structure composed of CellInfo I created was brand new. When changing to class, instead of copies they were references, and at some...

Everytime you run generateSuccessors, you create 4 (or less) NEW instances of AStarNode objects. This is not a problem per se, but AStarNode does not define hashCode and equals. So two nodes with the same coordinates are not considered equals, so closed.contains(successor) will NEVER return true. Implement hashCode and equals...

c++,path-finding,a-star,angelscript

for(int i = 0; i < openSet.length(); i++) { if(fScore[neighborTile.x][neighborTile.y] < lowestScore || i == 0) { lowestScore = fScore[neighborTile.x][neighborTile.y]; nextTile.x = neighborTile.x; nextTile.y = neighborTile.y; } } This loop just looks at neighborTile over and over. Did you mean to go over the elements of openSet?...

java,a-star,heuristics,8-puzzle

You do not have to worry about the situation you are describing in your question. The beginning state is expanded in the first iteration of A*, which leads the algorithm to include that node in the CLOSED list with an associated cost (which is zero, as it is the initial...

your image is like 2d grid map but your text suggest graph approach which is a bit confusing. for 2D grid map the costs must be different between cells on path you got too much of cost=100 in there and therefore you can not backtrack the path you have to...

algorithm,mapping,openstreetmap,graph-theory,a-star

Have a look into the GraphHopper project (where I'm the author of) or other routing projects for OSM already doing this. The idea is to count the number of ways one node is member of and mark nodes as junctions if they have a count of three or more (or...

algorithm,artificial-intelligence,a-star,tree-search

Assume that h(n) is not admissible, so there exists some vertex n such that h(n) > h*(n). But because of the compatibility of h(n), we know that for all n` it holds that h(n) <= c(n,a,n') + h(n'). Now combine these two predicates when n` is the vertex G to...

javascript,arrays,algorithm,object,a-star

By adding two lines in the do {} while (pn.Parent): do { pn = cn.Parent; ds.push({ Dir: cn.Y - pn.Y !== 0 ? cn.Y - pn.Y < 0 ? AS.Direction.UP : AS.Direction.DOWN : cn.X - pn.X > 0 ? AS.Direction.RIGHT : AS.Direction.LEFT, Node: cn}); console.log(ds.length); // Added this line, console.log(ds);...

performance,artificial-intelligence,a-star,heuristics,memory-efficient

Are you doing this for an assignment or for fun? If it's for fun, then don't use A*, use IDA*. IDA* will be faster and it uses almost no memory. Furthermore, you can use the extra memory to build better heuristics, and get even better performance. (You should find sufficient...

A* does exactly that... so no there is no significantly better way around (links to articles can be found in http://en.wikipedia.org/wiki/Shortest_path_problem) If you can do pre-processing you can color all points so pairs that can be reached are colored the same. Than later when you get 2 points if color...

java,algorithm,path,shortest-path,a-star

The heuristic function must be admissible(that is, it should never overestimate the distance to the goal). Once you start dividing the length of an edge by speedlimit, the real distance to the goal might be less than the Euclidean distance to it(if speedlimit > 1). It breaks the algorithm. How...

algorithm,actionscript-3,flash,path-finding,a-star

I see a few potential things wrong. You are potentially overwriting values here: n.g = currentNode.g + cost; n.f=calculateCostOfNode(n); n.parentNode =currentNode; openNodes.push(n); It should be: if n.g > currentNode.g + cost: n.g = currentNode.g + cost; n.f=calculateCostOfNode(n); n.parentNode =currentNode; if n not already in openNodes: openNodes.push(n); With n.g initiated to...

algorithm,search,artificial-intelligence,a-star,sudoku

A* is a graph search algorithm that finds a shortest path between a source to a destination (or set of destinations). To use A* on your problem, you need to reduce it to shortest path problem. In your case it could be by defining a state graph - where each...

c#,unity3d,path-finding,a-star

It looks like there could be some sort of circular logic where you're adding nodes to a list? Have you tried checking whether or not the list contains a node before you add it? while (node != null) { if (!list.Contains(node)) { list.Add(node); node = node.parent; } else { break;...

A few mistakes I've spotted: Your set of open nodes is not structured in any way so that retrieving the one with the minimal distance is easy. The usual choice for this is to use a priority queue, but inserting new nodes in a sorted order (instead of open.push(neighbour)) should...

java,algorithm,gis,dijkstra,a-star

Represent each node as a bunch of nodes, one for each incoming road. So let us have the following graph. And let use the following rules: If Came to B from A than we can only turn to D If Came to B from C than we can only go...

javascript,algorithm,performance,a-star

It depends on what you do with your foo.bar.baz, and the complexity of your code. While in principle var foobaZ should be quicker, in most cases it's going to be exactly the same, as the browser is going to be smart enough to optimize your code anyway. The key thing,...