Answer the question
In order to leave comments, you need to log in
How to search for array elements in a chain (search for the optimal path)?
Cheerful time of day!
I'm looking for an algorithm to solve my problem, even in php, even in js, it doesn't matter.
Given an array:
[0, "name", x, y, z, 10, [1,2]],
[1, "name", x, y, z, 10, [0,3]],
[2, "name", x, y, z, 5, [0,3,4]],
[3, "name", x, y, z, 10, [2,1,4]],
[4, "name", x, y, z, 10, [3,2]],
[5, "name", x, y, z, 10, [4]]
1) 0->2->3->4->5
2) 0->1->3->4->5
3) 0->2->4->5
2) 0->1->3->4->5 // самый короткий из безопасных путей
3) 0->2->4->5 // самый короткий путь
Answer the question
In order to leave comments, you need to log in
Have you decided to make a map for EVE Online with your own hands? All prerequisites, including the picture, speak of this. :)
Any pathfinding algorithm will help you. Look towards A*, its implementation exists, probably, even at brainfuck, so the code is simply inappropriate.
The route search is done once for the safest route and once again for the shortest.
In the first case, the weight of the node will be the s-level of the star. Heuristic - average sec-level per number of jumps to the target.
In the second case, the weight will already be the number of jumps themselves, and the heuristic will have to be calculated from the number of jumps to the target.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question