Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

[UPDATED RELEASE 03-07-2014] Superhub V1.6 OXZ

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

Moderators: winston, another_commander

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Looking at the code again I notice that it defines the situations in which no Superhub shall be added. Which already means that it uses the opposite end of the pseudo-random spectrum, so the Superhubs are created in the systems with 0.5 < pseudoRandomNumber < 1 instead of the systems with pseudoRandomNumber < 0.5.

What I often do is to set an arbitrary range between 0 and 1, and if I want to add different kinds of things I set different arbitrary sets. For instance:

Code: Select all

if(system.pseudoRandomNumber >= 0.1 && system.pseudoRandomNumber < 0.6)
{
	add one kind of thing
}
if(system.pseudoRandomNumber >= 0.4 && system.pseudoRandomNumber < 0.9)
{
	add another kind of thing
}
Both kinds of things are added with a 0.5-probability, but there is only a 0.2-probability that they both will appear independently in the same system. Obviously by changing the arbitrary values you can make that more or less likely.

If you have lower probabilities for each object you can put a lot of variants in the scale between 0 and 1, and it is your choice whether two objects have a chance to appear in the same system or not.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

I was right – my solution was indeed broken.

Here’s a simpler solution than PhantorGoth’s (which has been properly tested and everything). It scrambles the pseudoRandomNumber by using it and an arbitrary “salt” value as the seed of a simple psuedo-random number generator. Each salt gives a different per-system random value in the same range as pseudoRandomNumber.

Code: Select all

this.scrambledPseudoRandom = function(salt)
{
    // Convert from float in [0..1) with 24 bits of precision to integer.
    var n = Math.floor(system.pseudoRandomNumber * 16777216.0);
    
    // Add salt to enable generation of different sequences.
    n += salt;
    
    // Scramble with basic LCG psuedo-random number generator.
    n = (214013 * n + 2531011) & 0xFFFFFFFF;
    n = (214013 * n + 2531011) & 0xFFFFFFFF;
    n = (214013 * n + 2531011) & 0xFFFFFFFF;
    
    // Convert from (effectively) 32-bit signed integer to float in [0..1).
    return n / 4294967296.0 + 0.5;
}
Usage:

Code: Select all

if (this.scrambledPseudoRandom(344336) < 0.5…
Obviously 344336 should be replaced with a different randomly-selected value in each context this is used.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Somehow I think I'll just stick to things like system.ID for mine. This is getting a little Heath-Robinson.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Thargoid wrote:
Somehow I think I'll just stick to things like system.ID for mine. This is getting a little Heath-Robinson.
But will lead to the mentioned problems. If everybody adds their stuff in systems with system.ID < n, then all system below n will look the same and have all the stuff in them, and all systems above n will look the same and have no stuff at all in them.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

I strongly suggest not using system.ID or any other stable property, for the reasons already mentioned. While it took a while to get there, my last approach is tested, correct, easy to use and solves the problem.
User avatar
JazHaz
---- E L I T E ----
---- E L I T E ----
Posts: 2991
Joined: Tue Sep 22, 2009 11:07 am
Location: Enfield, Middlesex
Contact:

Post by JazHaz »

Have created a wiki page for this OXP:

http://wiki.alioth.net/index.php/Superhub
JazHaz

Gimi wrote:
drew wrote:
£4,500 though! :shock: <Faints>
Cheers,
Drew.
Maybe you could start a Kickstarter Campaign to found your £4500 pledge. 8)
Thanks to Gimi, I got an eBook in my inbox tonight (31st May 2014 - Release of Elite Reclamation)!
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

It’s a bad idea to put documentation inside an OXP. Mac users will not see it, and other users are likely not to look.
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Post by pagroove »

Ahruman wrote:
It’s a bad idea to put documentation inside an OXP. Mac users will not see it, and other users are likely not to look.
For all my next versions of OXP's I will put the documentation in the main .zip file. to make it also user-friendly for Apple etc.
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Superhub V1.2. slight update

Post by Commander McLane »

There is a small oversight in the Superhub spawning script: it doesn't check for system.isInterstellarSpace, therefore it throws an error on misjumps, because it can't find the main planet or its station.

Fix: add

Code: Select all

|| system.isInterstellarSpace
to the first if-statement.
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Re: Superhub V1.2. slight update

Post by pagroove »

Thanx,

Noted for the next update! :mrgreen:
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Superhub V1.2. slight update

Post by Switeck »

Any chance Superhub can be redesigned to use smaller than the 4096x4096 texture file it currently uses?

Most of the texture appears to be black "dead space", so if it was all crammed together it looks like it'd fit in 2048x2048.

I had one Oolite crash that said it couldn't allocate 64 MB of memory for that texture alone. I attribute Superhub to be the largest contributor of the huge memory spikes I'm seeing from rapid wormhole-jumping. During rapid wormhole-jumping, the game seems to allocate memory for Superhub's massive texture file a few times over until garbage collection can "catch up".
Were the texture reduced to 2048x2048, it might fit within 16 MB of memory.

As for when to spawn Superhubs, I use this code:

Code: Select all

	if(system.techLevel > 10 && system.economy < 4 && system.government > 4 && system.countShipsWithRole("pagroove_superhub") < 1) {
		this.xOffset = (Math.random() * 10000) + 10000; // x offset between 10 and 20km
		this.yOffset = (Math.random() * 10000) + 10000; // y offset between 10 and 20km
		if(Math.random() > 0.5) this.xOffset = -this.xOffset; // 50:50 chance of offsetting in the other direction
		if(Math.random() > 0.5) this.yOffset = -this.yOffset; // 50:50 chance of offsetting in the other direction
		system.addShips("pagroove_superhub", 1, system.mainStation.position.add(Vector3D(this.xOffset, this.yOffset, 0).fromCoordinateSystem("abs")));
		return;
	}
I figure Communist systems would not allow such a capitalist-style station in their systems. Their Gulags and Factories are good enough for them. :mrgreen:
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Re: Superhub V1.2. slight update

Post by pagroove »

I think that is a good idea to resize the texture indeed and repackage the OXP. :D
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Re: Superhub V1.2. slight update

Post by pagroove »

Switeck wrote:
figure Communist systems would not allow such a capitalist-style station in their systems. Their Gulags and Factories are good enough for them. :mrgreen:
Unless it's a 'Chinastyle' communist system.
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Re: Superhub V1.2. slight update

Post by pagroove »

@Switeck. BTW in the Superhub v1.2 there is already a smaller texture included. It resides in the texture directory in the sub dir 'smaller version'. You have to get this texture and copy it over the texture in the texture folder.
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
User avatar
pagroove
---- E L I T E ----
---- E L I T E ----
Posts: 3035
Joined: Wed Feb 21, 2007 11:52 pm
Location: On a famous planet

Re: Superhub V1.2. slight update

Post by pagroove »

mm :( last night I came across a Superhub and I can confirm that the rescaled texture is not good (buggy). I believe a few pages back Commander McLane posted a link to a correct version of the texture.
For P.A. Groove's music check
https://soundcloud.com/p-a-groove
Famous Planets v 2.7. (for Povray)
Image
https://bb.oolite.space/viewtopic.php?f=4&t=13709
Post Reply