Re: Secondary Market Definitions Defined
Posted: Thu Dec 14, 2023 3:21 am
For information and discussion about Oolite.
https://bb.oolite.space/
As I mentioned up-thread, you can get an estimate using
SystemInfo.samplePrice
for any system in the current galaxy. How different it would be to actually jumping into the system, I'm not sure, but if you don't want to do the whole jumping process thing, that might be an easier place to start.Yes, my previous post should have been clearer with regards to that. The wibbly-wobbly timey-winey "unknowns" mentioned in your previous post are still the primary problem. The experimentation continues.
I'm reasonably sure part of the tiny quantities at secondary stations is caused by using:
Gentlemen,
There's nothing extra in the code that I can see. The rock hermit market_definitions in shipdata.plist have a bit of info.Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm0) Might cim have included some comments in the vanilla game code which might explain a little more? I understand that he was one of our better commentators...
I thought I fixed this?Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm1) Is it actually possible to "fix" SW Economy so that the markets of the so-called mining systems actually act as such (rather than as agriculturals with zero quantities of agricultural commodities but with low prices for them)?
Not with a market_definition. You would need to use a market script to achieve this.Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm2) Is Vincentz's project (New Deal) achieveable? (His 4-way economy).
Yes.Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm3) Is Phasted's Real-Life economics modifiable to also change the quantities
1) SW Economyphkb wrote: ↑Thu Dec 14, 2023 9:14 pmThere's nothing extra in the code that I can see. The rock hermit market_definitions in shipdata.plist have a bit of info.Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm0) Might cim have included some comments in the vanilla game code which might explain a little more? I understand that he was one of our better commentators...
I thought I fixed this?Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm1) Is it actually possible to "fix" SW Economy so that the markets of the so-called mining systems actually act as such (rather than as agriculturals with zero quantities of agricultural commodities but with low prices for them)?
Not with a market_definition. You would need to use a market script to achieve this.Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm2) Is Vincentz's project (New Deal) achieveable? (His 4-way economy).
Yes.Cholmondely wrote: ↑Thu Dec 14, 2023 5:00 pm3) Is Phasted's Real-Life economics modifiable to also change the quantities
But let me return to my original offer. Do you want a demo/walkthough of a market_definition, or a market_script? It all comes down to what you're trying to achieve.
Code: Select all
"use strict";
this.name = "market_tweak.js";
this.author = "Stranger";
this.copyright = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script for selecting market preset";
this.version = "3.7.2";
/*
Tweaked by phkb
Instead of completely zeroing out quantities of food, textiles, liquor and furs in systems with harsh conditions,
I've instead reduced the amounts for sale by half. Can be adjusted by changing the "this._harshFactor" variable up or down.
Also added code to make tweaks apply to all system stations, not just main station. Turned off by default, but can be turned on
by changing "this._applyToAll" to "true";
*/
this._applyToAll = false;
this._harshMining = {
agri_quantity_reductor: 2, // increase this value to remove more agri-related goods (1.5 = 2/3rds of original, 2 = half original, 3 = 1/3rd of original, 4 = 1/4th of original)
price_discount_factor: 2.0, // increase this value to make the price discount of mining goods greater
quantity_increase_factor: 2.5 // increase this value to make the quantity boost of mining goods factor greater
};
//-------------------------------------------------------------------------------------------------------------
this.startUp = function () {
//log(this.name, "this OXP initialising!");
}
this.shipExitedWitchspace = function () { // Welcome to system!
if (system.isInterstellarSpace) return; // oops... we have a problem with navigation
var industry_adjust = (25000 + system.productivity) / 50000; // production of industrial goods vs GNP scaling
var agro_adjust = (10000 + system.productivity) / 25000; // production of agro goods vs GNP scaling
var goods_store;
if (this._applyToAll) {
var stns = system.stations; // use this to apply to all stations
} else {
var stns = [];
stns.push(system.mainStation); // use this to only apply to main station
}
var i = stns.length;
while (i--) {
var stn = stns[i];
if ((system.techLevel + 2 * system.government) > 12) { // illegal goods prohibited in (tech OR social) advanced worlds
stn.setMarketQuantity("slaves", 0);
stn.setMarketQuantity("narcotics", 0);
stn.setMarketQuantity("firearms", 0);
}
if (system.economy > 4) { // items unavailable in agrarian worlds
stn.setMarketQuantity("computers", 0);
stn.setMarketQuantity("machinery", 0);
stn.setMarketQuantity("alloys", 0);
}
if (system.economy < 3) { // items unavailable in industrial worlds
stn.setMarketQuantity("food", 0);
stn.setMarketQuantity("textiles", 0);
stn.setMarketQuantity("liquor_wines", 0);
stn.setMarketQuantity("furs", 0);
}
if (system.techLevel < 4 && system.mainPlanet.radius < 54250) { // too harsh conditions to produce much by archaic methods
goods_store = parseInt(stn.market.food.quantity / this._harshMining.agri_quantity_reductor);
stn.setMarketQuantity("food", goods_store);
goods_store = parseInt(stn.market.textiles.quantity / this._harshMining.agri_quantity_reductor);
stn.setMarketQuantity("textiles", goods_store);
goods_store = parseInt(stn.market.liquor_wines.quantity / this._harshMining.agri_quantity_reductor);
stn.setMarketQuantity("liquor_wines", goods_store);
goods_store = parseInt(stn.market.furs.quantity / this._harshMining.agri_quantity_reductor);
stn.setMarketQuantity("furs", goods_store);
// bump mining goods by factors relating to TL/radius/productivity
var prod_factor = (((system.productivity / 4500) * 4 + (system.techLevel / 3) + (system.mainPlanet.radius / 45000)) / 100) * this._harshMining.quantity_increase_factor;
var price_factor = (((system.productivity / 4500) * 3 + (system.techLevel / 3) + (system.mainPlanet.radius / 45000)) / 100) * this._harshMining.price_discount_factor;
var list = Object.keys(system.mainStation.market);
log(this.name, "prod factor = " + prod_factor);
log(this.name, "price factor = " + price_factor);
for (var j = 0; j < list.length; j++) {
if (stn.market[list[j]].classes.indexOf("oolite-mining") >= 0) {
var amt = stn.market[list[j]].quantity * 10;
var price = stn.market[list[j]].price;
log(this.name, "pre: " + list[j] + " price = " + price + ", amt = " + amt / 10);
stn.setMarketQuantity(list[j], parseInt((amt + amt * prod_factor)) / 10);
stn.setMarketPrice(list[j], parseInt(price - price * price_factor))
log(this.name, "post: " + list[j] + " price = " + stn.market[list[j]].price + ", amt = " + stn.market[list[j]].quantity);
}
}
}
if ((system.economy > 2) && (system.techLevel > 3)) { // items available only in archaic tech OR industrial worlds
stn.setMarketQuantity("minerals", 0);
stn.setMarketQuantity("radioactives", 0);
}
if (system.techLevel < 7) { // items unavailable below median tech limit
stn.setMarketQuantity("computers", 0);
stn.setMarketQuantity("medicine", 0);
stn.setMarketQuantity("luxuries", 0);
} else {
goods_store = Math.floor(stn.market.computers.quantity * industry_adjust);
stn.setMarketQuantity("computers", goods_store);
goods_store = Math.floor(stn.market.medicine.quantity * agro_adjust);
stn.setMarketQuantity("medicine", goods_store);
goods_store = Math.floor(stn.market.luxuries.quantity * industry_adjust);
stn.setMarketQuantity("luxuries", goods_store);
}
if (system.techLevel < 4) { // items unavailable in archaic tech worlds
stn.setMarketQuantity("machinery", 0);
stn.setMarketQuantity("alloys", 0);
stn.setMarketQuantity("oxygen", 0);
} else {
goods_store = Math.floor(stn.market.machinery.quantity * industry_adjust);
stn.setMarketQuantity("machinery", goods_store);
goods_store = Math.floor(stn.market.alloys.quantity * industry_adjust);
stn.setMarketQuantity("alloys", goods_store);
goods_store = Math.floor(stn.market.oxygen.quantity * industry_adjust);
stn.setMarketQuantity("oxygen", goods_store);
}
// low tech production, but needs some investments
goods_store = Math.floor(stn.market.liquor_wines.quantity * agro_adjust);
stn.setMarketQuantity("liquor_wines", goods_store);
goods_store = Math.floor(stn.market.furs.quantity * agro_adjust);
stn.setMarketQuantity("furs", goods_store);
}
}
KW's blurb: For several years, traders had been complaining about prices and availability of products at the main GalCop stations. Being the only trade point for a system, demand was high and prices often matched, leaving a very slim profit margin for many, especially new traders or those independent pilots w/out large contracts. To this end, several businesses began trading from large dockable ships and sometimes asteroid bases, setting up independent markets that could cater to bulk haulers, casual traders and even hard up pilots trying to make a living but unable to afford the prices at main stations.
The Hathor was designed as a wholesaler - dealing with bulk traders for supply they stocked plenty and were able to keep prices low, ensuring a steady stream of traffic. The stations also provided simple but cheap hotel rooms for pilots wishing to leave their ships but unable to afford accommodation on the main stations. The restaurants on a Hathor are also cheap, attracting many pilots who come just to eat rather than trade, income that helps support the station. Although the range of goods at a Hathor is not as broad as a main station, this is not their point : they deal mainly in staples and essentials, which is exactly where a lot of pilots make their living.
If you want to go into that deep a dive my belief is that it would certainly result in something positive. Re-imagining the entire Oolite economy or even attempting to alter it in the way that Stranger's OXZs do was not my reason for starting this thread. The origin of my inquiry goes back to THIS POST from 2021 to which there was not a conclusive answer or as lively a discussion as in this thread. Understandable, as that older post was buried in the Tinkerer's Workshop while this one is a whole new topic. A recent recommendation on my part of the "spara method" versus the "cim method" sparked my interest in again trying to learn the correct and most recent way of coding things. The result of that need to learn lead me back to the trade-goods.plist page, the "cim method", and my feeble attempts to understand how to get it to correctly do anything positive. My lack of any further enlightenment between 2021 and now resulted in the first post of this thread. My questions from 2021 through 2023 have been answered. The results are still a bit difficult to deal with given the "unknowns" involved but further experimentation will work it all out, one way or another, eventually.
Other than trying to get station markets or cargo contracts working, I do almost nothing with commodities markets.
I worked withphkb wrote: ↑Thu Dec 14, 2023 3:24 amAs I mentioned up-thread, you can get an estimate usingSystemInfo.samplePrice
for any system in the current galaxy. How different it would be to actually jumping into the system, I'm not sure, but if you don't want to do the whole jumping process thing, that might be an easier place to start.
SystemInfo.samplePrice
in my earlier mods of the core game's Cargo Contracts ...and that price generator was slightly broken too by cim's economic changes.OK, Hathor first.
That gives 2 average agris, 1 rich agri & 12 mainly agris. That makes a lot more sense to me. The price of food is not all that much, but the diferential for mainly agris would be worthwhile. I'd have expected more rich agris though, but if they are too poor to afford one, then they are too poor to afford one (you need to pay for patrols against pirates/Thargoids, too)! And 4 are confederacies, 2 democracies and 9 are corporate states.phkb wrote: ↑Fri Dec 15, 2023 1:13 pmOK, Hathor first.
The very first thing to deal with is the spawn rate. The current spawn script has Hathor stations turning up in about 50% of systems where the TL is greater than 7, and the government is either a Dictatorship, a Communist, a Confederacy, a Democracy or a Corporate State. That's probably too often based on the lore info, especially when economy doesn't play into the calculation at all.
How about this:
TL >= 8
Productivity >3000015000
Economy =Rich Ag, Avr Ag, Poor AgAny Agri system
(Edit to tweak numbers when I discovered that the initial set produced none).
Those parameters nets 15 systems in Gal 1 (Anbeen, Biisza, Ceedra, Celabile, Edorte, Edreor, Engema, Leoned, Ququor, Rarere, Rizala, Teveri, Tibionis, Veale, Xeer), which seems like a far more sustainable number of stations.
Code: Select all
"use strict";
this.name = "Hathor-Nephthys-populator.js";
this.author = "Thargoid";
this.copyright = "For Killer Wolf to use as he pleases.";
this.version = "1.1";
this.description = "Script to add Hathor and Nephthys stations to systems.";
this._always = false; // in case you want to put them everywhere! testing purposes, obviously
this.startUpComplete = function() {
// add hathor stations to market inquirer
if (worldScripts.market_inquirer) {
worldScripts.market_inquirer.$inquirerStations.push("KW_hathor");
}
}
this.systemWillPopulate = function() {
if (system.isInterstellarSpace || system.sun.isGoingNova || system.sun.hasGoneNova) { return; } // block them from appearing in interstellar space or nova systems.
if (this._always == true || (system.techLevel >= 7 && system.economy >= 4 && system.productivity > 15000)) {
var posHathor = Vector3D(0.0, 0.0, 0.7).fromCoordinateSystem("wsu");
system.setPopulator("KW_hathor", {
callback: function(pos) {
var hathor = system.addShips("KW_hathor", 1, pos, 0)[0];
worldScripts["Hathor-Nephthys-populator.js"].turnStation(hathor, system.sun);
log("populator", "Hathor added.");
}.bind(this),
location: "COORDINATES",
coordinates: posHathor,
deterministic: true
});
}
}
this.turnStation = function (stationEntity, targetEntity) {
if (!stationEntity.isValid || !targetEntity.isValid) { return; }
let stationVector = stationEntity.position.subtract(targetEntity.position).direction(); // unit vector pointing away from the sun
let angle = stationEntity.heading.angleTo(stationVector); // angle between current heading and target heading
let cross = stationEntity.heading.cross(stationVector).direction(); // set the plane where we should rotate in
stationEntity.orientation = stationEntity.orientation.rotate(cross, -angle); // re-orient the station away from the sun
}