Page 7 of 12

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 4:08 am
by Wildeblood
Regarding what makes a good galaxy, I take the exact opposite view: don't worry at all about the values generated for individual systems, because they can all be tweaked with a planetinfo.plist. The important thing is the actual galaxy layout, and the most important trap to watch for is zero-separation system pairs, where one becomes unreachable.

Here's another challenge to consider:-
screenbackgrounds.plist wrote:
{
short_range_chart = "oolite-short-range-chart.png";
long_range_chart = "oolite-long-range-chart.png";
system_data_nova = "oolite-nova-system.png";

/* // This section is commented out, and not used by standard Oolite.
// Use the following settings to add custom images to Oolite's screens

intro = "intro.png"; // background for the ships at game start
status = "status.png";
status_docked = "status-docked.png"; // if not defined, same as status
status_in_flight = "status-in-flight.png"; // if not defined, same as status
status_red_alert = "status-red-alert.png"; // if not defined, same as status
report = "report.png"; // if not defined, same as status_docked

manifest = "manifest.png";
equip_ship = "equip-ship.png";
mount_weapon = "mount-weapon.png"; // if not defined, same as equip_ship
shipyard = "shipyard.png";

long_range_chart1 = "long-range-chart1.png"; // if not defined, same as long_range_chart
long_range_chart2 = "long-range-chart2.png"; // if not defined, same as long_range_chart
long_range_chart3 = "long-range-chart3.png"; // if not defined, same as long_range_chart
long_range_chart4 = "long-range-chart4.png"; // if not defined, same as long_range_chart
long_range_chart5 = "long-range-chart5.png"; // if not defined, same as long_range_chart
long_range_chart6 = "long-range-chart6.png"; // if not defined, same as long_range_chart
long_range_chart7 = "long-range-chart7.png"; // if not defined, same as long_range_chart
long_range_chart8 = "long-range-chart8.png"; // if not defined, same as long_range_chart

system_data = "system-data.png";
...

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 8:53 am
by Pleb
Extra values can be added into the code to accomodate the new galaxies, so they would read as

Code: Select all

long_range_chart9 = "long-range-chart9.png"; // if not defined, same as long_range_chart
long_range_chart10 = "long-range-chart10.png"; // if not defined, same as long_range_chart
long_range_chart11 = "long-range-chart11.png"; // if not defined, same as long_range_chart
long_range_chart12 = "long-range-chart12.png"; // if not defined, same as long_range_chart
long_range_chart13 = "long-range-chart13.png"; // if not defined, same as long_range_chart
long_range_chart14 = "long-range-chart14.png"; // if not defined, same as long_range_chart
long_range_chart15 = "long-range-chart15.png"; // if not defined, same as long_range_chart
long_range_chart16 = "long-range-chart16.png"; // if not defined, same as long_range_chart
I will look at the code tonight and post up the relevant changes that need to be made. Would help if I had access to the code at work as I don't do much on a Friday but I think our IT department would have something to say if they caught me downloading it!

Also the only reason I was trying to find a galaxy seed that had everything needed in it was so that modifications to the planetinfo.plist would not be neccesary. I've been playing around with other parts of the code for my own ammusement, such as without having to write an OXP to increase Thargoid chances in specific galaxies or increasing the general traffic in systems. But again I would see this as OXP territory and am simply trying out new ideas in the source code for my own enjoyment.

Have also theorised about multiple start locations, but struggling to figure out a way of setting a variable in one file and recalling it in another - for example, in a file called PlayerEntityControl.m (I think, again at work so can't check!) the commands at the start of the game could be modified so that when you start, press N to start a new game and then press Space, you could change it so that instead of pressing Space you press 1, 2 or 3 to select different starting locations, which could also have different ships, money and legal status. However, the set up for the starting game is contained in the file PlayerEntity.m so you would need to set a variable in PlayerEntityControl.m that could be read in PlayerEntity.m in order to do this. It is possible though, I'm sure...

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 9:25 am
by PhantorGorth
Pleb wrote:
I did some more experimenting with Galaxy Seeds last night, only to discover that the new seed I had chosen to use in the last code I posted in this thread actually causes 2 galaxies to suffer the same fate as Galaxy 4 with only Democracy, Communist, Multi-Government and Anarchy government systems present. Although I would prefer not to have a situation like this, it makes me wonder whether this is an unavoidable scenario as it appears to be a flaw (or feature, depending how you look at it :wink: ) with the way the systems are generated from the galaxy seed...
I did an experiment with my spreadsheet and found that I would get all sorts of government distributions that didn't include all 8 types. But in all you get each type that is there in multiples of 32 systems. Some had 4 types, some 5, some 6, some 7. One even had 4 with 128 dictatorships!

I am looking a writing some code to pick random seeds and see if that set of 8 galaxies has all 8 government types in each. Due to RL issues that probably won't be until next week.

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 9:32 am
by cim
Pleb wrote:
Have also theorised about multiple start locations, but struggling to figure out a way of setting a variable in one file and recalling it in another - for example, in a file called PlayerEntityControl.m (I think, again at work so can't check!) the commands at the start of the game could be modified so that when you start, press N to start a new game and then press Space, you could change it so that instead of pressing Space you press 1, 2 or 3 to select different starting locations, which could also have different ships, money and legal status. However, the set up for the starting game is contained in the file PlayerEntity.m so you would need to set a variable in PlayerEntityControl.m that could be read in PlayerEntity.m in order to do this. It is possible though, I'm sure...
If you look carefully at the order things happen in, then it's not what it looks like to the player, so this is a bit easier.

Firstly, the game loads the new game in PlayerEntity. (Look at the worldscript loading in the log, for instance) Then, it displays the spinning cobra and start screen, with PlayerEntityControls handling load/save. If the player chooses to load a saved game, it takes them to the load screen. If they then exit that screen without loading a saved game, it drops them back into the new Jameson loaded at game start.

So, to have alternative starting positions, all you need to do is:
1) Hack together some save-games for those starting positions. Easy enough to do either by editing the save file or by modifying the startup in Player Entity and saving the result.
2) Modify the startup screen in PlayerEntityControls so that if they choose not to load a saved commander, the new commander screen with the ship previews offers them choices. If they pick something other than '1', load the saved game you prepared earlier.
(Or just distribute the savegames from step 1 and don't bother changing the source code, but where's the fun in that :) )

On this bit specifically:
Pleb wrote:
but struggling to figure out a way of setting a variable in one file and recalling it in another
It's an OO language, so you (in general) don't do this as such. Instead, you use properties and method calls on objects. So, there is for instance exactly one Player object. You can access it globally as the PLAYER variable, but if you're in a method definition in one of the PlayerEntity files it's the local object.

So, for instance, you can do [PLAYER setForwardShieldLevel:newLevel] from any function in any file to set the player's forward shield to newLevel, where newLevel is a variable calculated locally in this file.

Or each Ship is a ShipEntity object (the PLAYER object is also a ShipEntity object, but overrides some of its methods and adds some new methods and properties {1}). So you can get the ShipEntity reference for a particular ship in various ways, and then call methods on it to either set or retrieve information, or to cause it to perform more complex behaviour.

Code: Select all

ShipEntity *ship = [UNIVERSE spawnShipWithRole:@"pirate" near:PLAYER]; // adds a random pirate ship near the player. UNIVERSE is the other important global object.
[ship becomeExplosion]; // and then blows them up
This, rather than having a variable which is directly read by two different objects, is how it's supposed to be done: find the object you want, then call methods on it to get or set variables, or do other things.

{1} And the ShipEntity object is also a subclass of the Entity object, so both ShipEntity and PlayerEntity get all the methods and properties an Entity has. PlanetEntity is also a subclass of Entity, so gets the methods Entity has, but is not a subclass of ShipEntity, so you can't do [planet becomeExplosion] (unless you first write a becomeExplosion method in PlanetEntity.m, of course)

Does this make it a bit clearer how things are structured in the source?

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 10:44 am
by Pleb
Okay thanks cim I think I'm starting to understand the process of OO code, it wasn't that long ago that even JavaScipt puzzled me but I think its a case of once one code starts to make sense they all slowly seem to fit into place - but with some major differences here and there! :)

But what I was thinking, rather than the game having to load different savegame files at the beginning, couldn't you simply have an IF statement to choose the different values that the start game uses? Using the methods you described, a property and method could be set up, for example [PLAYER setStartID:PlyStartID] and called with [PLAYER PlayerStartID] a bit like the [PLAYER CurrentGalaxyID] method, so that it could determine what starting location/setup the player chose at the beginning and then set a value based on that decision?
PhantorGorth wrote:
I did an experiment with my spreadsheet and found that I would get all sorts of government distributions that didn't include all 8 types. But in all you get each type that is there in multiples of 32 systems. Some had 4 types, some 5, some 6, some 7. One even had 4 with 128 dictatorships!

I am looking a writing some code to pick random seeds and see if that set of 8 galaxies has all 8 government types in each. Due to RL issues that probably won't be until next week.
Looking forward to seeing this, I obviously haven't been experimenting with the seeds as much as you have as the results you have are much more varied than mine! But the goal of finding a "perfect" galaxy seed is at the top of my list!

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 11:00 am
by cim
Pleb wrote:
But what I was thinking, rather than the game having to load different savegame files at the beginning, couldn't you simply have an IF statement to choose the different values that the start game uses?
Yes, you could, in theory, but you'd then have to have a way of displaying the spinning Cobra and the start screens (including the load/save GUI) before the Universe and Jameson had been set up. That would require quite a substantial rewrite of the GUI code and much more - for instance, the spinning Cobra is a ShipEntity which exists from the Universe, though disconnected from the "real" ships in the system, and what would you do if the player tried to exit the "load saved game" screen without selecting a game?

You don't have to do it by loading a savegame file, either, as you could write to the PlayerEntity directly from PlayerEntityControls, but it's probably more flexible to do it that way rather than hard-coding the alternative starts in, as you could then have an "alternative-starts.plist" which referenced files in a AltStarts subfolder of Resources or an OXP to allow OXPs to also define alternative starting positions by shipping the standard saved games.

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 11:12 am
by Pleb
Ah I understand now, explains why when I changed the starting ship before to an Asp to experiment it shows the Asp spinning at the beginning and not the Cobra. I like the idea of allowing OXPs to define alternate starting locs, this might be something worth looking into. I will try and experiment more with this idea over the weekend to see how this would work.

Thanks again cim, I think I'm very slowly starting to understand how the code pieces together and how things are loaded/defined in the game. It makes for good educational value! (It also allows me to experiment with new ideas in the game as possible suggestions for the main release or just for my own enjoyment...) :mrgreen:

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 1:31 pm
by Wildeblood
Pleb wrote:
PhantorGorth wrote:
I did an experiment with my spreadsheet and found that I would get all sorts of government distributions that didn't include all 8 types. But in all you get each type that is there in multiples of 32 systems. Some had 4 types, some 5, some 6, some 7. One even had 4 with 128 dictatorships!

I am looking a writing some code to pick random seeds and see if that set of 8 galaxies has all 8 government types in each. Due to RL issues that probably won't be until next week.
Looking forward to seeing this, I obviously haven't been experimenting with the seeds as much as you have as the results you have are much more varied than mine! But the goal of finding a "perfect" galaxy seed is at the top of my list!
Have a careful read of the parts of Universe.m setting up system properties. IIRC, it doesn't use all of the six galaxy seed numbers, but only some. So changing some numbers has an effect on government type distribution, and changing others has no effect. (Or, I might have completely misunderstood what I've read there.)

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 1:39 pm
by Pleb
Wildeblood wrote:
Have a careful read of the parts of Universe.m setting up system properties. IIRC, it doesn't use all of the six galaxy seed numbers, but only some. So changing some numbers has an effect on government type distribution, and changing others has no effect. (Or, I might have completely misunderstood what I've read there.)
The problem is, even if the initial seed can produce systems with all 8 government types in, when the seed is rotated it seems to always produce at least one galaxy that does not have them all in. I'm hoping there might be a seed that would keep all 8 govs in all 8 galaxies, but at the moment it is very much trial and error...

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 2:38 pm
by Wildeblood
Pleb wrote:
Wildeblood wrote:
Have a careful read of the parts of Universe.m setting up system properties. IIRC, it doesn't use all of the six galaxy seed numbers, but only some. So changing some numbers has an effect on government type distribution, and changing others has no effect. (Or, I might have completely misunderstood what I've read there.)
The problem is, even if the initial seed can produce systems with all 8 government types in, when the seed is rotated it seems to always produce at least one galaxy that does not have them all in. I'm hoping there might be a seed that would keep all 8 govs in all 8 galaxies, but at the moment it is very much trial and error...
I fear you've missed my point. There's no obligation to rotate all six seeds: you only need to change one to get a different chart. IIRC, you can leave the ones that determine governments unchanged.

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 2:44 pm
by PhantorGorth
Wildeblood wrote:
Have a careful read of the parts of Universe.m setting up system properties. IIRC, it doesn't use all of the six galaxy seed numbers, but only some. So changing some numbers has an effect on government type distribution, and changing others has no effect. (Or, I might have completely misunderstood what I've read there.)
The government number is taken from 3 bits of one of those 6 seeds (bits 3,4 and 5 (counting from 0) from seed c) but the seed of the next system is from twisting the seed 4 times:
If the 6 numbers are label a,b,c,d,e and f then

w(0) = (256*b+a)
w(1) = (256*d+c)
w(2) = (256*f+e)

twist: w(n+3) = (w(n) + w(n+1) + w(n+2)) & 0xFFFF

and the seeds for the next system are w(4), w(5) and w(6) (yes w(3) is not used) and so on. Each triplet you can break down into the six seed numbers you referred to above.

So although true that only a few bits are used and the other bits are not used for working out the government type the twist mechanism means they do on the next system and the system after that etc.

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 4:41 pm
by Pleb
The only way I can see if avoiding a Galaxy 4 situation then would be to either change the way the galaxy seeds are rotated specifically for the new galaxies, or to use different seeds specified for the new galaxies as I have done when jumping from Galaxy 8 to Galaxy 9. The second option would be easier and require less coding.

EDIT: Also, to answer a previous question, to add more long range chart backgrounds to the screenbackgrounds.plist file you simply have to add the code I posted before into the screenbackgrounds.plist file. No source code changes are required.

Re: Galaxy seeds and system properties

Posted: Fri Jun 22, 2012 5:40 pm
by PhantorGorth
Pleb wrote:
The only way I can see if avoiding a Galaxy 4 situation then would be to either change the way the galaxy seeds are rotated specifically for the new galaxies, or to use different seeds specified for the new galaxies as I have done when jumping from Galaxy 8 to Galaxy 9. The second option would be easier and require less coding.
Well suggest you wait until I have had a chance to find one that has all 8 govs in all 8 galaxies and failed.

Re: Galaxy seeds and system properties

Posted: Sat Jun 23, 2012 5:21 pm
by Wildeblood
Many hands make light work, so I suggest it's time to re-start this discussion (the search for particular nifty galaxy seeds) in the discussion section of the forum, in the form of a challenge. While trying to avoid therein distracting discussion of the related implementation issues of how many, how to enter, etc. Give instructions how to hack a save-file, and ask people to upload images and state the seed numbers used to create them. Yes? No?

Re: Galaxy seeds and system properties

Posted: Sat Jun 23, 2012 5:37 pm
by Pleb
Wildeblood wrote:
Many hands make light work, so I suggest it's time to re-start this discussion (the search for particular nifty galaxy seeds) in the discussion section of the forum, in the form of a challenge. While trying to avoid therein distracting discussion of the related implementation issues of how many, how to enter, etc. Give instructions how to hack a save-file, and ask people to upload images and state the seed numbers used to create them. Yes? No?
The only problem with hacking save games is that it has a tendency to cause problems with the game. But it would be good to see what people can come up with.