path-finding

How to find multidimensional path of exact 0 cost with 1, 0, -1 weights

淺唱寂寞╮ 提交于 2019-12-03 07:18:48
问题 I was given directed graph with n nodes and edges with weigths of vectors (every vector has length m) of numbers 1, 0, -1. I would like to find any path (or say that such path doesn't exist) from one node to other (we can visit nodes many times) such sum of its weights equals to vector of only zeros. I was thinking of bruteforce backtracking algorithm but it is not guaranteed that it would end. Can we somehow limit length of such path in terms of n and m? Example of graph for n=8, m=2 Example

A* admissible heuristics on a grid with teleporters?

旧时模样 提交于 2019-12-03 07:01:11
问题 Suppose that you have a 2D grid of cells, some of which are filled in with walls. Characters can take a step from one square to any square that is one step horizontal or vertical from it, but cannot cross walls. Given a start position and an end position, we can find the shortest path from the start position to the end position by using the A* algorithm with an admissible heuristic. In this current setup, the Manhattan distance would be admissible, since it never overestimates the distance to

How do you use a Bidirectional BFS to find the shortest path?

[亡魂溺海] 提交于 2019-12-03 06:02:50
问题 How do you use a Bidirectional BFS to find the shortest path? Let's say there is a 6x6 grid. The start point is in (0,5) and the end point is in (4,1). What is the shortest path using bidirectional bfs? There are no path costs. And it is undirected. 回答1: How does Bi-directional BFS work? Simultaneously run two BFS's from both source and target vertices, terminating once a vertex common to both runs is discovered. This vertex will be halfway between the source and the target. Why is it better

Efficient Path finding algorithm avoiding zigzag's [duplicate]

大兔子大兔子 提交于 2019-12-03 04:53:43
问题 This question already has answers here : Pathfinding - A* with least turns (2 answers) Closed 5 years ago . I am developing a software which connects objects with wires. This wiring has a rule that these wires cannot pass on other objects and no diagonal move is accepted. All of the shortest path algorithms that i know (A*, dijkstra etc.) find this type of paths: I do not want the unnecessary zigzags in the second screenshot. How do i achive this goal? Note: Anyone who want to try the

Storing a directed graph in google appengine datastore

强颜欢笑 提交于 2019-12-03 03:43:38
I need to store a large and dynamic undirected graph in google appengine, what's the best way to do this? The graph representation must be able to support rapidly pulling out a set of vertices (for rendering on a page) and all the links from a specific vertex, and pathfinding across the graph (although the optimal path isn't really needed, just a fairly good one) My thoughts on the subject: The most obvious way is to have a vertex model, and an edge model which references two vertices, however that sounds like it's going to end up using an awful lot of queries for every operation, I'm

Correct formulation of the A* algorithm

落爺英雄遲暮 提交于 2019-12-03 03:19:46
问题 I'm looking at definitions of the A* path-finding algorithm, and it seems to be defined somewhat differently in different places. The difference is in the action performed when going through the successors of a node, and finding that a successor is on the closed list. One approach (suggested by Wikipedia, and this article) says: if the successor is on the closed list, just ignore it Another approach (suggested here and here, for example) says: if the successor is on the closed list, examine

Is A* the best pathfinding algorithm?

青春壹個敷衍的年華 提交于 2019-12-03 01:48:43
问题 It is generally said that A* is the best algorithm to solve pathfinding problems. Is there any situation when A* is not the best algorithm to find solution? How good is A* compared to BFS, DFS, UCS, etc? 回答1: The short answer is yes, there are situations in which A* is not the best algorithm to solve a problem. However, there are a number of ways to assess what constitutes the best algorithm for finding a solution. If you are considering best in terms of performance of multiple searches from

Pathfinding on large map

为君一笑 提交于 2019-12-03 01:37:38
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,000 nodes. Each section would then be divided into 100 subsections. This would be repeated until each

Pacman: how do the eyes find their way back to the monster hole?

浪尽此生 提交于 2019-12-03 00:02:10
问题 I found a lot of references to the AI of the ghosts in Pacman, but none of them mentioned how the eyes find their way back to the central ghost hole after a ghost is eaten by Pacman. In my implementation I implemented a simple but awful solution. I just hard coded on every corner which direction should be taken. Are there any better/or the best solution? Maybe a generic one that works with different level designs? 回答1: Actually, I'd say your approach is a pretty awesome solution, with almost

Copy path/file name in Eclipse to clipboard

非 Y 不嫁゛ 提交于 2019-12-02 23:26:01
Is there a shortcut to copy the current path/file to the clipboard? There is Copy Qualified Name function in Eclipse, it will copy the full name of the element you select (or element on cursor). For example : /MyProject/src/app/Application.java : when you select Application.java in Package Explorer java.util.HashSet<String> : when you copy while cursor at HashSet<String> However, it required you to select the element you want. So, here is what I do. Make your Package Explorer link with editor, you can active this by click the double-arrow icon at top-right corner. Set up a hot-key for Show