I think I finally understand what I’m doing incorrectly with the Dijkstra implementation. I’m not using edges, part of which because there aren’t any, and traversing each node. I’m also trying to use a tree where a queue is called for.
The code I have now would work great for the A* algorithm, so I plan on keeping it and probably implementing the A* algorithm while I finish up what I have so far.
Mgccl tuned me into a link that helped me out a great deal in understanding a better solution to the problem. Fundamentally, the solution is the same. Cast a “ray” or a line towards the end node and keep doing so either until you bypass any blocked paths or reach the end.
Casting Rays
This would meet the requirements for the queue as the completed ray can be placed in the queue. Since the rays are weighted edges, it meets the final requirement for what the algorithm calls for.
The speed should increase slightly since I will only be checking the nodes that is within the ray. The worse case is that I do end up checking the majority of the nodes and not find the end. The best part is that it would allow me to traverse the same nodes more than once. The second best part is that it won’t change the API for users.
What is a Ray?
Just a line. Actually, ray casting has more origins in 3D gaming, but the goal is to have the algorithms support 3D as much as possible. It is useful for collision detection, which is what I’m using it for in this case. I’m sending a ray out and checking to see if it hits something and then sending another node out.
There is going to be a bit more mathematics involved as I need to keep in mind that I don’t want to extend further than the end node and want to move towards it as much as possible.
Similarities to A*
Hmm, in which case the algorithm will look a lot like A* at the end, but the only difference is that the Dijkstra will use rays and the A* will traverse nodes. Which has the better advantage will be up to the developer. Hopefully, by the time the algorithms are stable along with the Quantum Library, both algorithms will function as they are meant to. I fear however that the Dijkstra will be quicker for some cases than A* just because of how it is implemented. A* should be more accurate at the beginning in its path creation.
Time?
The goal was to have the Dijkstra finished by the end of the month, along with a lot of other Astrum Futura features. I don’t think I’ll be able to make that goal with the changes I have planned. The good news is that A* is closer to being implemented. The bad news is that it probably take another week or two, because I nearing the end of school and have a lot of final projects that I need to work on instead of this one.
Possibly Related Posts:
- Game Engine Development and Open Source
- Plans for Base CMS
- Bullet: E-Book Library Management and Content Server
- Using ZendFramework 2 beta1 For Directory Project
- Project Plans