Creating "Hyperlane" Map Generator for RTS game

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Hello, I’m TheMoop and I’m creating a sci-fi RTS game. Ship travel mechanics are complete, but I want them to travel along specific paths between stars, hyperlanes in other words, which helps to encourage defensive strategy and tactical planning.

So the goal is to create a Hyperlane generator similar to the game Stellaris’ hyperlane map. This is essentially just creating random paths between points, but the paths can never cross, and any given point has to be able to reach all other points through connected paths. I understand this is a difficult mathematical problem, so I’ve been searching outside of roblox for solutions… the trouble is, most developers will use a math plugin and even then the result is not really what I’m looking for.

Ideally, this should also create attachments on parts representing stars, and beams between those attachments where travel is feasible. Any time a player tries to move a fleet from one star to another, there has to be exactly one hyperlane connecting them. This part is much easier to figure out and is much less mathematical, so I’m less concerned with that question being answered.

This is achievable on roblox, Hyperant (Rise of Nations) created an unfinished game “Stellar Conquest” (Stellar Conquest - Roblox) that did exactly this.

  1. What is the issue? Include screenshots / videos if possible!

The effect I’m trying to create:

Hyperant’s hyperlane generation:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

My first attempt at this was simple brute force by creating a set of 5 hyperlane maps. My thinking is that a ship should check a two-dimensional table generated in a module script to check if travel from their current star (row) to destination star (column) is possible. If travel is possible, the [row][column] will return a 1, and if otherwise it will return a 0. However, the trouble is that 100 stars will have to have 10,000 entries filled out in its matrix. I’d be happy with even 20-40 stars, but I still don’t want to fill out 400-1600 entries.

A side note that you might want to read if you have questions about the specific mechanics: this game involves system to system (star system) travel via hyperlanes; fleets should not be able to skip over stars through hyperlane travel, because this would ruin defensive strategies.

Thanks for your help!

3 Likes

I followed around some posts and came to these wikipedia articles:

I noticed some people on roblox are using these algorithms to create square mazes, and I think this is the key to creating what I was talking about. If anyone’s had experience with this algorithm, I could use some experienced advice on how to use it.

I guess you could try creating a bunch of tiny parts along the hyperlane (by taking the starting vector from the ending vector and then dividing that by however many parts you want to place), then seeing if the parts collide with a star

This is obviously not very optimised but you could give it a shot I guess (maybe use it as a cool “rendering sequence” when you open it for the first time too?)

1 Like

If anyone’s still interested, I’m using a basic algorithm to generate a full graph of all possible paths between stars, which is assembled into a 2d table filled with distances. I’m using the Prim Algorithm to sort this table and find the Minimum Spanning Tree, read on that here: Prim Algorithm - Finding Minimum Spanning Tree - Graph - DYclassroom | Have fun learning :-)

That sounds like a solution for creating the hyperlane effect, really I think I could just do that by generating beams in pairs of nodes/vertices/stars of the table. What I really could use is a way to generate hyperlanes themselves and keep them from crossing.

Prim’s algorithm worked. Essentially the script finds all connections between stars and selects the two least far connections to make hyperlanes with. You can make that only one connection if you want, though something to keep in mind is that trees that are far away from each other won’t auto-connect. I’m thinking of making a revision to provide for this. DM or reply if you want the script.

3 Likes

Do you still have the script by chance?