Something I put together for post-0.70, currently testing for side effects.
I thought I should share it even while still waiting for 0.70, as the system is pretty simple and yet far-reaching, which makes me wonder why no one else had thought this up (And mayhap someone had and failed?) before.
Explanation for modders:
Explanation for non-modders:
This system allows countries to pay over-average prices for resources they really need - but also to recognise these trades as unprofitable as soon as their need passes and cancel those quickly.
Countries which attain large stockpiles through looting or simple passing of time (GER, ENG) will now be more willing to share this bounty with their allies and actually use the resources for something useful (such as trading for supplies - or resources from less bountiful stockpiles).
Similarly, countries which find themselves in a shortage unforeseen by the developer can now react. - Currently such countries would be stuck with trade values insufficient to solve the problem (I saw a JAP out of energy; CORE JAP is set to always trade energy for only 4/5 base price and usually it does have enough to warrant this setting).
However, there is no loss of control involved, as the system as presented can be overridden at any time by setting all the flags simultaneously. So, a custom AI file can still tell e.g. GER to import oil and rares no matter what, before it goes to war against almost all the oil producing world.
... AoD AI is a fickle thing though (I discovered a new AI bug two days ago; oh the joy), so this may still not work out as desired (but preliminary tests look good).
There obviously needs to be more fine tuning in the trigger than presented here (indeed I already use more complex conditions for rare_materials), but that is certainly not a problem.
Latest version:
View attachment CORE2_0.70_DynamicTradeValuesRC3_Zsar.zip
I thought I should share it even while still waiting for 0.70, as the system is pretty simple and yet far-reaching, which makes me wonder why no one else had thought this up (And mayhap someone had and failed?) before.
Explanation for modders:
core_AI_trade.txt
Trade_Energy_Neutral.ai
Total expenditure:
Code:
event = {
id = 35401 # subject to change; For testing with 0.68.2 build, I took the first free IDs I stumbled upon.
random = no
persistent = yes
trigger = {
ai = yes
NOT = {
ispuppet = -1 # going to expand into distinct puppet / non-puppet constraints later
# Puppets need slightly higher trade values as they can only buy from overlord.
# They also need vastly smaller stockpile values for everything but oil as they can only ever store 1000 units.
local_flag = Trade_Energy_Neutral # not pertaining to functionality, only prevents continuous triggering
}
# medium stockpile; numbers subject to change
OR = {
AND = {
NOT = { energy = 45000 } # 150 IC five months
energy = 28500 # 150 IC three months + five days
}
AND = {
NOT = {
ic = 51
energy = 15000 # five months
}
energy = 9500 # three months + five days
}
AND = {
NOT = {
ic = 31
energy = 9000 # five months
}
energy = 5900 # three months + five days
}
AND = {
NOT = {
ic = 11
energy = 3000 # five months
}
energy = 1900 # three months + five days
}
}
}
name = "AI: Neutral Energy Pricing"
style = 0
# Every one of these events gets a different day of the month but all share their frequency, so they will never overlap.
date = { day = 3 month = january year = 1936 }
offset = 29
# probably going to increase to two months;
# -1 to spread over all the days in a month (3rd; next 2nd; next 1st; etc.)
deathdate = { day = 29 month = december year = 1954 }
action_a = {
name = "Energy Prices stabilise"
command = { type = ai which = "switch/Trade_Energy_Neutral.ai" }
# four tiers of resource pricing in this implementation (others omitted here but can be guessed from flag names)
# Flags are not actually necessary but prevent successive triggering of the same event once per month.
# They also allow to switch the system on and off for individual countries and resource types,
# by setting all the flags of a type simultaneously (and clearing all of them to reactivate).
command = { type = local_clrflag which = Trade_Energy_Sell }
command = { type = local_setflag which = Trade_Energy_Neutral }
command = { type = local_clrflag which = Trade_Energy_Buy1 }
command = { type = local_clrflag which = Trade_Energy_Buy2 }
}
}
Code:
# only replaces this value; leaves all other contents of the trade block intact
trade = {
energy = 1.0 # subject to change
# Prices used here have been arbitrarily chosen to be 0.8 / 1.0 / 1.5 / 2.0 times
# base value from resource_values.csv.
}
- A constant number of events: for each resource type desired x the number of pricing tiers desired y(x)
The current test implementation uses x = 4 (energy, metal, rare_materials, oil) and y = 4 (see comment in Trade_Energy_Neutral.ai). - A constant number of AI files: one file per event from above
- One event trigger check per day for as many days per month as there are events
But possibly per just every second month may suffice.
A constant number of events monitor the resource stockpiles of all the AI countries in the world.
Once a country attains a sufficiently large stockpile, it will make the ressource in question cheaper, to facilitate export deals which help it with supplies and money (or import of different resources).
Conversely, when stockpiles dwindle, countries increase the price of the resources in question to facilitate import, as importing even at double the base price is usually better than losing IC.
Inbetween these behaviours, countries maintain average prices, at which anyone may buy from and sell to everyone else freely.
Once a country attains a sufficiently large stockpile, it will make the ressource in question cheaper, to facilitate export deals which help it with supplies and money (or import of different resources).
Conversely, when stockpiles dwindle, countries increase the price of the resources in question to facilitate import, as importing even at double the base price is usually better than losing IC.
Inbetween these behaviours, countries maintain average prices, at which anyone may buy from and sell to everyone else freely.
Countries which attain large stockpiles through looting or simple passing of time (GER, ENG) will now be more willing to share this bounty with their allies and actually use the resources for something useful (such as trading for supplies - or resources from less bountiful stockpiles).
Similarly, countries which find themselves in a shortage unforeseen by the developer can now react. - Currently such countries would be stuck with trade values insufficient to solve the problem (I saw a JAP out of energy; CORE JAP is set to always trade energy for only 4/5 base price and usually it does have enough to warrant this setting).
However, there is no loss of control involved, as the system as presented can be overridden at any time by setting all the flags simultaneously. So, a custom AI file can still tell e.g. GER to import oil and rares no matter what, before it goes to war against almost all the oil producing world.
... AoD AI is a fickle thing though (I discovered a new AI bug two days ago; oh the joy), so this may still not work out as desired (but preliminary tests look good).
There obviously needs to be more fine tuning in the trigger than presented here (indeed I already use more complex conditions for rare_materials), but that is certainly not a problem.
Latest version:
View attachment CORE2_0.70_DynamicTradeValuesRC3_Zsar.zip
Last edited: