A-Star-Pathfinding | source code for demonstrating the A-Star Pathfinding | Learning library
kandi X-RAY | A-Star-Pathfinding Summary
kandi X-RAY | A-Star-Pathfinding Summary
Programs and source code for demonstrating the A-Star Pathfinding Algorithm
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of A-Star-Pathfinding
A-Star-Pathfinding Key Features
A-Star-Pathfinding Examples and Code Snippets
Community Discussions
Trending Discussions on A-Star-Pathfinding
QUESTION
I want to implement an A-Star Algorithm with a GUI for user input to set the start and end node, and draw obstacles. However, I have spent a great deal of time pondering why the Algorithm isn't working.
IssueThe path goes in the opposite direction of the end node and to the corner of the matrix. For example, if start: 2,2 and end: 8,8 the path will map to the origin: 0,0 and vice versa.
TroubleshootingI have already checked all the areas that I could possibly think is going wrong and even referring to source code from a medium article: A-Star Algorithm by Nicholas Swift
- Euclidean distance is not negative
- Adjacent nodes are not out of bounds
- Other smaller troubleshoot
The obstacles on the graph have not yet been implemented because I was trying to get the path to map correctly before adding additional complexity to the motivating problem.
I simply cannot see where I am going wrong. I come from a Java background so there could be some basic Python syntax that is escaping me and making everything break. Any suggestions will be appreciated.
Source code:
...ANSWER
Answered 2021-Jan-11 at 17:27As pointed out by user @Ghoti the issue was a simple comparison error in the algorithm. With the current comparison statement in the code above the first node in the adjNode list is always selected.
QUESTION
I'm trying to port this Java tutorial to Xojo. I'm struggling to unpack the Set
function below because, whilst short and elegant, it crams a lot of conversions into a small space and I'm not sure if I'm understanding it correctly. It's difficult as Java is not my primary language and Xojo lacks support for generics:
ANSWER
Answered 2020-Mar-14 at 18:33it means map
the id
to a Node
and put (collect) it into a set
this::getNode
translates to: from this class, use getNode on the id
which is just syntactic sugar for .map(id -> getNode(id)).collect(Collectors.toSet())
QUESTION
I am trying to adapt an application I found here, I imagined that I just had to add an axis. The problem is that the script seems like it is stuck. Can someone tell me what I did wrong and how I can use A* with a 3d matrix (i j k)?
this is the portion of the A* function I changed
...ANSWER
Answered 2020-Jan-20 at 23:16A* can work with any number of dimensions; it's a graph traversal algorithm, and no matter how many dimensions your problem space has, connecting one position to another still produces a graph.
You have two problems with generating new nodes, however.
You included
(0, 0, 0)
in the list, so no change. You keep putting the current position back into the queue for consideration. That’s just busy work, because the current position is already in the closed list.You never subtract from any of your coordinates, you only add. So your
x
,y
andz
values can only ever go up. If reaching your goal requires a path around an obstacle, then you have a problem here because all your version can ever do is move in one direction along any given axis.
In a 3 by 3 by 3 3D matrix, with the current position in the middle, there are 3 times 3 times 3 minus 1 == 26 positions you can reach with a single step. Your code reaches just 7 of those, plus one that stays put.
If you extract your tuples in the for new_position in [...]
list into a separate variable and add some newlines, and re-arrange them a bit to group them by how many 1
s you have in the tuple, you get the following definition. I renamed this to deltas
, because it's not a new position, it's the change relative to the old position, or delta. I re-arranged your tuples to make it easier to group them logically:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install A-Star-Pathfinding
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page