where in the code?
Moderators: winston, another_commander
- maaarcooose
- ---- E L I T E ----
- Posts: 397
- Joined: Sun May 29, 2011 9:36 pm
- Location: Devon, UK
- Contact:
where in the code?
Not sure if this is the best section on the forum for discussions about the code of OOlite itself but here goes.
Can someone direct me to where in the code there is a function that would return planet details.
Seeing as everything about a planet is scripted, I'm guessing there should be a function that you can just pass the galaxy and planet number and it will return all the details about that planet.
With the little utility I'm writing, I currently read info for the planets from a group of CSV files, but I'd like to just replicate the internal OOlite function. The CSV files I have do not have all details and the downloadable excel file of the galaxies doesn't have all the information in them. The list of planets on: http://wiki.alioth.net/index.php/Oolite ... t/Galaxy_1 does seem to show everything, but not in a particularly handy format.
Anyone help me here or shall I just bite the bullet and create my own CSV's from the WIKI info?
Cheers.
!m!
Can someone direct me to where in the code there is a function that would return planet details.
Seeing as everything about a planet is scripted, I'm guessing there should be a function that you can just pass the galaxy and planet number and it will return all the details about that planet.
With the little utility I'm writing, I currently read info for the planets from a group of CSV files, but I'd like to just replicate the internal OOlite function. The CSV files I have do not have all details and the downloadable excel file of the galaxies doesn't have all the information in them. The list of planets on: http://wiki.alioth.net/index.php/Oolite ... t/Galaxy_1 does seem to show everything, but not in a particularly handy format.
Anyone help me here or shall I just bite the bullet and create my own CSV's from the WIKI info?
Cheers.
!m!
Trading computers and writing stuff....
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
Re: where in the code?
I think Oolite still replicates the original pseudo-random planet info generation that was used in the original 8-bit machines, that is to say, there is a galaxy seed, from this, the planet's location, size, description and name are generated. These can be subsequently over-written by a player created plist, but you won't find in the code all those descriptions etc...maaarcooose wrote:Not sure if this is the best section on the forum for discussions about the code of OOlite itself but here goes.
Can someone direct me to where in the code there is a function that would return planet details.
Seeing as everything about a planet is scripted, I'm guessing there should be a function that you can just pass the galaxy and planet number and it will return all the details about that planet.
With the little utility I'm writing, I currently read info for the planets from a group of CSV files, but I'd like to just replicate the internal OOlite function. The CSV files I have do not have all details and the downloadable excel file of the galaxies doesn't have all the information in them. The list of planets on: http://wiki.alioth.net/index.php/Oolite ... t/Galaxy_1 does seem to show everything, but not in a particularly handy format.
Anyone help me here or shall I just bite the bullet and create my own CSV's from the WIKI info?
Cheers.
!m!
I know that doesn't help, but it may be possible to extract and convert the galaxy generation code and convert that into another format...
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.
- maaarcooose
- ---- E L I T E ----
- Posts: 397
- Joined: Sun May 29, 2011 9:36 pm
- Location: Devon, UK
- Contact:
Re: where in the code?
Indeed, that's what I was hoping to do. At the moment, I'm creating a group of CSV files. I think they will still be useful.DaddyHoggy wrote:
I know that doesn't help, but it may be possible to extract and convert the galaxy generation code and convert that into another format...
I'd just like to call a function and that function replicates the random number generators.
!m!
Trading computers and writing stuff....
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: where in the code?
You could use JS and the console to write all planet info to a log file. I think most relevant stuf is available through SystemInfo This includes all (or most) info from planetInfo.plist
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- maaarcooose
- ---- E L I T E ----
- Posts: 397
- Joined: Sun May 29, 2011 9:36 pm
- Location: Devon, UK
- Contact:
Re: where in the code?
Okay, I'll take a look at that.
In the planet list, http://wiki.alioth.net/index.php/Oolite ... t/Galaxy_1 what is the HC value for each planet?
!m!
In the planet list, http://wiki.alioth.net/index.php/Oolite ... t/Galaxy_1 what is the HC value for each planet?
!m!
Trading computers and writing stuff....
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: where in the code?
Hub Count is not a property of planets, it is just an result of building the system. But you can count the number of systems in 7LY reach. That should give the same result (At least I think that both use the same number rounding)maaarcooose wrote:what is the HC value for each planet?
!m!
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- maaarcooose
- ---- E L I T E ----
- Posts: 397
- Joined: Sun May 29, 2011 9:36 pm
- Location: Devon, UK
- Contact:
Re: where in the code?
Makes sense.
It seems to match the number of systems in 7Ly range.
Interestingly during my programming of the jumps within range, I decided to do it by calculating the distances between the systems instead of using the data from the files. To get the all the jumps, I have to use 7.1 as my range. It might be down to rounding issues but I imagine the original BBC version only calculated in integers.
Even at this number, I think some jump routes are incorrect, missing or where they shouldn't be. 7.0 misses a couple, and 7.1 adds one that shouldn't be there.
I'm guessing it's due to my scaling up the X,Y values and that the X value is doubled.
!m!
It seems to match the number of systems in 7Ly range.
Interestingly during my programming of the jumps within range, I decided to do it by calculating the distances between the systems instead of using the data from the files. To get the all the jumps, I have to use 7.1 as my range. It might be down to rounding issues but I imagine the original BBC version only calculated in integers.
Even at this number, I think some jump routes are incorrect, missing or where they shouldn't be. 7.0 misses a couple, and 7.1 adds one that shouldn't be there.
I'm guessing it's due to my scaling up the X,Y values and that the X value is doubled.
!m!
Trading computers and writing stuff....
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: where in the code?
Yes, to obtain the same connections as the original, one must use the same rounding as the original. In Oolite its calculated as:maaarcooose wrote:It might be down to rounding issues but I imagine the original BBC version only calculated in integers.
!m!
Code: Select all
OOINLINE double distanceBetweenPlanetPositions ( int x1, int y1, int x2, int y2)
{
int dx = x1 - x2;
int dy = (y1 - y2)/2;
int dist = sqrtf(dx*dx + dy*dy); // N.b. Rounding error due to truncation is desired.
return 0.4 * dist;
}
Last edited by Eric Walch on Mon Sep 05, 2011 12:57 pm, edited 1 time in total.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
Re: where in the code?
Although a ship's maximum range is 7.0LY there are no systems that are exactly 7.0LY from each other - the original 8-bit systems had increments of 0.4 LY for range - so systems would go 6.8 to 7.2 LY apart...
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.
- Mauiby de Fug
- ---- E L I T E ----
- Posts: 847
- Joined: Tue Sep 07, 2010 2:23 pm
Re: where in the code?
Huh! I had an idea for an oxp which put things in a system depending on the system data (for example, a monitoring station orbiting the sun in planets ravaged/scourged/plagued by frequent/unpredictable/deadly solar activity) and reckoned it would be nice to be able to sort the planet descriptions by things like that, eg bring up a list of those with earthquakes, good food, not worth going to... So I manually went about inputting the data from G1 into a spreadsheet. I'd done about 200 or so planets when my computer crashed whilst the file was open and corrupted the file, and the only backup I had was one with 30 planets done. So I gave up on the idea of doing it manually and googled to find a way to auto-input into a spreadsheet and discovered CSVs. I've been using regex matching to try and format the stuff copied from the wiki and delete things I don't want, but that still leaves a lot to go through manually to get it into the format I originally wanted. And I've now had the idea to vary what I originally had planned by using data other than simply the planet descriptions. So what with that and my laptop being an the verge of complete death, i haven't got very far...maaarcooose wrote:With the little utility I'm writing, I currently read info for the planets from a group of CSV files, but I'd like to just replicate the internal OOlite function. The CSV files I have do not have all details and the downloadable excel file of the galaxies doesn't have all the information in them. The list of planets on: http://wiki.alioth.net/index.php/Oolite ... t/Galaxy_1 does seem to show everything, but not in a particularly handy format.
Bugger! Wish I'd thought of that earlier! That's inspired!Eric Walch wrote:You could use JS and the console to write all planet info to a log file. I think most relevant stuf is available through SystemInfo This includes all (or most) info from planetInfo.plist
- maaarcooose
- ---- E L I T E ----
- Posts: 397
- Joined: Sun May 29, 2011 9:36 pm
- Location: Devon, UK
- Contact:
Re: where in the code?
Interesting!Eric Walch wrote:Yes, to obtain the same connections as the original, one must use the same rounding as the original. In Oolite its calculated as:maaarcooose wrote:It might be down to rounding issues but I imagine the original BBC version only calculated in integers.
!m!But I assume Oolites filtering by distance uses the same formula. When examining closely, this formula excludes all distances ending on an odd number. So 7.1 will be impossible as result.Code: Select all
OOINLINE double distanceBetweenPlanetPositions ( int x1, int y1, int x2, int y2) { int dx = x1 - x2; int dy = (y1 - y2)/2; int dist = sqrtf(dx*dx + dy*dy); // N.b. Rounding error due to truncation is desired. return 0.4 * dist; }
I've come at it a different way.
I plot all the planets, storing the coordinates as I plot them on the grid, then I use the plotted coordinates to work out the distance, not the actual X,Y value.
Code: Select all
Public Sub plotPlanets()
For i = 0 To 255
For k = 0 To 12
planetData(k) = Me.galaxyData.Rows.Item(i).Cells(k).Value.ToString()
'GalaxyName.Text = planetData(k)
Next k
drawingPoint.X = ((Int(planetData(2)) + 1) * 4) - 4
drawingPoint.Y = ((Int(planetData(3)) + 1) * 2) - 2
g.DrawRectangle(redPen, drawingPoint.X, drawingPoint.Y, 2, 2)
Me.galaxyData.Rows.Item(i).Cells(13).Value = drawingPoint.X + 1
Me.galaxyData.Rows.Item(i).Cells(14).Value = drawingPoint.Y + 1
g.DrawEllipse(greenPen, drawingPoint.X - 2, drawingPoint.Y - 2, 6, 6)
Next i
End Sub
Public Sub plotJumpRoutes()
For i = 0 To 255
For l = 0 To 14
planetDataStart(l) = Me.galaxyData.Rows.Item(i).Cells(l).Value.ToString()
Next l
startPoint.X = Int(planetDataStart(13))
startPoint.Y = Int(planetDataStart(14))
For k = 0 To 255
For l = 0 To 14
planetDataEnd(l) = Me.galaxyData.Rows.Item(k).Cells(l).Value.ToString()
Next l
If (i <> k) Then
xd = Int(planetDataEnd(13)) - Int(planetDataStart(13))
yd = Int(planetDataEnd(14)) - Int(planetDataStart(14))
distance = Math.Sqrt(xd * xd + yd * yd)
If distance <= Int(jumpDistance.Text) Then
endPoint.X = Int(planetDataEnd(13))
endPoint.Y = Int(planetDataEnd(14))
g.DrawLine(yellowPen, startPoint, endPoint)
End If
End If
Next k
Next i
End Sub
Yes I am programming in VB. Quick and dirty programming, mmmmmm.
!m!
Trading computers and writing stuff....
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php
Website: http://www.theramist.co.uk/
OOliteInfo: http://www.theramist.co.uk/ooliteinfo/oo.php