Page 1 of 2
Flavour OXP – Named Stations – Would need help with a Script.
Posted: Tue Jul 21, 2020 4:27 am
by LittleBear
Hello Commanders,
It must be 10 years since I did any OXPing, but after a long break I have been playing Oolite again with all the new stuff. I don’t have time to really to bring my scripting up to date, but an idea that has been floating around in my head for a few years is it would be a nice bit of flavour if every unnamed station (main stations and unnamed OXP stations that currently appear just as “Dodecahedron Station” got an individual name in the same style as Random Ship names eg: “Dodecahedron Station: Ark of Light”.
I could do the call lists as I did with Random Hits, but my scripting is so out of date that I couldn't learn the new scripting techniques. I can only really manage to put the list together.
I’ve included a [/code] bellow which would be my base to add words and naming styles to. I can do that bit but I’d need someone to write me a script which would:-
1) I’d like to add indivual hand written names to the Black Monks Stations. I’d need to know how many there are in the game and then I’d add induvial names to this list. The script would need to read the list and add this to each Black Monk Station. I’ve set a key for this in the code which I’d fill in, and if people want to contribute words for the random generator and individual names for stations. So at the moment if a script ran this every Black Monk Monastery would be named “Name this station!” and I then add names to the list.
2) I’d like to add an induvial name to each main station in every galaxy from a list. I’d throw this open to the forums for people to contribute names to the list. Under this I’ve set a key to do this in blocks of 24 planets for each galaxy as that why I known when I’m done. The script would have to add the name from the list to each main station. I’d be going for the way Povey planets does it – Have a list of 2056 individual names and assine one to each station in the 8 galaxies.
3) Name all the unnamed OXP stations which just add generic stations to extra planets etc using a random generator. I’ve give an example. With one naming style on the list combining two groups of 5 words there are 25 possible names. By adding more templates for style millions of names can be generated in the same way random ship names does. I can make the word lists (and again if anyone wants to contribute words on this thread I’ll add them). I’d like to keep all names consistent although generated randomly. IE just in the same way Elite generates the planet descriptions from a word lists in descriptions, each planet has the same description in each game. The script would also need to avoid renaming unique stations from OXPs such as the bars from Random Hits and the stations from assassins.
I’d be up for making the random generator list and coming up with names for the Black Monks Stations. If any other OXPers would like this proposed oxp to also name their stations either with a personal list or a random generator using words to generate personalised random names for that OXP stations then I’d include that as well.
If anyone is up for doing a script, then could you post here? If this can be done then I’d make a start on putting lots of word lists together and throw the naming of the stations. I’d then put out a test OXP with the list that just says Name this Station. So initially each main stations would just say Name this Station after its name. As people propose names or I think of them, I’ll add them to the list. Once I’ve got a good set of random generators and list of names together I’ll put it out as a final version.
I’d enjoy making the random word lists, but that as far as I’d be able to contribute. It would need someone else to write the script and send me it as an oxp into which I could put the descriptions file.
If you would be interested in doing this post here.
The demo code for my descriptions file is posted below.
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</array>
<key>named_stations_black_monk_station_names</key>
<string>Name this Station!</string>
</array>
<key>named_stations_master_list_of_templates_types_for_naming_oxp_stations</key>
<array>
<string>[named_stations_random_name_generater_template_type_1]</string>
<</string>
</array>
<key>named_stations_random_name_generater_template_type_1</key>
<array>
<string>[named_stations_random_name_generater_template_type_1_first_word] of [named_stations_random_name_generater_template_type_1_second_word]</string>
<</string>
<key>named_stations_random_name_generater_template_type_1_first_word</key>
<array>
<string>Ark</string>
<string>Sanctuary</string>
<string>Well</string>
<string>River</string>
<string>Fortress</string>
<</string>
<key>named_stations_random_name_generater_template_type_1_second_word</key>
<array>
<string>Infinity</string>
<string>Light</string>
<string>Heaven</string>
<string>Rapture</string>
<string>Solitude</string>
<</string>
<key>named_stations_galaxy1_main_staton_names_planet_nubmers_1_to_24/key>
<array>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
</array>
</dict>
</plist>
Little Bear
(Out of retirement if anyone this this is a nice flavour addition).
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Tue Jul 21, 2020 5:08 am
by another_commander
Welcome back LittleBear!!!! So great to have you with us again!
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Tue Jul 21, 2020 9:56 am
by Cody
Welcome back indeed! We like naming things!
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Tue Jul 21, 2020 11:03 am
by Disembodied
Yay! LittleBear returns! Good to have you back.
This reminds me - I had a half-baked notion to see if RandomShipNames could be used to give individual identifiers to the main system stations, way back. I don't think I did anything with regard to the actual names, but I did think we could maybe jazz things up by coming up with alternatives for "station", e.g.
[Insert name here] Station
[Insert name here] Spaceport
[Insert name here] Starport
[Insert name here] Orbital
[Insert name here] Highport
[Insert name here] Starbase
[Insert name here] Citadel
[Insert name here] Outpost
All Democracies could have a "Something Spaceport", say, or all Dictatorships could have a "Something Highport". Or perhaps a better way to do it would be to split the systems by tech level, and have e.g. TL 1-2 stations classed as "Outpost"; TL 3-4 "Station"; 5-6 "Highport"; 7-8 "Orbital"; 9-10 "Spaceport"; 11-12 "Starport"; 13-14 "Starbase"; 15 "Citadel".
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Tue Jul 21, 2020 11:58 am
by Cody
Disembodied wrote: ↑Tue Jul 21, 2020 11:03 am[Insert name here] Outpost
Perfect! My home system's (Ceerti G7) station - Inside Outpost
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Tue Jul 21, 2020 1:36 pm
by Milo
I think the requirement not to modify stations with unique names could be solved by having a whitelist of station dataKeys (keys in shipdata.plist) that are safe to change. As an additional check, you could retrieve (and cache, since it won't change after startUp) the
shipDataForKey for each station and save the "name" property, and then when we encounter a station and are considering applying a new name, check first that the station's current name matches the one from the shipdata (in case some other OXP uses a whitelisted station dataKey but then applies a different name by script).
To gather the total number of Black Monks stations, I think we can run the following command in the debug console (derived from the _setMonkSystems function in the Blank Monks OXP) in each galaxy and then sum them to find the total:
Code: Select all
var stationCount = 0; var systems = SystemInfo.filteredSystems(this, function(other) { if (other.government >= 6 && other.techlevel >= 11 && !other.sun_gone_nova) { return (other); } }); for (var i = 0; i < systems.length; i++) { var destinations = 0; for (var j = 0; j < systems.length; j++) { var routeInfo = System.infoForSystem(galaxyNumber, systems[i].systemID).routeToSystem(systems[j]); if (routeInfo && routeInfo.route.length > 9) destinations++; } if (destinations > 0) { stationCount += 1; } }; stationCount;
Any volunteers to do the 8? Unfortunately, "Exception: Error: SystemInfo.routeToSystem: Cannot calculate route for destinations in other galaxies." when I tried to replace galaxyNumber (global representing current galaxy) with a loop checking 0 through 7; we have to actually be in the galaxy we want to count in. The first galaxy has 18.
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Wed Jul 22, 2020 1:28 pm
by LittleBear
Thanks guys.
Been having a bit of a think and I think the simplest way to do this is to by default to set the main station and any oxp stations on the whitelist to the name given in my generic station name random generator. So far I've just added one template in a 32 X 32 grid. So at them moment it will generate 1,024 different names. The first template generates protective sounding names "eg Dome of Justice" as well as Alistair Reynold style names "Nature of Reality, Shadow of Infinity" etc. I'd probabley do about 20 templates so that would give us 200,000 differnt unique names in 20 different naming styles, which would be enough for all the main and oxp stations in the 8 galaxies. Then, add an overwrite key. So if you'd like to name Lave Station, post here with the galaxy and planet number (so it would be 1,7 for Lave) and every couple of months I'll release an update with the player selected names in it. So on first release, all main stations would have a unique name generated by the word lists in the OXP. As people name stations the player selected name will be added to the next release.
For the Monk Stations I think the simplest way to do it (and this would go for any other OXPer who would like a personal list for their stations) is to name each Monk Station from the list of names in the random generator. At the moment I've only entered one word in each table, so every monk station would be named "Hammer of God". But once I've filled in 32 words in each table, that gives 1,024 unique names. I'd probabley add two temples giving 2,048 names which would be enough for every station in the 8.
So, that should make the script simpler as it would need to:-
1) Set the Main Station name and the name of all oxp stations on the white list in every system to the Random Generator Name. It would need to do the same thing as Random Ship Names does and check the name generated was not previously picked. We'd then have every oxp and main station in the galaxies with a unique name. If a player has named a station then over-ride the random generator and name that station with the player's name stored in descriptions.
2) For Monk Stations (or any other OXP station where the creator would like a name from their own word lists to better fit the style of their stations) name the monk stations from the monk word lists.
Hopefully that makes it a bit easier for a scripter to implement. I do need someone to do me script though!
Below revised Descriptions File:-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</array>
<key>named_stations_black_monk_station_names</key>
<string>[named_stations_monk_random_name_generater_template]</string>
</array>
<key>named_stations_monk_random_name_generater_template</key>
<string>[named_stations_monk_random_name_generator_template_type1_first_word] of [named_stations_monk_random_name_generator_template_type1_second_word]</string>
</array>
<key>named_stations_monk_random_name_generater_template_type_1_first_word</key>
<array>
<string>Hammer</string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
</array>
<key>named_stations_monk_random_name_generater_template_type_1_second_word</key>
<array>
<string>God</string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
</array>
<key>named_stations_master_list_of_templates_types_for_naming_stations</key>
<array>
<string>[named_stations_random_name_generater_template_type_1]</string>
</array>
<key>named_stations_random_name_generater_template_type_1</key>
<array>
<string>[named_stations_random_name_generater_template_type_1_first_word] of [named_stations_random_name_generater_template_type_1_second_word]</string>
</array>
<key>named_stations_random_name_generater_template_type_1_first_word</key>
<array>
<string>Ark</string>
<string>Sanctuary</string>
<string>Well</string>
<string>River</string>
<string>Dome</string>
<string>Aspect</string>
<string>Nature</string>
<string>Fortress</string>
<string>Castle</string>
<string>Guardian</string>
<string>Mirror</string>
<string>Keeper</string>
<string>Circle</string>
<string>Pillar</string>
<string>Spire</string>
<string>Tower</string>
<string>Bridge</string>
<string>Bastion</string>
<string>Shield</string>
<string>Ring</string>
<string>Hand</string>
<string>Cup</string>
<string>Reflection</string>
<string>Contemplation</string>
<string>Protector</string>
<string>Shadow</string>
<string>Messenger</string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
</array>
<key>named_stations_random_name_generater_template_type_1_second_word</key>
<array>
<string>Infinity</string>
<string>Light</string>
<string>Heaven</string>
<string>Rapture</string>
<string>Solitude</string>
<string>Peace</string>
<string>Delight</string>
<string>Perfection</string>
<string>Reality</string>
<string>Life</string>
<string>Time</string>
<string>Consciousness</string>
<string>Hope</string>
<string>Babel</string>
<string>Serenity</string>
<string>Justice</string>
<string>Silence</string>
<string>Destiny</string>
<string>Eternity</string>
<string>Fate</string>
<string>Oblivion</string>
<string>Sentience</string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
<string></string>
</array>
<key>named_stations_main_staton_names_over_ride_personaly_picked_names/key>
<array>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
</array>
</dict>
</plist>
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Wed Jul 22, 2020 5:32 pm
by Milo
Small nitpick on your plist: the first two instances of </array> aren't matched up with anything.
For the randomization itself, I think we might have a problem. The implementation of expandDescription uses a fully random seed value, not a system-specific deterministic seed like the planet descriptions for example, so we can't use expandDescription to generate random names that will be deterministic (the same across restarts or irrespective of the order in which players encounter the stations).
... randomization in Oolite is complicated, to put it mildly. The global random number sequence gets reset all over the place, not always restored, and in several places where the code seems to be trying for a deterministic value, I'm not fully convinced that it's actually getting one.
You might think that there would be a per-system seed value saved for later use, but apparently not; the initial system populator derives its starting seed value with a function getRandomSeedForCurrentSystem that actually uses a null seed unless the planetinfo.plist for the associated system defines a "random_seed" key-value. Only a few systems have such entries in planetinfo.plist. So in most systems, the populator starts its random sequence from the same value, and the variability we see is a consequence of differences in what populators are set up in different system types. If you took two otherwise identically configured systems, the fact that they are different galaxy or system IDs seemingly doesn't play a role.
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Wed Jul 22, 2020 9:06 pm
by LittleBear
Opps. Definatley rusty. Have fixed the arrays and completed two lists of 32 each.
I hit the problem of Oolite pedo-randomness when doing Random Hits as although in theroy there should have been millions of combinations as I was using about 50 rolls of the dice on each ad page, the sequence would repeat after so many rolls and the ad on the 4th page would be the same as the one on the third page. I got round that by having multiple pick tables so allthough the sequence of numbers would be the same as the word tables being picked from were different the ad was different. I also found throwing in a recursion every so often would throw the generator out of sync.
Could we use the psedo-randomness to our advantage though? The planet descriptions are generated by Oolite 'randomly' picking words from a descriptions array to put together the planet descriptions. However as the Seed Number is the same for every player of Oolite, the game always picks the same sequence of words for each system and so Lave is always "most famous for its vast rain forests the Lavian tree grub" for all players. Wouldn't the same thing follow if picking from an oxp descriptions.plist as the seed that generates Lave's description is used so the name of Lave Station would always be "Arc of Infinity" (or whatever the system seed picked from my lists"?
Since nothing exits until the player launches couldn't we do a naming of the main station and all oxp stations in the system on a Status Lanching and Status exiting Hyperspace? As the same system seed is being used for each generation shouldn't that mean all the stations at a given system will have pesdo random generated names in the same way as the planet decsriptions so the stations in a given system all keep the name assigned to them by the seed?
Fixed up the code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
// Call Lists for the Black Monk Stations. If a particular type of Station is linked to a call list then it will be named using its own call list rather than the standard one.
<key>named_stations_black_monk_station_names</key>
<array>
<string>[named_stations_monk_random_name_generater_template]</string>
</array>
<key>named_stations_monk_random_name_generater_template</key>
<array>
<string>[named_stations_monk_random_name_generator_template_type1_first_word] of [named_stations_monk_random_name_generator_template_type1_second_word]</string>
</array>
<key>named_stations_monk_random_name_generater_template_type_1_first_word</key>
<array>
<string>Hammer</string>
<string>Mace</string>
<string>Scythe</string>
<string>Temple</string>
<string>Chapel</string>
<string>Church</string>
<string>House</string>
<string>Nave</string>
<string>Robe</string>
<string>Tabard</string>
<string>Prayer</string>
<string>Missionary</string>
<string>Hall</string>
<string>Disciple</string>
<string>Cleric</string>
<string>Saviour</string>
<string>Messiah</string>
<string>Lord</string>
<string>Shepherd</string>
<string>Vestments</string>
<string>Lash</string>
<string>Stocks</string>
<string>Saint</string>
<string>City</string>
<string>Song</string>
<string>Chant</string>
<string>Tome</string>
<string>Gospel</string>
<string>Bishop</string>
<string>Path</string>
<string>Revelation</string>
<string>Servant</string>
</array>
<key>named_stations_monk_random_name_generater_template_type_1_second_word</key>
<array>
<string>Mammon</string>
<string>Gold</string>
<string>Compound Interest</string>
<string>Lamentation</string>
<string>Repentance</string>
<string>Retribution</string>
<string>Debt</string>
<string>the Bankrupt</string>
<string>Credit</string>
<string>Piety</string>
<string>Banking</string>
<string>Borrowing</string>
<string>Economics</string>
<string>the Righteous</string>
<string>Virtue</string>
<string>the Crusader</string>
<string>Currency</string>
<string>Capitalism</string>
<string>the Poor</string>
<string>the Destitute</string>
<string>the Blessed</string>
<string>Servitude</string>
<string>Poverty</string>
<string>Atonement</string>
<string>Suffering</string>
<string>the Meek</string>
<string>Negative Equity</string>
<string>the Overdrawn</string>
<string>the Miser</string>
<string>the Wanderer</string>
<string>Iron</string>
<string>Pain</string>
</array>
// Call Lists for all stations. If a station is not specified as having it's own call list then it will be named using the key below. When this key is called it will randomly select one of the templates as a naming style and then generate a name in that style.
<key>named_stations_master_list_of_templates_types_for_naming_stations</key>
<array>
<string>[named_stations_random_name_generater_template_type_1]</string>
</array>
// Templete Type 1 - This Template generates protective sounding names eg Ark of Hope and poetic names eg Shadow of Infinity.
<key>named_stations_random_name_generater_template_type_1</key>
<array>
<string>[named_stations_random_name_generater_template_type_1_first_word] of [named_stations_random_name_generater_template_type_1_second_word]</string>
</array>
<key>named_stations_random_name_generater_template_type_1_first_word</key>
<array>
<string>Ark</string>
<string>Sanctuary</string>
<string>Well</string>
<string>River</string>
<string>Dome</string>
<string>Aspect</string>
<string>Nature</string>
<string>Fortress</string>
<string>Castle</string>
<string>Guardian</string>
<string>Mirror</string>
<string>Keeper</string>
<string>Circle</string>
<string>Pillar</string>
<string>Spire</string>
<string>Tower</string>
<string>Bridge</string>
<string>Bastion</string>
<string>Shield</string>
<string>Ring</string>
<string>Hand</string>
<string>Cup</string>
<string>Reflection</string>
<string>Contemplation</string>
<string>Protector</string>
<string>Shadow</string>
<string>Messenger</string>
<string>Vison</string>
<string>Breath</string>
<string>Quantum</string>
<string>Storm</string>
<string>Manifestation</string>
</array>
<key>named_stations_random_name_generater_template_type_1_second_word</key>
<array>
<string>Infinity</string>
<string>Light</string>
<string>Heaven</string>
<string>Rapture</string>
<string>Solitude</string>
<string>Peace</string>
<string>Delight</string>
<string>Perfection</string>
<string>Reality</string>
<string>Life</string>
<string>Time</string>
<string>Consciousness</string>
<string>Hope</string>
<string>Joy</string>
<string>Serenity</string>
<string>Justice</string>
<string>Silence</string>
<string>Destiny</string>
<string>Eternity</string>
<string>Fate</string>
<string>Oblivion</string>
<string>Sentience</string>
<string>Enlightenment</string>
<string>Radiance</string>
<string>Endurance</string>
<string>Empathy</string>
<string>Might</string>
<string>Honour</string>
<string>Chivalry</string>
<string>Purity</string>
<string>Conscience</string>
<string>Wisdom</string>
</array>
<key>named_stations_main_staton_names_over_ride_personaly_picked_names/key>
<array>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
<string>Name this Station!</string>
</array>
</dict>
</plist>
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Wed Jul 22, 2020 11:04 pm
by Milo
LittleBear wrote: ↑Wed Jul 22, 2020 9:06 pm
the sequence would repeat after so many rolls and the ad on the 4th page would be the same as the one on the third page.
Oolite 1.79 improved the randomization of string replacements so your workaround might not be needed now.
Could we use the psedo-randomness to our advantage though? The planet descriptions are generated by Oolite 'randomly' picking words from a descriptions array to put together the planet descriptions. However as the Seed Number is the same for every player of Oolite, the game always picks the same sequence of words for each system and so Lave is always "most famous for its vast rain forests the Lavian tree grub" for all players. Wouldn't the same thing follow if picking from an oxp descriptions.plist as the seed that generates Lave's description is used so the name of Lave Station would always be "Arc of Infinity" (or whatever the system seed picked from my lists"?
No, this is what I was trying to say in my previous post. The method by which planets are always given the same description is not used when expanding other strings. We don’t seem to have an OXP-accessible way to ask the game to give us a
deterministically random string expansion.
Since nothing exits until the player launches
Actually, the system is fully populated when the game loads, not when you launch for the first time. The simulation is running even while you are docked.
couldn't we do a naming of the main station and all oxp stations in the system on a Status Lanching and Status exiting Hyperspace?
The best place to do it would be in a system populator because as I mentioned earlier the game resets the global random number sequence just before doing the initial populating of a system (at game load or when exiting witchspace), so code there should - in theory - always obtain the same random result in a given system. But even that is not enough to eliminate all variance. For example, if any populator does a different amount of random rolls based on something about the player (such as spawning assassins if they have a parcel) that could result in your random text coming up with a different result. And it would be different for different Ooniverses (including if the player ever changed their OXP list in a way that affected the populators) because differences in the populators that run before your OXP would change the randomization of the names your OXP would produce.
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Thu Jul 23, 2020 1:42 pm
by Milo
What we want:
- Ability to expand strings randomly, but deterministically across restarts/reloads (which includes being unaffected by random rolls done by anything other than our OXP)
- Different results in each system (i.e., each unique tuple of galaxy number and system number)
- Different results if we do multiple rolls in the same system (e.g., generating random names for more than one station of the same type)
- Ideally, the same outcomes for the same stations even if the player changes their Ooniverse in ways that affect the number of stations in a system
For the last, it would be useful if there were something about each station which is itself both deterministic and different for different stations. Entity personality comes to mind, but it is deterministic only for the main station. Other stations have random, varying entity personalities. The original station name itself might be the best thing to use -- it's (probably) not going to change even if the player shuffles their Ooniverse. It doesn't let us distinguish between stations of the same name, but I think it's rare for that to occur in the same system.
We could compute a number that is deterministic for a given combination we are rolling for (galaxy + system id + original station name + number of stations with that same name in the system) and provide that to the game each time we ask for a random name.
If we could have the game reset its random sequence each time we ask for a string expansion, and apply our provided number to "shuffle" the random result, we could get deterministic output that satisfies the criteria above.
I'm thinking that the expandDescription function, which currently accepts two parameters, could be enhanced to accept a third, numeric parameter, called something like "deterministicOffset" for example, and if that is provided by an OXP, the function would cache the global random sequence, temporarily reset the sequence to some deterministic initial state that's always the same, and then apply the provided offset to "shuffle" it (still deterministic), after which it would do the various string expansions, and then finally restore the cached global random sequence (so random rolls that occur afterwards get the same result they would have if we hadn't done our string expansion in the middle).
You might wonder why restoring the cached random sequence is necessary; any random rolls would still get "random" values, right? Yes and no -- they would get random values, but from our replacement sequence, which would not have the same distribution of values as the original sequence. Using our replacement sequence for future rolls would result in more correlation, less "random-ness", compared to using the original sequence.
Before I go off and try to implement this, I'll leave the idea here for feedback and alternative proposals.
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Thu Jul 23, 2020 3:57 pm
by LittleBear
Thanks. Rats I was kinda hoping to be able to use the Pesdo Randomness to help, but I can see now why this only works for the planet descriptions.
As I've been in hibernation for 10 years (OXP wise!) the last script I wrote was Random Hits (in legacy as that was the only option at the time). It was Eric Walsh and Spara who did the hard work of bringing Random Hits up to date by converting my legacy scripts. So I may be talking out of my Aft View as I really do not understand the current scripting for Oolite at all (and it may not be possible to do this) But:-
What we need are some numbers that stay the same for each system to use pesdo-random (which would make this OXP a million times easier to do). Although we can't use Oolite seed there are things which differ system to system but always stay the same: Galaxy Number, Planet Number, Economy, Govenment, Productivity etc. So there is a sequence of numbers (I assume which can be grabbed by a script). Then we'd have a consitent seed for each system. So Lave (and only Lave) would have the sequence 0, 7, (and then whaterver the values for govenment productive etc are - sorry can't remember how these appear in code now). But, that would mean each system has a unique set of 7 numbers which never change. Could those be accessed in Java script and a seed used from those with those numbers forming the seed numbers for a fiboneci (probley spelt it wrong) sequenece? If we could do that then the script would only need to read those numbers on system set up and we'd have unique dice rolls for each system which stay the same. I realese if an OXP is installed which changes an Economy (as Assassins does) then there would be a re-roll, but that is kinda inevitable really as no two players will have the same station OXPs installed anyway. But it would mean consistancy for each player.
Edit: Sorry, don't think I'd read your post properly (on the 00.00 to 16.00 shift and long day!). Looks like you can do it?
I'll get on with doing a few more word lists so you have enough cobinations for testing it. Don't worry if it can't be done. I've had quite a bit of fun from doing some word lists and it's got me throw some long duty rotas were I'm hanging around for a couple of hours waiting for the next case to be ready. So I won't feel I've wasted my time doing lists if it ultimatley can't be done.
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Thu Jul 23, 2020 4:21 pm
by Milo
Yes, what you are proposing is essentially the same as what I was proposing in my last post. But we need help from the core to support this, it isn't possible without being able to tell the game to use a different random sequence just for our rolls. The way the random number generator works, you can think of it like an infinite series of values pre-rolled, and each time you ask for a random number it gives you one of them. But if anyone else asks for a random number in between when we ask for one, that changes which one we will get. It's first come first served. We currently don't have a way to replace the random sequence right before we do our string expansion. We want to roll a new infinite sequence just for us, using a seed value computed like you suggested, but we need an extension in the core to let us do that.
What I mean by "caching the sequence" is before we replace it, we want to save the original infinite series and put it back when we're done so the next roll by someone else gets a "random" value that's as random as previous rolls.
Edit: OK, not really infinite. See
http://wiki.alioth.net/index.php/Random ... _generator
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Thu Jul 23, 2020 4:56 pm
by LittleBear
Ok understand. We'd need a feature request to Another Commander and a new Oolite Version for this to work, which is a bit of an ask. I seem to remember that on 1.65 (14 years ago!) there was a legacy comand of get system random number which gave a random number which was always the same for that particular system you called it in. But take it there isn't such a command anymore or even if there is we don't yet have a way to tell Oolite to use that number just for our rolls?
Re: Flavour OXP – Named Stations – Would need help with a Script.
Posted: Thu Jul 23, 2020 5:34 pm
by Milo
I'm not seeing any way to get deterministic string expansions currently.
But, I just hacked something up (I suspect my code is vastly over-complicated for what we need, but it seems to be working):
Code: Select all
diff --git a/src/Core/Scripting/OOJSGlobal.m b/src/Core/Scripting/OOJSGlobal.m
index ec1dfd45..8f9ad1f4 100644
--- a/src/Core/Scripting/OOJSGlobal.m
+++ b/src/Core/Scripting/OOJSGlobal.m
@@ -278,13 +278,15 @@ static JSBool GlobalLog(JSContext *context, uintN argc, jsval *vp)
}
-// expandDescription(description : String [, overrides : object (dictionary)]) : String
+// expandDescription(description : String [, overrides : object (dictionary)] [, deterministicOffset : Number]) : String
static JSBool GlobalExpandDescription(JSContext *context, uintN argc, jsval *vp)
{
OOJS_NATIVE_ENTER(context)
NSString *string = nil;
NSDictionary *overrides = nil;
+ int32 deterministicOffset = 0;
+ RANROTSeed rndcache = RANROTGetFullSeed(); // save current state of global random number generator
if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
if (string == nil)
@@ -296,11 +298,28 @@ static JSBool GlobalExpandDescription(JSContext *context, uintN argc, jsval *vp)
{
overrides = OOJSDictionaryFromStringTable(context, OOJS_ARGV[1]);
}
+ if (argc > 2)
+ {
+ if (!JS_ValueToInt32(context, OOJS_ARGV[2], &deterministicOffset) || deterministicOffset < 0 || 10000 < deterministicOffset)
+ {
+ OOJSReportBadArguments(context, nil, @"expandDescription", MIN(argc - 1, 1U), &OOJS_ARGV[2], nil, @"integer (positive deterministic offset for randomization no greater than 10000)");
+ return NO;
+ }
+ else
+ { // give consistent output like planetary descriptions and deterministic populator locations
+ Random_Seed systemSeed = OOStringExpanderDefaultRandomSeed(); // this will be either a nil seed {0} or a static seed from a "random_seed" key in planetinfo.plist
+ RANROTSeed rndlocal = RanrotSeedFromRandomSeed(systemSeed); // Same pattern as seed_for_planet_description()
+ uint32_t rndvalue = RanrotWithSeed(&rndlocal);
+ RANROTSetFullSeed(MakeRanrotSeed(rndvalue+((uint32_t)(int32)deterministicOffset*63647))); // use a deterministic seed for randomization (63647 is nothing special, just a largish prime)
+ }
+ }
OOJS_BEGIN_FULL_NATIVE(context)
string = OOExpandDescriptionString(kNilRandomSeed, string, overrides, nil, nil, kOOExpandForJavaScript | kOOExpandGoodRNG);
OOJS_END_FULL_NATIVE
+ if (deterministicOffset) RANROTSetFullSeed(rndcache); // restore the saved random number generator state
+
OOJS_RETURN_OBJECT(string);
OOJS_NATIVE_EXIT
Without the change:
> expandDescription("[distress-call]")
Our vessel is under attack, please help us.
> expandDescription("[distress-call]")
Our vessel is under attack, please help us.
> expandDescription("[distress-call]")
We are beset by brigands! Please help!
> expandDescription("[distress-call]")
Help! Anyone!
> expandDescription("[distress-call]")
Help! They’re firing on us!
With the change:
> expandDescription("[distress-call]",{},galaxyNumber * 256 + system.ID)
Our vessel is under attack, please help us.
> expandDescription("[distress-call]",{},galaxyNumber * 256 + system.ID)
Our vessel is under attack, please help us.
> expandDescription("[distress-call]",{},galaxyNumber * 256 + system.ID)
Our vessel is under attack, please help us.
> expandDescription("[distress-call]",{},0)
Mayday! Please assist. Mayday! Please assist.
> expandDescription("[distress-call]",{},0)
Mayday! Please assist. Mayday! Please assist.
> expandDescription("[distress-call]",{},1)
Criminals are attacking us. Please assist!
> expandDescription("[distress-call]",{},1)
Criminals are attacking us. Please assist!
> expandDescription("[distress-call]",{},2)
Help! Anyone!
> expandDescription("[distress-call]",{},2)
Help! Anyone!
> expandDescription("[distress-call]",{},3)
S.O.S. … S.O.S. … S.O.S. …
> expandDescription("[distress-call]",{},3)
S.O.S. … S.O.S. … S.O.S. …