Procedure to find all interstellar spaces

General discussion for players of Oolite.

Moderators: another_commander, winston

Post Reply
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2275
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Procedure to find all interstellar spaces

Post by Wildeblood »

There seems to be no way to twiddle the system info of interstellar spaces from JS, so it has to be done with a planetinfo file? What I would like to do, ideally, is read the system info of the current system and of the target system (GRR to recent trunk changes) and set the properties of the inter-system space to the averages of their values. But I fear that can't be done.

So let's say, hypothetically, that I wanted to write a big planetinfo file that included all interstellar destinations as well as all systems. How do I know which combinations of system IDs are real interstellar routes and which are not?

I'd like to discuss a large change to Oolite: setting the sky properties by chart co-ordinates, rather than system ID. Particularly if one could set as few as four locations (in each corner of the chart), but as many as desired, and Oolite would interpolate the values for any intermediate location. Feasible? Stupid?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Procedure to find all interstellar spaces

Post by cim »

Wildeblood wrote:
How do I know which combinations of system IDs are real interstellar routes and which are not?
Something like this should work in 1.81 (in 1.80 you can't read data for the galaxies you aren't in, so you'd need to manually handle the outermost loop)

Code: Select all

for (var g=0;g<=7;g++) {
  for (var i=0;i<=255;i++) {
    var s = System.infoForSystem(g,i);
    for (var j=i+1;i<=255;j++) {
      var e = System.infoForSystem(g,j);
      if (s.distanceToSystem(e) <= 7) {
        log(this.name,g+" "+i+" "+j);
        log(this.name,g+" "+j+" "+i);
      }
    }
  }
}
That gets you all the "natural" interstellar positions.

However, the interstellar position is "last stellar system visited", "destination system of last jump", so with fuel-adding OXPs (or a lot of patience) all others are theoretically possible - and might correspond to quite a range of coordinates depending on the route taken to get to them.
"0 7 7" is easy - misjump from Lave towards Leesti, then misjump again back to Lave, for instance.
Wildeblood wrote:
I'd like to discuss a large change to Oolite: setting the sky properties by chart co-ordinates, rather than system ID. Particularly if one could set as few as four locations (in each corner of the chart), but as many as desired, and Oolite would interpolate the values for any intermediate location. Feasible? Stupid?
Probably can be done, though I'd have to do some research into 2-D interpolation algorithms, but it's also probably easier just to make the interstellar space system infos writable with JS.
V12
Dangerous
Dangerous
Posts: 64
Joined: Thu Sep 19, 2013 12:25 pm

Re: Procedure to find all interstellar spaces

Post by V12 »

In my opinion, this code is better :

Code: Select all

for (var g=0;g<=7;g++) {
  for (var i=0;i<=255;i++) {
    var s = System.infoForSystem(g,i);
    for (var j=i+1;i<=255;j++) {
      var e = System.infoForSystem(g,j);
      if (s.distanceToSystem(e) <= 7) {
        log(this.name,g+" "+i+" "+j);
      }
    }
  }
}
Reverse routes not duplicated
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2275
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Procedure to find all interstellar spaces

Post by Wildeblood »

V12 wrote:
Reverse routes not duplicated
I'll let cim explain why that's wrong if he cares to.

But in practice neither will actually work at all, because 256 or more consecutive log writes will crash Oolite. I know that from experience.

Code: Select all

var message = "";
for (var g=0;g<=7;g++) {
  for (var i=0;i<=255;i++) {
    var s = System.infoForSystem(g,i);
    for (var j=i+1;i<=255;j++) {
      var e = System.infoForSystem(g,j);
      if (s.distanceToSystem(e) <= 7) {
        message += (g+" "+i+" "+j+"\n");
        message += (g+" "+j+" "+i+"\n");
      }
    }
  }
}
log(this.name, message);
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: Procedure to find all interstellar spaces

Post by another_commander »

Wildeblood wrote:
But in practice neither will actually work at all, because 256 or more consecutive log writes will crash Oolite. I know that from experience.
Just run cim's code in the console and it didn't crash under trunk. There is a typo though:

Code: Select all

for (var j=i+1;i<=255;j++) { 
should be

Code: Select all

for (var j=i+1;j<=255;j++) { 
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2275
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Procedure to find all interstellar spaces

Post by Wildeblood »

another_commander wrote:
Wildeblood wrote:
But in practice neither will actually work at all, because 256 or more consecutive log writes will crash Oolite. I know that from experience.
Just ran cim's code in the console and it didn't crash under trunk.
I'm surprised. I used to write similar things when I was experimenting with Distant Suns. Somewhere between 100 & 200 consecutive log writes was the limit on my Win7 machine. I could never do a whole galaxy's worth. I assumed the problem was the OS keeping up with writing to the external file, rather than anything inherent to Oolite. OTOH, compiling one big multi-MB message and writing it to the log in one message never caused a problem.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Procedure to find all interstellar spaces

Post by cim »

V12 wrote:
Reverse routes not duplicated
The duplication is necessary, if you're asking for all locations - "0 7 55" is "interstellar space from a misjump from Lave to Leesti" while "0 55 7" is "interstellar space from a misjump from Leesti to Lave".

The new connection colours feature in 1.81 requires "gal low high" as the order, so for that you do only need half of them.
V12
Dangerous
Dangerous
Posts: 64
Joined: Thu Sep 19, 2013 12:25 pm

Re: Procedure to find all interstellar spaces

Post by V12 »

Hmmm, You are right. I was blind, I missed for (var j=i+1;j<=255;j++)

:oops: :oops: :oops:
Post Reply