Topic: Hexed

Greetings,

I have returned to the game from a long absence and noted that all mapping tools have been defunct.  This is mostly due to the great amount of features that have been added to our standard map.  None the less I hit the tool shed to build my own map utility because I am odd that way.

Any who the idea hit me about using hexes for universe layouts as opposed to the current grid.  The benefit of a hex grid is that each system has 6 neighbors instead of 4.  Not only does this tighten up the universe by making travel times to non-parallel systems quicker, but it is also more realistic and imho... a bit nicer to look at.

So what am I crowing about?  Using the current StarBurst Map, I recreated it in hex style here...

https://beowolfe.itch.io/imperial-confl … ZKcRYoQfCc

Enjoy!

2 (edited by LiGhTGuNs 04-May-2016 23:21:46)

Re: Hexed

Could you give an example of how you would calculate travel times in this grid? I like the idea.

~Attacking is a Skill~
~Defending is an Art~

Re: Hexed

Hi LightGuns,

It works the same as the current system.  By using Pythagoras Theorem to calculate the magnitude of a vector.

That sounds like a mouthful so lets use a picture.

https://www.dropbox.com/s/jtd2yj2177kpw … e.png?dl=0

In this picture lets say the circle has a radius of 1 unit.

Notice in the Hex set up that the center point of each hex is equidistant from the center of the middle hex.  Each hex is 1 unit away.   For the squares the corners are not equidistant - thats why corner movements cost you an extra tick.


So.... Pythagoras Theorem is a^2+b^2=c^2,  c is our magnitude or distance between the center square and corner square


For the corner cube thats 1^2+1^2=c^2, or C=1.41 (boo, thats way its 2 ticks to travel)

For the hex set up, .5^2+.86^2=c^2 ...c=1!

Re: Hexed

I was thinking more along the line of coding it. Currently one can just use Pythagoras theorem on the x and y coordinates.

In the hex setup the system numbers won't be representative of the real coords because the grid is not orthogonal.

Also warping the map seems a challenge.

~Attacking is a Skill~
~Defending is an Art~

Re: Hexed

Coding is not difficult.

This is code for a Square grid

//Universe size
int width=100;
int height=100;

        //create square layout
        for (int y = 1; y <= width; y++)
        {
            for (int x = 1; x <= width; x++)
            {
                sector.Coordx=x;
                sector.Coordy=y;
                sector.x = x;
                sector.y = y;
            }
        }
/////////////////////////////////////////////////////////
Here would be code for a Hex grid we need to offset ever other row and as you mentioned the y coord is not a full unit.  The code for that would look like this....

//Universe size
int width=100;
int height=100;
float xOffSet=1.72;
float yOffset=1.5;

       //create hex layout
        for (int y = 1; y <= width; y++)
        {
            float oddRowMod = xOffSet / 2;
            if (y % 2 == 0)
            {
                oddRowMod = 0;
            }
            for (int x = 1; x <= width;x++)
            {
                hexScript sectorHex = GOsectorHex.GetComponent<hexScript>();
                sector.coordx=x * xOffSet+oddRowMod;
                sector.coordy=y * yOffSet;
                sector.x = x;
                sector.y = y;
            }
        }



For galaxy wrap the math stays the same, you use the sector.coordx and sector.coordy to figure out travel times.

Re: Hexed

/me takes a note... if you add math or code to post, people will TL;DR it.  tongue

7 (edited by LiGhTGuNs 25-May-2016 23:38:22)

Re: Hexed

Read it, I think I  understand it,  don't find the coding particularly elegant. Basically you internally are still working with a square grid,  but are offsetting the pieces to fall in place.  This makes for decimal coords.

In the hex system you probably don't want to show coords like 99.23,22.68:6 to the user. You could probably do without, but I like the fact that I can calculate travel time based on coords. I'd prefer integer coords.

I was more or less expecting a native hex implementation.

Your proposal got me reading up on http://www.redblobgames.com/grids/hexagons

Anyway, to make this implementation ready I think you have to make the coding already plug and play.  Meaning:
-Adjusted coding to render a galaxy
-Adjusted coding to retrieve travel time
-Adjusted coding for system coordinates.
-Adjusted coding for planet coords
-Probably a dozen other things that use coords that are now expecting integers.

Switching away from integers could drain site performance as well. Processing floats instead of integers takes more memory and more processing power.

~ above comments only based on my limited programming skills: two courses in machine coding and java coding over 12 years ago as part of Bachelor electrical engineering. Forgive me if it does not make sense smile

~Attacking is a Skill~
~Defending is an Art~

Re: Hexed

Absolutely love the wealth of info from http://www.redblobgames.com/grids/hexagons.  Thanks for the link LG smile