Space StarMap Stargates

Posted By: MMike

Space StarMap Stargates - 04/30/08 18:20

Hello.
Im wondering, how could i get the ship to calculate the number of jumps needed to get from the K1 point to the K4 destination.
Lines means that there are startGates( teleporters) connections for those stars.

In this example the the quick way to get from k1 to k4 is goin directly, since there is a stargate that connect those points. So its just 1 jump (fastest). Though you could go from K1 to K2 to K3 and K4 too, though it would be slower ( 3 jumps).

Im asking this because i want a button to turn auto pilot on, and let the player click on the destination in this example K4 , and then the AI system will calculate the fastest waypoints, and will show a list with the waypoint route (order) and drive the ship for those stargates.

Anyone expert on this can give me a hand?
Posted By: tompo

Re: Space StarMap Stargates - 04/30/08 18:26

Serch pathfinding (with nodes) in contribution forum. \:\)
Posted By: Gumby22don

Re: Space StarMap Stargates - 05/01/08 04:19

Yep - any pathfinding you use should be able to count the jumps. Because its node based from the start, it should be relatively easy to implement \:\) Have fun

Don
have a great day
Posted By: MMike

Re: Space StarMap Stargates - 05/01/08 16:14

I searched but there are very complex Ai systems i just need some basic ai path finding, Like.

Each dot, is an place, with a name, or number, and need to get the lowest combination possible to reach the same destination..
I was expecting some expert could writte a simple thing.
Whats the mechanism?
Posted By: bstudio

Re: Space StarMap Stargates - 05/01/08 17:23

Search for the perfect AI series in the AUM magazines. There is something similar to what you want there.
Posted By: AlexDeloy

Re: Space StarMap Stargates - 05/01/08 18:00

You could try to implement the Dijkstra Algorithm to find the shortest path in a set of nodes.
The easiest way might be to save the distances between the nodes in a two-dimensional array: e.g. distance[3][5] = 70 for a distance of 70 between the nodes 3 and 5
Posted By: LarryLaffer

Re: Space StarMap Stargates - 05/01/08 18:07

Visual Example: http://www.ifors.ms.unimelb.edu.au/tutorial/dijkstra/island.html

Algorithm: http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
Posted By: AlexDeloy

Re: Space StarMap Stargates - 05/01/08 19:13

I just made a quick dijkstra implementation

http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=204798
Posted By: Gumby22don

Re: Space StarMap Stargates - 05/04/08 14:08

Awesome - clear, precise. Well done Alex.

Don
have a great day
Posted By: WolfCoder

Re: Space StarMap Stargates - 05/09/08 14:57

I was thinking of first a comparison of all the stars that make a circuit, and then an algorithm that first gets you in that circuit and then finds the closest star in that circuit.

For example stars K1, K2, K3, and K4 make a circuit and you can go around in a circle with them. There's another circuit with K2, K3, and the star off to the side. Those two stray stars would be considered a circuit even though there is 1, but both are their own circuits.

First step is to get yourself in the circuit the star is in, but the starting location is in the circuit which contains K4. Then, you've got to travel either left or right, and check the total distance of all the lines from the left and right, and in this case the left path is shorter (directly).

I'm not sure if this is a good algorithm or not, but I would write a function to run through and recursively catalog all the stars and which circuits they make up. For faster speeds, this would run at compilation.
© 2024 lite-C Forums