More/ larger galaxies

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: More/ larger galaxies

Post by cim »

Norby wrote:
Need to change arithmetics from float to double and cim said it is not so easy but if we get it then we can multiply the interesting destinations.
Though I did later say it was done.

You can get to 10^14 (one hundred thousand million kilometres) in 1.79 without any problems, and 10^15 (one million million kilometres) with only minor cosmetic issues with the exhausts such as you might get anyway near the planet in 1.77. In practice anything over 10^8 is a bit unnecessary, of course: that's already hours of travel at torus speeds.
Pleb wrote:
Another cool idea might be to add more than one sun to a system...
One tricky thing there is that all shaders (both core and OXP) currently assume there is exactly one major light source. (There are many other bits that assume a single sun, too, but that one is the one that can't be fixed just by changing the core)
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: More/ larger galaxies

Post by Pleb »

cim wrote:
One tricky thing there is that all shaders (both core and OXP) currently assume there is exactly one major light source. (There are many other bits that assume a single sun, too, but that one is the one that can't be fixed just by changing the core)
Ah well I assumed it wouldn't be that simple as it hadn't been done before! Would it be possible to designate the sun that is added to a system in the source as the primary sun, and then have it so that you could add another sun in an OXP, and designate this a secondary sun, like when adding planets in OXP? I suppose the main drawback from this would be that it wouldn't have a light source though...
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Tricky
---- E L I T E ----
---- E L I T E ----
Posts: 821
Joined: Sun May 13, 2012 11:12 pm
Location: Bradford, UK. (Anarchic)

Re: More galaxies

Post by Tricky »

Pleb wrote:
Tricky wrote:
If using bytes then yes 256 systems is a hard limit. But you can push the algorithm to create many more systems in one galaxy.
You would have to push it pretty far! As far as I can tell from trial and error, you would have to re-write a massive amount of code to even achieve this... :(
Surprisly not. I've used Ian Bell's Text Elite to generate 1024 systems without changing the base code. The [EliteWiki] Random Number Generator can create up to 32768 systems per galaxy (with caveats).
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: More galaxies

Post by Zireael »

Tricky wrote:
Surprisly not. I've used Ian Bell's Text Elite to generate 1024 systems without changing the base code. The [EliteWiki] Random Number Generator can create up to 32768 systems per galaxy (with caveats).
*eyes gleaming at the possibilities*
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: More/ larger galaxies

Post by Pleb »

Okay just as a proof-of-concept, the following instructions made to the source (I used the current 1.79 trunk code) enables 16 galaxies in an OXP'able way, with the option of enabling or disabling this feature:

First open the OOTypes.h file in the src\Core directory, and look for the following code on line 208:

Code: Select all

kOOMaximumGalaxyID				= 7,
And replace it with the following code:

Code: Select all

kOOMaximumGalaxyID				= 15,
Then open the Universe.m file in the src\Core directory and look for the following code, starting on line 7166:

Code: Select all

gnum++;
g0.a = rotate_byte_left(g0.a);
g0.b = rotate_byte_left(g0.b);
g0.c = rotate_byte_left(g0.c);
g0.d = rotate_byte_left(g0.d);
g0.e = rotate_byte_left(g0.e);
g0.f = rotate_byte_left(g0.f);
And replace it with the following code:

Code: Select all

gnum++;
if (gnum == 8)
{
	Random_Seed new_galaxy_seed;
	new_galaxy_seed = RandomSeedFromString([planetInfo oo_stringForKey:@"galaxy_9_seed"]);
	g0.a = new_galaxy_seed.a;
	g0.b = new_galaxy_seed.b;
	g0.c = new_galaxy_seed.c;
	g0.d = new_galaxy_seed.d;
	g0.e = new_galaxy_seed.e;
	g0.f = new_galaxy_seed.f;
}
else
{
	g0.a = rotate_byte_left(g0.a);
	g0.b = rotate_byte_left(g0.b);
	g0.c = rotate_byte_left(g0.c);
	g0.d = rotate_byte_left(g0.d);
	g0.e = rotate_byte_left(g0.e);
	g0.f = rotate_byte_left(g0.f);
}
if (gnum == 0)
{
	g0.a = 74;
	g0.b = 90;
	g0.c = 72;
	g0.d = 2;
	g0.e = 83;
	g0.f = 183;
}
Then go to line 7190 in the same file and you will see the same code. Replace it with the code above as before.

Now open up the PlayerEntity.m file in the src\Core\Entities directory and look for the following code, starting on line 6213:

Code: Select all

galaxy_number++;
galaxy_number &= 7;

galaxy_seed.a = rotate_byte_left(galaxy_seed.a);
galaxy_seed.b = rotate_byte_left(galaxy_seed.b);
galaxy_seed.c = rotate_byte_left(galaxy_seed.c);
galaxy_seed.d = rotate_byte_left(galaxy_seed.d);
galaxy_seed.e = rotate_byte_left(galaxy_seed.e);
galaxy_seed.f = rotate_byte_left(galaxy_seed.f);
And replace it with the following code:

Code: Select all

galaxy_number++;
	
// check if planetinfo.plist has more than 8 galaxies enabled:
BOOL extra_galaxies = ([[UNIVERSE planetInfo] oo_boolForKey:@"extra_galaxies_enabled"]);
if (extra_galaxies)
{
	// make sure galaxy number goes back to 0 (galaxy 1):
	if (galaxy_number > 15)
	{
		galaxy_number = 0;
	}

	// when jumping to galaxy 9 generate new galaxy seed to generate 8 new galaxies:
	if (galaxy_number == 8)
	{
		Random_Seed new_galaxy_seed;
		new_galaxy_seed = RandomSeedFromString([[UNIVERSE planetInfo] oo_stringForKey:@"galaxy_9_seed"]);
		galaxy_seed.a = new_galaxy_seed.a;
		galaxy_seed.b = new_galaxy_seed.b;
		galaxy_seed.c = new_galaxy_seed.c;
		galaxy_seed.d = new_galaxy_seed.d;
		galaxy_seed.e = new_galaxy_seed.e;
		galaxy_seed.f = new_galaxy_seed.f;
	}
	else
	{
		galaxy_seed.a = rotate_byte_left(galaxy_seed.a);
		galaxy_seed.b = rotate_byte_left(galaxy_seed.b);
		galaxy_seed.c = rotate_byte_left(galaxy_seed.c);
		galaxy_seed.d = rotate_byte_left(galaxy_seed.d);
		galaxy_seed.e = rotate_byte_left(galaxy_seed.e);
		galaxy_seed.f = rotate_byte_left(galaxy_seed.f);
	}

	// when back at galaxy 1 reset galaxy seed to original seed:
	if (galaxy_number == 0)
	{
		galaxy_seed.a = 74;
		galaxy_seed.b = 90;
		galaxy_seed.c = 72;
		galaxy_seed.d = 2;
		galaxy_seed.e = 83;
		galaxy_seed.f = 183;
	}
}
else
{
	// if extra galaxies are not enabled ensure player can only visit the original 8 galaxies:
	galaxy_number &= 7;

	galaxy_seed.a = rotate_byte_left(galaxy_seed.a);
	galaxy_seed.b = rotate_byte_left(galaxy_seed.b);
	galaxy_seed.c = rotate_byte_left(galaxy_seed.c);
	galaxy_seed.d = rotate_byte_left(galaxy_seed.d);
	galaxy_seed.e = rotate_byte_left(galaxy_seed.e);
	galaxy_seed.f = rotate_byte_left(galaxy_seed.f);
}
Now finally, open up the planetinfo.plist file in the Resources\Config directory and add the following two lines of code:

Code: Select all

// Set to yes if you want to enable extra 8 galaxies:
extra_galaxies_enabled = yes;
// Seed used for galaxy 9 and for subsequent 7 turns to generate galaxies 10-16:
galaxy_9_seed = "177 86 161 69 177 103";
These two functions added to the planetinfo.plist file will now allow you to either enable to disable the extra galaxies, and define the seed used for galaxy 9.
Tricky wrote:
Surprisly not. I've used Ian Bell's Text Elite to generate 1024 systems without changing the base code. The [EliteWiki] Random Number Generator can create up to 32768 systems per galaxy (with caveats).
Ah, so for my next trick... :twisted:
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: More/ larger galaxies

Post by Redspear »

Pleb wrote:
These two functions added to the planetinfo.plist file will now allow you to either enable to disable the extra galaxies, and define the seed used for galaxy 9.
Tricky wrote:
Surprisly not. I've used Ian Bell's Text Elite to generate 1024 systems without changing the base code. The [EliteWiki] Random Number Generator can create up to 32768 systems per galaxy (with caveats).
Ah, so for my next trick... :twisted:
Oooh, customisable :D . And with an off-switch no less 8)
I'm gonna have to try that out...

Eagerly awaiting your next trick :shock: (...where's the drool smiley? :P )
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: More/ larger galaxies

Post by Zireael »

(...where's the drool smiley? :P )
Yeah, I think we need it now.

I say merge Pleb's changes into core so that every player can customize the number of galaxies as he/she wishes.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: More/ larger galaxies

Post by Pleb »

So...it would seem that is perfectly easy to generate more than 256 systems per galaxy. I have changed the code to generate 512 systems per galaxy instead of the 256 and this seems to work. However, getting those systems to display on the chart is a different matter:

Image

Image

Image

Image

I'm sure it is possible (after all, isn't everything?) but I haven't yet figured this part out... :(
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: More/ larger galaxies

Post by Redspear »

Pleb wrote:
So...it would seem that is perfectly easy to generate more than 256 systems per galaxy. I have changed the code to generate 512 systems per galaxy instead of the 256 and this seems to work. However, getting those systems to display on the chart is a different matter
Great start :D but it looks like a case of denser galaxies rather than larger ones.

Am I reading that right? :?
Pleb wrote:
I'm sure it is possible (after all, isn't everything?) but I haven't yet figured this part out... :(
That's the spirit :D it's just that some things aren't really practical I suppose. Hopefully this one will be :)

Good luck with it anyway. I really hope you can save those killer mountain monkeys :P
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: More/ larger galaxies

Post by Pleb »

Redspear wrote:
Great start :D but it looks like a case of denser galaxies rather than larger ones.

Am I reading that right? :?
Yes, my initial experiment was to try to add another 256 systems to the existing 256 systems in a galaxy. The systems are currently on a 256x256 (0-255) grid, which is then put onto a 256x512 area when displayed on the chart using an offset. A lot of the things in Oolite are generated using the random number generator, generating numbers from 0-255. I will next attempt to increase this 256x256 grid to see how a larger galaxy pans out, but it would be handy if I could get the extra systems to display properly on the chart first!
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: More/ larger galaxies

Post by cim »

Pleb wrote:
it would be handy if I could get the extra systems to display properly on the chart first!
GuiDisplayGen.m, drawGalaxyChart, look at all the hard-coded 256s in the for loops. Similarly in drawStarChart in the same file.

A patch that set those and the similar uses in Universe.m to all be equal to a constant, and then set that constant equal to 256, would almost certainly be accepted for the main code.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: More/ larger galaxies

Post by Redspear »

Pleb wrote:
I will next attempt to increase this 256x256 grid to see how a larger galaxy pans out, but it would be handy if I could get the extra systems to display properly on the chart first!
It sounds like you've got your priorities right there :lol:
cim wrote:
GuiDisplayGen.m, drawGalaxyChart, look at all the hard-coded 256s in the for loops. Similarly in drawStarChart in the same file.

A patch that set those and the similar uses in Universe.m to all be equal to a constant, and then set that constant equal to 256, would almost certainly be accepted for the main code.
Jolly useful this 'cim' chap isn't he? :wink: *

* Apologies if not a he... :oops:
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: More/ larger galaxies

Post by Pleb »

cim wrote:
GuiDisplayGen.m, drawGalaxyChart, look at all the hard-coded 256s in the for loops. Similarly in drawStarChart in the same file.

A patch that set those and the similar uses in Universe.m to all be equal to a constant, and then set that constant equal to 256, would almost certainly be accepted for the main code.
Setting this to a constant and setting the contant to 256 is accepted. However in order to generate the 512 systems the constant needs to equal 512 surely? This is how I was able to generate the extra systems in the first place. Unfortunately, doing this still doesn't enable them to be drawn on the chart properly, and it also causes havoc with the route finder:

Image

I understand why the route finder gets funny, because the formula it uses to calculate this uses 256 and change this to 512 and it messes it up (as it still thinks there are only 256 systems). However I can't understand why I cannot get it to draw the extra systems, as if it could then I'm sure the problem with the route finder formula would be fixed as well...
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: More/ larger galaxies

Post by cim »

Pleb wrote:
However in order to generate the 512 systems the constant needs to equal 512 surely?
Yes, of course. Sorry, what I mean is that if you found the various hard-coded 256's that needed to be changed and set them to a constant, we would happily take that patch even though we would keep the constant at 256, and you could set it to whatever you wanted.

As for the problems ... that function calls in Universe.m

Code: Select all

- (Random_Seed) systemSeedForSystemNumber:(OOSystemID)n
{
	return systems[(unsigned)n & 0xFF];
}
The & 0xFF there is restricting the values returned (which is necessary to prevent memory overflows, so you have to replace it with a different bounds-check). You probably want to do a search for 255 and 0xFF as well as 256, in case there are other similar cases.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: More/ larger galaxies

Post by Pleb »

cim wrote:
The & 0xFF there is restricting the values returned (which is necessary to prevent memory overflows, so you have to replace it with a different bounds-check). You probably want to do a search for 255 and 0xFF as well as 256, in case there are other similar cases.
D'oh! I didn't even think of that, even though I've seen it before never occured to me that it was what was causing the issue! I was basically there, but this one line of code was holding me back! Once I changed it to 0x1FF it works fine:

Image

Image

Image

As you can see, it's now an overcrowded galaxy! And if you look at galaxy 7, the galactic rift has long gone:

Image

At the very least, there isn't anywhere that isn't connected now! The next test will be to see if its possible to enlarge the galaxy and spread out these systems a bit. And now I know the sort of things to look out for in case it all goes wrong again, thanks cim!
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
Post Reply