Oolite Bulletins

For information and discussion about Oolite.
It is currently Sat Sep 22, 2018 7:49 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Sep 03, 2018 2:59 pm 
Offline
Mostly Harmless
Mostly Harmless

Joined: Mon Sep 03, 2018 11:06 am
Posts: 3
First of all: thanks to the Oolite team for their detailed explanation of the planet generating algorithm (here and here).

I have started building a little "planet browser" for the Sinclair ZX81 (which of course is not really a "port" of Oolite, but I hope my thread somehow fits into this sub-forum). A few things are still not clear to me, maybe these could be further explained in the Wiki:


1. Planet Names: why are some of the two-character parts left out? See for example the second planet "QUBE": the second part of the name has the value 0 and is therefore empty, that's clear. But the fourth part in the w2 hsb would be 1101 (decimal 13), which would be "DI". How do you decide that this part is not included in the planet's name?


2. Planet radius: according to the wiki, for the first planet TIBIDIED it should be 256*(11+7) = 4608. The original BBC game and Oolite show this value as 4610 (obviously rounded).
The Elite DOS games (Elite and Elite Plus) show the radius of TIBIDIED to be 7103 km. I would like to optionally generate the DOS radius value. Has someone already figured out how to do this?

BTW, the Amiga version shows the radius of TIBIDIED to be 38114 km, which seems quite uncomfortable for an earthling like me (too much gravity :wink:)...


3. The following values are not explained in the wiki:

Tech. Level
Population
Inhabitants Type
Productivity

Can you please explain what bit patterns are used to determine these values?


Many thanks in advance.
Robert (Commander, Rating Harmless)


Top
   
PostPosted: Fri Sep 07, 2018 10:18 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 5233
Hi and welcome. Sorry for the delayed reply, but Oolite has moved away from the procedural planet data generation since version 1.82, so I had to go back and find the source code of v1.80 in order to help you with your questions. Unfortunately, with 1.80 being so old, it is a bit difficult to test stuff. So I will just provide the relative algorithms here and I hope they will be of help.

So, the name generation was handled by the generateSystemName method, which reads as follows:
Code:
- (NSString *) generateSystemName:(Random_Seed) s_seed
{
	int i;
	
	NSString			*digrams = [self descriptionForKey:@"digrams"];
	NSString			*apostrophe = [self descriptionForKey:@"digrams-apostrophe"];
	NSMutableString		*name = [NSMutableString string];
	int size = 4;
	
	if ((s_seed.a & 0x40) == 0)
		size = 3;
	
	for (i = 0; i < size; i++)
	{
		NSString *c1, *c2;
		int x = s_seed.f & 0x1f;
		if (x != 0)
		{
			x += 12;	x *= 2;
			c1 = [digrams substringWithRange:NSMakeRange(x,1)];
			c2 = [digrams substringWithRange:NSMakeRange(x+1,1)];
			[name appendString:c1];
			if (![c2 isEqual:apostrophe])		[name appendString:c2];
		}
		rotate_seed(&s_seed);
	}
	
	return [name capitalizedString];
}
It looks that things might get dropped under certain conditions related to the system seed a and f components, as well as when the second character of the selected digram is the apostrophe.

The rest of the system parameters were calculated in the generateSystemData method using the system seed in the following way:
Code:
OOGovernmentID government = (s_seed.c / 8) & 7;
	
OOEconomyID economy = s_seed.b & 7;
if (government < 2)
	economy = economy | 2;

OOTechLevelID techlevel = (economy ^ 7) + (s_seed.d & 3) + (government / 2) + (government & 1);
	
unsigned population = (unsigned)(techlevel * 4) + government + economy + 1;

unsigned productivity = ((economy ^ 7) + 3) * (government + 4) * population * 8;
	
unsigned radius = (((s_seed.f & 15) + 11) * 256) + s_seed.d;
Hope this helps. Feel free to ask if something requires further clarification.


Top
   
PostPosted: Sun Sep 09, 2018 1:36 pm 
Offline
Mostly Harmless
Mostly Harmless

Joined: Mon Sep 03, 2018 11:06 am
Posts: 3
Thanks, that helps a lot! Now I know why I couldn't find anything helpful in the current Oolite source.

Could you please explain what parts of the seed values w0, w1 and w2 the s_seed.a through s_seed.... values correspond with? I assume that each one is either the hsb or lsb of one of the three seed words, but in what order?

The planet radius is clear now, as I can see you have to add the planet's x variable. So it goes like this:
TIBIDIED:
256*(11+7)+2 = 4610
QUBE:
256*(11+10)+152 = 5528

Population and Productivity are easy to calculate as they are simply based on the other values.

And can you please search the old source for how the Inhabitants Type (e.g. "Human Colonials") is determined?


Top
   
PostPosted: Sun Sep 16, 2018 2:54 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 5233
Not really sure what the w0, w1 etc. refer to. Not sure about the correspondence, as I am not famiiar with the old Elite code.

Regarding the second question, here is the source of the method that was doing the system descriptions in 1.80. The arrays under the system_description container array in descriptions.plist were used to build up the system description phrase.
Code:
NSString *OOExpandDescriptionString(Random_Seed seed, NSString *string, NSDictionary *overrides, NSDictionary *legacyLocals, NSString *systemName, OOExpandOptions options)
{
	if (string == nil)  return nil;
	
	OOStringExpansionContext context =
	{
		.seed = seed,
		.systemName = [systemName retain],
		.overrides = [overrides retain],
		.legacyLocals = [legacyLocals retain],
		.isJavaScript = options & kOOExpandForJavaScript,
		.convertBackslashN = options & kOOExpandBackslashN,
		.useGoodRNG = options & kOOExpandGoodRNG
	};
	
	// Avoid recursive %I expansion by pre-seeding cache with literal %I.
	if (options & kOOExpandDisallowPercentI) {
		context.systemNameWithIan = @"%I";
	}
	
	OORandomState savedRandomState;
	if (options & kOOExpandReseedRNG)
	{
		savedRandomState = OOSaveRandomState();
		OOSetReallyRandomRANROTAndRndSeeds();
	}
	
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSString *result = nil, *intermediate = nil;
	@try
	{
		// TODO: profile caching the results. Would need to keep track of whether we've done something nondeterministic (array selection, %R etc).
		if (options & kOOExpandKey)
		{
			intermediate = ExpandStringKey(&context, string, kStackAllocationLimit, kRecursionLimit);
		}
		else
		{
			intermediate = Expand(&context, string, kStackAllocationLimit, kRecursionLimit);
		}
		if (!context.hasPercentR)
		{
			result = intermediate;
		}
		else
		{
			result = ExpandPercentR(&context, intermediate);
		}
	}
	@finally
	{
		[context.systemName release];
		[context.overrides release];
		[context.legacyLocals release];
		[context.systemNameWithIan release];
		[context.randomNameN release];
		[context.randomNameR release];
		[context.systemDescriptions release];
	}
	
	if (options & kOOExpandReseedRNG)
	{
		OORestoreRandomState(savedRandomState);
	}
	
	result = [result copy];
	[pool release];
	return [result autorelease];
}
The string that sets the description domino going is in descriptions.plist: "system-description-string" = "[14] is [22].";. This, together with the system seed is passed to the above method for expansion.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited