-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explanation on how velocity is used #46
Comments
Also, the concept of distance being in meters is confusing. I guess in the general case all of these things should be set to Also, I assume the intent of Velocity is to declare how many units (meters) you can move in a single step, where I guess a single step is a second??? |
Hey @AudriusButkevicius , thanks for your questions, I'll try to explain below. If you have more questions please feel free to re-open the ticket, I usually close tickets with questions immediately to keep things tidy, as I'll often forget to do it later :). You're right that A* is a general algorithm for path finding along a graph. Indeed in general A* there is no notion of velocity, or distance. There is just a cost attached to each path. In my library I've tried to make the cost of a path less abstract. By using units from the physical world. So if there is a path from node A to node B and they are 100KM apart and the speed limit on this road is 50KM/H and your agent is in a car that can reach 50KM/H the cost of moving over this path is 2 hours. If your agent is on a bike their might be able to only sustain 25KM/H so the same path costs 4 hours for them. (This last part, the speed difference between a bike and a car is the In find that for many of my users this makes it a lot easier to reason about path finding as they find it hard to make the translation from their game world to the abstract world of path finding. Of course not all path finding scenarios take place in something that resembles the real world. Your example of a board game is |
I am still not sure I follow what maxVelocity changes in the example between bike and car. Presumably the path is still the same? So I am lost to how one would use these. I guess you are saying the car could take some other, longer path, as long as the speed limit was higher? I'd still think an example where all of these examples are translated to a simple board game would be helpful, because for people solving simple problems, having to specify these values really throws them off. I also have a specific example I am trying to solve, to which I am not certain how I'd use the library. I have a 100x100 game grid. Can this library be used for a problem like that? As far as I understand, I could just generate nodes with for each point of the grid, and then from any node T I would connect it to all other nodes where distance is <5, with "speed limit" of 1, and do a find operation with maximum velocity of 1? I guess the path will be right, but the rest will be some non-sense numbers, that I don't care about anyway? |
" I guess you are saying the car could take some other, longer path, as long as the speed limit was higher?" Exactly, the cost of the path is time, so the 'cheapest' path could be different for actors with different top speeds. As for your example it would not work easily with this library. As it takes the distance between nodes into account so jumping wouldn't work well. In a plain A* library it should work but would lead to a lot of edges since every node (not an edge) would be connected to 5 other nodes in each of the 8 directions. So for a 100x100 grid that would to roughly 400.000 edges. In your case wouldn't a simpler algorithm work? I think the shortest path would always be to take as many diagonal steps as possible until you're a straight line away from your target. |
5000x5000 is probably too much to handle if you want real-time path finding. Your idea sounds a lot like hierarchical path finding. This looks like a great article on that: https://alexene.dev/2019/06/02/Hierarchical-pathfinding.html. As for teleportation. If you explain it like this it sounds like for path finding you can just connect the gaps that are small enough to jump over. So those parts are just connected to their nearest straight/diagonal node on the other end. Then when traversing the path you need to check if the next node is part of a gap or not. If you enter a gap start to play the jump animation. |
So if I follow the most basic explanation of A*, it usually talks about finding a path from A to B on some grid/graph G.
I am completely lost where the velocity comes in here, how I should use it, and what I should set it to for the basic case of simply finding a path.
I assume it has something todo with declaring the cost of moving from P1 to P2, so that you optimise the path with the lowest cost (fastest path, etc), but what does that mean for finding a path, what does setting maximumVelocity actually do?
The text was updated successfully, but these errors were encountered: