Page 1 of 3

Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 4:38 pm
by Redspear
This is my take on the basic trade model inherited from elite.

Disclaimer: I'm new to tinkering with markets and so my coding is likely clunky and sub-optimal, almost certainly with anti-social behavioural issues when it comes to integrating with other oxps. I hope to be able to address any such issues as they arise.

That said, the basic idea is to keep the reliability of the standard trade model but not the monotony.

The standard model means that some items are always more profitable than others as long as you are trading in the right direction along the industrial to agricultural plane.

For example: not only are computers always more expensive than machinery but they are also always more profitable trade items than machinery.
The problem then is that there is no good reason to buy machinery when computers are available.

This model assigns each of the 8 economy types with a specific high-demand commodity. Population, productivity and tech level also exert some influence.

For example: computers still cost more than machinery but when shipping to a mainly agricultural or poor agricultural system they will not be as profitable.
The result is that at least sometimes the trader would now buy machinery in preference to computers.

Economy Type and Most Profitable Import:
  • Rich Industrial - furs
  • Average Industrial - liquor/wines
  • Poor Industrial - food
  • Mainly Industrial - radioactives
  • Mainly Agricultural - machinery
  • Rich Agricultural - luxuries
  • Average Agricultural - computers
  • Poor Agricultural - alloys
It is of course quite possible to argue over which commodity should go where and why but it's a simple matter to edit the oxp to one's own tastes (if you don't know how, just ask).

Further musings of the what, where, why variety can be found here.

Population, productivity and tech level also exert some influence, along with a dash of randomisation, but the above table should remain very reliable if not infallible.

Version 1.0 available from the download manager.

Re: Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 5:40 pm
by Old Murgh
Redspear wrote: Fri Dec 31, 2021 4:38 pm
It is of course quite possible to argue over which commodity should go where and why but it's a simple matter to edit the oxp to one's own tastes (if you don't know how, just ask).
I like the look of it. I'll play around with it. If customisation is as easy as you imply, I suspect I'll adjust at bit to my personal fancy. In my world, fine wine rates a bit higher than furs and rich agri would be more self-supplied with luxuries.

Not having sat down with it yet I already wonder, will I find a way to do an AND, as in equal desire for gold AND gemstones?

Re: Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 6:23 pm
by Redspear
Old Murgh wrote: Fri Dec 31, 2021 5:40 pm
If customisation is as easy as you imply, I suspect I'll adjust at bit to my personal fancy. In my world, fine wine rates a bit higher than furs and rich agri would be more self-supplied with luxuries.
I've just made it so that the most expensive items by default (eg. luxuries over computers) have the highest potential for demand amongst the wealthy. Tweaking the original rather than re-writing it...

Quick-fix if you'd rather change to your preference:
  • open it up
  • swap all mentions of furs with luxuries and vice versa - if using notepad ++ or similar I'd find and replace one of them with 'temp' fisrt so that you can then find and replace the other before doing similar with 'temp'

Old Murgh wrote: Fri Dec 31, 2021 5:40 pm
Not having sat down with it yet I already wonder, will I find a way to do an AND, as in equal desire for gold AND gemstones?
Not sure I've caught your meaning...
This doesn't do anything to gold or gemstone prices but again, you could make it so:
  • Suppose you want it to behave as commodity X (being one of the ones I've listed in the first post)
  • Duplicate any lines for X placing them on the very next line after their parent
  • With any such duplicates, replace the name of the original commodity with that of X

There are some inherent tech adjustments that you might want to consider:
  • tech level is used as a crude indication of 'development' and consequently of natural resources in order to achieve such a state
  • consequently food and furs, luxuries and alloys are cheaper on low-tech worlds
  • similarly radioactives and liqour/wines, computers and machinery are cheaper on high-tech worlds
    • yes it's both simplistic and questionable but again it's easily tinkered with if you don't like it (swap +/- to reverse)
    • it's there to further price varience, so it has a functional (if otherwise hidden) purpose

Hope that helps and if I still haven't answered your question them I'd be happy to give it another go.

Re: Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 7:12 pm
by Old Murgh
Redspear wrote: Fri Dec 31, 2021 6:23 pm
Not sure I've caught your meaning...
This doesn't do anything to gold or gemstone prices but again, you could make it so:
  • Suppose you want it to behave as commodity X (being one of the ones I've listed in the first post)
  • Duplicate any lines for X placing them on the very next line after their parent
  • With any such duplicates, replace the name of the original commodity with that of X
There are some inherent tech adjustments that you might want to consider:
  • tech level is used as a crude indication of 'development' and consequently of natural resources in order to achieve such a state
  • consequently food and furs, luxuries and alloys are cheaper on low-tech worlds
  • similarly radioactives and liqour/wines, computers and machinery are cheaper on high-tech worlds
    • yes it's both simplistic and questionable but again it's easily tinkered with if you don't like it (swap +/- to reverse)
    • it's there to further price varience, so it has a functional (if otherwise hidden) purpose
Hope that helps and if I still haven't answered your question them I'd be happy to give it another go.
I'm sure I could have put it more clearly. I didn't mean gold and gems specifically:

Let's say I am looking to assign another top priority to replace the one in the OXP. Can I add more than one, so to replace commodity X I might like to reassign Y (which I gather would be easy) but if I wanted to reassign two commodities of equal value Y and Z? Hence, could I replace furs with gold AND gemstones?

You write above that you are using tech level as conditions, and does it work here the same way as it would in a script i.e. the condition is a given number for systemTechLevel_number? I am asking since I would have thought with the economies being the topic at hand one would then use the systemEconomy_number. But maybe you've written it in a different way, I have never messed around with anything involving the commodities or the Trade-goods.plist.

I should probably look with my own eyes under the hood and maybe I would understand enough not to bother you with this inquest.

[edit]
Bugger, it's in java. I feel rather more helpless.

Re: Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 7:31 pm
by Nite Owl
Very interesting stuff. Currently still making my first loop of the Eight (in Sector 4 at the moment). Will stick with the simple default economy until my arrival back at Sector 1. This OXZ will then pair nicely with my desire to achieve the highest rank possible in the Famous Planets OXZ. That being to visit all 2048 planets in the Eight. Such a diverse economy as the one you have created here will be well suited to that pursuit. The only small suggestion would be to add a rich text file document to the OXZ that includes the list from your initial post that describes which economy favors which import. Have already made one for myself should you be interested. Brilliant work on both the import and supply side of the coding. Have v1.0 saved in my "unused" OXZ folder for future use and will keep an eye out should there be any updates. Thank You for your time and effort.

Re: Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 8:41 pm
by Redspear
Old Murgh wrote: Fri Dec 31, 2021 7:12 pm
Let's say I am looking to assign another top priority to replace the one in the OXP. Can I add more than one, so to replace commodity X I might like to reassign Y (which I gather would be easy) but if I wanted to reassign two commodities of equal value Y and Z? Hence, could I replace furs with gold AND gemstones?
OK, that's pretty much how I interpreted your question so my reply should hold true.
What I didn't metion however is that each commodity is accompanied by its base value in decicredits.

For example on the luxuries line ther'es the value 912 (91.2 credits) as the average value for that commodity, so if you're using that value for food for example then it will still work but food will now be a lot more expensive.

Old Murgh wrote: Fri Dec 31, 2021 7:12 pm
You write above that you are using tech level as conditions, and does it work here the same way as it would in a script i.e. the condition is a given number for systemTechLevel_number? I am asking since I would have thought with the economies being the topic at hand one would then use the systemEconomy_number. But maybe you've written it in a different way, I have never messed around with anything involving the commodities or the Trade-goods.plist.
It's all by script (which may not be the best way).
Tech level along with population, productivity and a dash of random are all just modifiers so that luxuries for example aren't the same price in every rich agricultural. Economy type is the most significant factor.

If we compare price variance to the tides then economy type is like the moon - there will be other influences but this is the major one.

Old Murgh wrote: Fri Dec 31, 2021 7:12 pm
Bugger, it's in java. I feel rather more helpless.
Javascript I think :? ... Having never learned either of them I could be wrong :lol:
:) I'll post a code example when I have more time.

Nite Owl wrote: Fri Dec 31, 2021 7:31 pm
The only small suggestion would be to add a rich text file document to the OXZ that includes the list from your initial post that describes which economy favors which import.
You're right, I was having trouble with the zipping process (of all things) and so non-essentials were getting trimmed while I worked it out. I'll add it to the next one.

Nite Owl wrote: Fri Dec 31, 2021 7:31 pm
Brilliant work on both the import and supply side of the coding. Have v1.0 saved in my "unused" OXZ folder for future use and will keep an eye out should there be any updates. Thank You for your time and effort.
Very generous of you. I'd just discovered Math.floor and Math.random (whilst actually getting them to work) :lol:

On exports there are relatively minor tech influences to price.
Productivity will influence supply of exports.

On imports government type will have a major influence on price.
Population will further influence that price (more population, more demand).

More of a cosmetic addition: economy type will also inflence stock of items in high demand.
For example a poor industrial, paying the higest prices for food, will have only a few TCs of food for sale if any - but variance was though preferable to a blanket 'none'.

And you're very welcome :D


EDIT: actually, explaining all that I've just noticed that there's a missing modifier to supply price. Without it, it's possible to find cheaper computers in an agricultural than an industrial - clearly that's wrong.

I'll fix and update to v1.1 next year :wink:

All the best everyone.

Re: Demand Driven Economy OXZ

Posted: Fri Dec 31, 2021 9:15 pm
by Old Murgh
Redspear wrote: Fri Dec 31, 2021 8:41 pm
Old Murgh wrote: Fri Dec 31, 2021 7:12 pm
Bugger, it's in java. I feel rather more helpless.
Javascript I think :? ... Having never learned either of them I could be wrong :lol:
:) I'll post a code example when I have more time.
Yes, I'm trying to pick up some things I used to know but have mostly forgotten about pLists (I gather a MacOSX preference back when]. This later javascript development is a bit too much for me now.

Looking forward to examples at your leisure.

Happy new year.

Re: Demand Driven Economy OXZ

Posted: Sat Jan 01, 2022 3:07 pm
by Redspear
Here's sample code from (soon to be released) v1.1

Code: Select all

if(system.economy == 0)     // rich industrial
        {
		new_stock = Math.floor((Math.random() + 0.5) * 60) - supply_mod;
        system.mainStation.setMarketQuantity("luxuries", new_stock);
		new_stock = Math.floor((Math.random() + 0.5) * 60) - supply_mod;
        system.mainStation.setMarketQuantity("computers", new_stock);
		new_stock = Math.floor((Math.random() + 0.5) * 60) - supply_mod;
        system.mainStation.setMarketQuantity("machinery", new_stock); 
		new_stock = Math.floor((Math.random() + 0.5) * 60) - supply_mod;
		system.mainStation.setMarketQuantity("alloys", new_stock); 
		
		new_price = Math.floor(system.mainStation.market.luxuries.price + (focus_mod * 4) + (Math.random() * (10 - 1 + 1) - 5));
		system.mainStation.setMarketPrice("luxuries", new_price);
		new_price = Math.floor(system.mainStation.market.computers.price - (focus_mod * 3) + (Math.random() * (10 - 1 + 1) - 5));
        system.mainStation.setMarketPrice("computers", new_price);
		new_price = Math.floor(system.mainStation.market.machinery.price - (focus_mod * 2) + (Math.random() * (10 - 1 + 1) - 5));
        system.mainStation.setMarketPrice("machinery", new_price); 
		new_price = Math.floor(system.mainStation.market.alloys.price + focus_mod + (Math.random() * (10 - 1 + 1) - 5));
		system.mainStation.setMarketPrice("alloys", new_price);  
		
		new_price = Math.floor(560 + 144 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 4));
		system.mainStation.setMarketPrice("furs", new_price);
		new_price = Math.floor(252 + 80 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 3));
        system.mainStation.setMarketPrice("liquor_wines", new_price);
		new_price = Math.floor(212 + 48 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 2));
        system.mainStation.setMarketPrice("radioactives", new_price); 
		new_price = Math.floor(44 + 32 + demand_mod + (Math.random() * (10 - 1 + 1) - 5));
		system.mainStation.setMarketPrice("food", new_price); 
		
		shortage_factor = Math.floor(system.mainStation.market.food.quantity / 1.5);
		system.mainStation.setMarketQuantity("food", shortage_factor);
		shortage_factor = Math.floor(system.mainStation.market.radioactives.quantity / 3);
		system.mainStation.setMarketQuantity("radioactives", shortage_factor);
		shortage_factor = Math.floor(system.mainStation.market.liquor_wines.quantity / 6);
		system.mainStation.setMarketQuantity("liquor_wines", shortage_factor);
		shortage_factor = Math.floor(system.mainStation.market.furs.quantity / 12);
		system.mainStation.setMarketQuantity("furs", shortage_factor);
        }
The opening line is just establishing that the following code runs in rich industrial systems only (it's the '0' that's key, not the 'rich industrial' text - appearing after the '//' means it's just reference to make the code easier to read).

After that we've got four blocks of code.

Block 1: establishes the quantity of key exports for this system (supply_mod is based on productivity and set elsewhere in the code)
Block 2: modifies the price of key exports based on tech level and some randomisation
Block 3: establishes the price of key imports based on economy type (rich industrial in this case) and population size
Block 4: modifies the quantity of key imports available for purchase based on demand priority

Armed with that knowledge, we now know where to look to if we wanted to make (for example) the changes suggested by (Old) Murgh:
Old Murgh wrote: Fri Dec 31, 2021 5:40 pm
fine wine rates a bit higher than furs and rich agri would be more self-supplied with luxuries.
Well, I'm just going to tackle the first one here.
So crudely (in the case of a rich industrial) we're looking at imports and we're looking primarily at pricing. Price of key imports is established in block 3 of the code, so lets take a closer look.

Code: Select all

		new_price = Math.floor(560 + 144 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 4));
		system.mainStation.setMarketPrice("furs", new_price);
		new_price = Math.floor(252 + 80 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 3));
        system.mainStation.setMarketPrice("liquor_wines", new_price);
		new_price = Math.floor(212 + 48 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 2));
        system.mainStation.setMarketPrice("radioactives", new_price); 
		new_price = Math.floor(44 + 32 + demand_mod + (Math.random() * (10 - 1 + 1) - 5));
		system.mainStation.setMarketPrice("food", new_price); 
Four differnt goods with two lines each. First ther'e a line doing the calculation and then there's a line formalising the price and naming the commodity. Swapping names about shout be simple enough so let's focus on the numbers.

Code: Select all

		new_price = Math.floor(560 + 144 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 4));
		system.mainStation.setMarketPrice("furs", new_price);
'Zooming in' once more, we've just got the first two lines setting the price for furs. Whatever we change the word furs to will be the commodity that is set at this price. The more interseting stuff ig oing on in the line above.

The first number of the calculation (560) is the average price of the intended commodity according to elite in decicredits (furs at 56.0Cr).
The second number (144) is the typical ammount that this government is prepared to pay 'over the odds' for the commodity in question.
demand_mod is based on population and the rest is just adding some random variance.

So if you just swap the word 'furs' for 'liquor_wines' then instead of just getting the 144 base profit margin, traders will be getting 144 + 560 (furs) - 252 (liquor_wines) = 452 base profit margin. Why? Because we've inflated the base price as well as the profit margin but in this system only.

So, if you want base prices to remain the same (e.g. furs might be more expensive but wines are more profitable) then just swap the second numbers around (profit margins).

So, making liqour wines more profitable than furs but not more expensive (in this system type) only requires swapping two numbers:

Code: Select all

		new_price = Math.floor(560 + 80 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 4));
		system.mainStation.setMarketPrice("furs", new_price);
		new_price = Math.floor(252 + 144 + demand_mod + ((Math.random() * (10 - 1 + 1) - 5) * 3));
        system.mainStation.setMarketPrice("liquor_wines", new_price);
The respective base profit margins of 144 and 80 have simply been swapped and now furs is ranked second after liquor wines as the most profitable import to ship to a rich industrial.

Phew... Hopefully that wasn't so long winded as to be confusing :?

Re: Demand Driven Economy OXZ

Posted: Sat Jan 01, 2022 3:21 pm
by Old Murgh
Redspear wrote: Sat Jan 01, 2022 3:07 pm
..
Phew... Hopefully that wasn't so long winded as to be confusing :?
No, I guess that's what it takes. Thanks for taking the time to spoon feed. It's 3D chess but you point out the crucial bits. I feel I should be able to make my eventual tiny alterations.

Re: Demand Driven Economy OXZ

Posted: Sat Jan 01, 2022 5:42 pm
by Cholmondely
Old Murgh wrote: Fri Dec 31, 2021 9:15 pm
Redspear wrote: Fri Dec 31, 2021 8:41 pm
Old Murgh wrote: Fri Dec 31, 2021 7:12 pm
Bugger, it's in java. I feel rather more helpless.
Javascript I think :? ... Having never learned either of them I could be wrong :lol:
:) I'll post a code example when I have more time.
Yes, I'm trying to pick up some things I used to know but have mostly forgotten about pLists (I gather a MacOSX preference back when]. This later javascript development is a bit too much for me now.

Looking forward to examples at your leisure.

Happy new year.
The legacy scripts still work just fine. There are some changes (eg. with markets: stations now need to have a market defined in either legacy script or javascript or the market will not work, the AI's for npc's are much more complex, and I'm unsure to what extent the old AI's still work). And javascript is supposedly far more flexible.

I'm currently playing with Hotrods (written in OpenStep). Seems to work just fine and adds lots of fun to my game....

Happy New Year to you too!

Re: Demand Driven Economy OXZ

Posted: Sat Jan 01, 2022 9:52 pm
by Redspear
Cholmondely wrote: Sat Jan 01, 2022 5:42 pm
I feel I should be able to make my eventual tiny alterations.
Cool, just ask if you get stuck.

Meanwhile v 1.1 has been uploaded
Main change was to fix issue with export prices.

Now that I seem to have got the hang of at least one way of manipulating markets I think it's time to blow the dust off a long-standing WIP.

Re: Demand Driven Economy OXZ

Posted: Tue May 31, 2022 8:29 pm
by Redspear
Playing around with this for a while (during rescaling) I've become aware of a couple of issues.
  • Goods quantities (supply) aren't always working as intended
  • Food in particular makes it too easy to make good money from the start

The first point is a coding fix but the second is arguably a design flaw. When the cheapest commodity can (in one case) also be the most profitable then that can start to function as an exploit.

Whilst I can easily nerf the profits from food, it is so cheap in the first place that they really would take a relative hammering. Rather than that, time for another rethink....

Image


A few things to note here:
  • food is no longer (ever) a high profit item
  • textiles, whilst still cheap, still offer significantly more room for manouver re cost : profit ratio
  • two of the cheapest good (food & minerals) are also the two easiest to reliably trade without being fussy re destination
  • theres been a reshuffle of who demands what, especially re unprocessed goods

Should the rock hermit supply minerals or demand them?
(there is a point here if you bear with me...)

They certainlty work with them but if...
Minerals : Unrefined rock containing trace elements
...is true then shouldn't they be looking to profit from those trace elements? Aren't they what make the rock valuable?
In which case they are likely to produce...
Minerals : Refined rock no longer containing trace elements
In other words, their selling minerals (as typically presented in game) would be inefficient at best and foolish at worst.
They may even pay you slightly more for minerals (esp. from elsewhere) as you'd be helping to fund their livelihood.


My point being that it's possible to rethink minerals (as described) as primary production raw materials rather than primary production outputs.
My purpose being that I can the solve the 'food problem' mentioned above and yet require a no less reasonable model in order to do so.

Radioacties are slightly different...
Radioactives : Ores and by-products
...but then that might depend upon what they were being used for.

As for luxuries, as Cholmondely has pointed out before, coffee, perfumes and spices all sound sufficiently like agricultural produce anyway, and just the sort of thing to be in high demand at a rich industrial system.


I've yet to do the recoding but if I still can't upload to the wiki then I'll give my ideas a bit more time to stew first.

Re: Demand Driven Economy OXZ

Posted: Mon Dec 05, 2022 1:00 pm
by Redspear
  • v 1.2 with cosmetic improvement (oooh, nice :P )
    • replaced food with textiles for poor industrial demand
    • added descriptions to f7 screen for in game hints/explanation

Image

Image

Image

Image

Image


You get the idea...

...and yes, I've just noticed the typo damn it! :roll: :lol:

Re: Demand Driven Economy OXZ

Posted: Tue Dec 06, 2022 11:35 pm
by Redspear
  • v1.3...
    • much more variety of f7 descriptions: each system description hints at it's import demands
    • adjusted profit margins: generally less lucrative with the notable exception of...
    • new, additional trade demands for the more dangerous systems (hinted at in the f7 descriptions)
    • now incorporates every commodity bar one, for which I have other plans... moo hoo, moo ha ha... MOO HOO HOO HA HaHaHaaaa...

Re: Demand Driven Economy OXZ

Posted: Wed Dec 07, 2022 2:08 pm
by Redspear
After the last update a brief explainer of sorts might be in order.

To make a profit, ship an agricultural commodity to an industrial system or vice versa.
  • 'Agricultural' goods (extracted/harvested): textiles, radioactives (mined ores), liquor/wines, furs
  • 'Industrial' goods (processed/manufactured): alloys, machinery, computers, luxuries

Some will make more money than others depending upon which economy type you ship them to. Generally speaking, the richer the economy, the more expensive its tastes and the more it will pay over the odds for them.

The other goods are either very cheap, legally controlled or available in smaller quantities than 1TC. Credits can be made shipping them here and there but that said, each of them is in particular demand by multi-gov, feudal and anarchy systems. The more insular or hazardous the system is the more it is likely to crave basic goods such as food and 'workers' or means of 'control' such as firearms.

  • So there are three (informal) 'levels' of trade, from the fairly ignorant to the savvy
    • Trader: ship any agricultural item (from any agri market) to any industrial system or vice versa (likely profit: low)
    • Merchant: as 1 but ship it to the right system (likely profit: medium)
    • Blockade Runner: ship a very particular item to a rather dangerous system (likely profit: high)

Alien items are currently the 'odd commod' but will later either be integrated into this oxp or into another that I'm working on.

Hints:
  • Check the f7 screen - Remember, it's about what they demand more than it's about what they supply
  • Richer systems generally pay more for more expensive stuff
  • Ship agricultural to industrial and industrial to agricultural (both in terms of systems and goods) and you should always make something