The economic model is the architecture by which we want the code to implement. It comprises the theory by which the organic economy should operate on. The scripting will be done to implement this framework in a coherent and extensible manner.
The foundation for the economic model is geographical oriented. Every region has geographical factors (access to sea, mines, farmland, trade routes, etc.) that effects the potential within a settlement. That is to say, not every city has the requisite to become a burgeoning economic metropolis. Geographical potential is measured from a level of 0 to 16 and is dependent on the following factors:
- Water Access
- Land Access
- Natural Resources
- Agriculture
Each area except for Governor has 4 possible states.
Water access:
- No Water
- River
- Minor Sea
- Major Sea/Ocean
Land Access:
- Difficult to traverse region
- Accessible region
- Region is situated in a minor trade route
- Region is situated in a major trade route
Natural Resource:
- No natural resource
- One regular resource
- One premium (or multiple regular) resource
- Multiple premium resources
Agriculture:
- Non-sustainable land (Desert, Frozen Wastes)
- Some sustainable land (Tundra, Mountains,
- Sustainable land (Steppes,
- Optimal land (River Delta, Plains)
Potential is filled by the development of those areas and an additional three factors which effect the potential with geometric growth:
- Trading Partners
- Population
- Governor's management traits
Trading Partners: - Has been coded - now its just a matter of checking the counter whenever we need
- No trading partners
- One trading partners
- Four trading partners
- Ten trading partners
Population size:
- Large Town
- City
- Large City
- Huge City
Governor is an entirely separate function that helps attain maximum potential but in a very different methodology.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Psuedocode extended - Governors not included at the moment.
I am writing this as my vision of how this works so I can start coding a few settlements.
There will be X levels of Economic Potential. Each level will be assigned a value that is stored in a counter.
Level 1 1000
Level 2 2000
Level 3 3000
Level 4 4000
Level 5 5000
Level 6 6000
Level 7 7000
Level 8 8000
Level 9 9000
Each level will then set an event_counter to enable various bonuses stored in export_descr_buildings.txt. This way a Smith in a Huge City will produce exponentially more income than a Smith in a Village. Every single building in the EDB file will have all potential levels listed in their capability section, with various bonuses that each building can give.
Economic Potential can be increased by adding government buildings and increasing settlement size. Some cities will not be able to reach full potential because they lack enough land/water/naturaul resources. So the cap for London might be level 6 but the cap for Constantinople might be level 10.
New global_counters:
bonus_level - checked at SettlementTurnEnd
Settlement level counters, note that I am adding a few for each settlment. Originally there were 2.
settlement_economy - Increasing this will increase the chances of new merchants
settlement_crime - Increases the chances of criminal activity - more ideas/work needed here.
settlement_potential - The cap based on values above
settlement_actual - The stored value of all economic buildings in a settlement. (Note to self) DO NOT COUNT crime buildings.
settlement_market - Raw number of economic that exist - caps determined by market level.
settlement_enable_construction - An event counter that is either true/false
Other possible counters:
settlement_number_MerchantName - The max number of a certain kind of merchant. We will terminate_monitor on any building tree that hits the max. Default is 1. These numbers can go up based on settlment_potential or other conditions.
Each region is assigned a value based upon local resources present at game start. Values to be determined. Probably somewhere between 0 and 100. This sets the base level for Economic Potential. Then add in the value for the buildings that exist at game start to get the total Economic Potential for each settlement.
So all settlements will be set at game start based upon manually calculated numbers:
Code:
monitor_event PreFactionTurnStart FactionIsLocal
set_counter london_potential 1
set_counter paris_potential 2
;etc etc one for each city
set_counter london_market; - set the initial market cap for each settlement based on market level
terminate_monitor ;once this is set no need to reference it again, kill the monitor
end_monitor
Then there will be a bunch of monitors that check the status of each settlement for stuff such as tax_rate and governor_traits. At each SettlementTurnEnd these factors will add up in settlement_economy and settlement_crime, which will get reset at each SlaveTurnEnd to 0. This will allow factors to change but will require that it is calculated each turn. Its possible we could combine these into a single counter if we do random percents correctly but for now we will leave two.
Note that for this to work it HAS to progress in the order outlined below. Doing things out of order will cause problem.
Check tax_rate first. 5 monitors but only 1 can be true:
Code:
monitor_event SettlementTurnEnd SettlementName London
and taxes = high
set_counter london_crime XXX
set_counter london_economy XXX
end_monitor
monitor_event SettlementTurnEnd SettlementName London
and taxes = low
set_counter london_crime YYY
set_counter london_economy YYY
end_monitor
monitor_event SettlementTurnEnd SettlementName London
and taxes = normal
set_counter london_crime ZZZ
set_counter london_economy ZZZ
end_monitor
After that check if a Governor is in the settlement. Note that we INCREMENT these values not SET.
Code:
monitor_event SettlementTurnEnd SettlementName London
and GovernorInResidence
inc_counter london_crime -AAA ;decrease chance for crime
inc_counter london_economy BBB ;increase chance for business
end_monitor
monitor_event SettlementTurnEnd SettlementName London
and not GovernorInResidence
inc_counter london_crime AAA ;increase chance for crime
inc_counter london_economy -BBB ;decrease chance for business
end_monitor
Then we compare the settlement_market, settlement_actual and settlement_potential and get a true/false to allow new buildings. If actual > potential then deny new economic buildings. New crime buildings still allowed.
One monitor for each level of market: (NOTE TO SELF) Set all these to a default value at PreFactionTurnStart FactionIsLocal, either true or false just pick one. To be determined, shortest code wins, go from lowest level to higehst to prevent multiple conditions being true. Probably should be set to true for error catching purposes.
Code:
monitor_event SettlementTurnEnd SettlementName london
and SettlementBuildingExists MarketName1
and I_CompareCounter london_market => X
set_event_counter settlement_enable_construction 0 ;disable or disable construction by script or by player
end_monitor
Once we have determined whether or not to allow buildings, then check the cap.
Code:
monitor_event SettlementTurnEnd SettlementName london
if I_EventCounter settlement_enable_construction == 1 ; if construction is enabled then check caps, if disabled no need to do anything.
if I_CompareCounter london_potential == 1 ;potential is between 1000 and 2000
and I_CompareCounter london_actual => 2000 ;disable new buildings
set_event_counter settlement_enable_construction 0
end_if
if I_CompareCounter london_potential == 2 ;potential is between 2000 and 3000
and I_CompareCounter london_actual => 3000 ;disable new buildings
set_event_counter settlement_enable_construction 0
end_if
;need one condition for each level of potential
end_if
end_monitor
Now we have determined whether or not new buildings will be allowed. We can then check for new buildings to be created via script. This can all be done inside one big monitor with nested IF statements. The same for crime buildings but we can add those later after we nail this process down.
Code:
monitor_event SettlementTurnEnd SettlementName london
and I_EventCounter london_enable_construction == 1
if I_CompareCounter london_ecnonomy > x ;is economic value between two numbers?
and I_CompareCounter london_ecnonomy < y
RandomPercent create building 1 - remember to check max_merchants first
RandomPercent create building 2 - also remember to increase the related counters if building gets created
RandomPercent create building 3
RandomPercent create building 4
RandomPercent create building 5
RandomPercent create building 5
end_if
if I_CompareCounter london_ecnonomy > A ;is economic value between next two numbers?
and I_CompareCounter london_ecnonomy < B
RandomPercent create building 1 - remember to check max_merchants first
RandomPercent create building 2
RandomPercent create building 3
RandomPercent create building 4
RandomPercent create building 5
RandomPercent create building 5
end_if
;set several levels of economic value so we can have several different RandomPercent values
;at the end of this monitor set our bonus_level based on settlement_actual
if settlement_actual > A and below B then set_counter bonus_level 1
if settlement_actual > B and below C then set_counter bonus_level 2
end_monitor
Now all of our buildings for this turn have been created, either by script or by the player. We can add a SettlementSelected monitor and allow/disallow certain buildings for the player with the same settlement_enable_construction counter. Also note that some of these probably should be done at SettlementTurnStart rather than SettlementTurnEnd. I will figure out the best method once I get into seriously coding settlements.
Now we need to figure out our bonus levels. The settlement_potential sets the base for our bonus level, but we need to move it up or down depending on our region status: drought, severe_drought, recession_severe recession etc.
Code:
monitor_event SettlementTurnEnd SettlementNameLondon ;check status for region_weather_status and region_economy_status
if I_EventCounter britain_weather_status 1 ;severe_drought
lower bonus_level
end_if
if I_EventCounter britain_weather_status 2 ;drought
lower bonus_level
end_if
if I_EventCounter britain_weather_status 3 ;normal
do nothing bonus is flat
end_if
if I_EventCounter britain_weather_status 4 ;good_harvest
raise bonus_level
end_if
if I_EventCounter britain_weather_status 6 ;great_harvest
raise bonus_level
end_if
;do the same for region_economy_status
end_monitor
Note that we could also throw in some conditions that raise/lower bonuses on a faction wide basis and then check those values here before we move on to the next step.
Then compare bonus_level and set the actual bonus to be read by the EBD.
Code:
monitor_event SettlementTurnEnd SettlementName london
if I_CompareCounter bonus_level == 1
set_event_counter bonus_level_1 1
set_event_counter bonus_level_2 0
set_event_counter bonus_level_3 0
set_event_counter bonus_level_4 0
set_event_counter bonus_level_5 0
set_event_counter bonus_level_6 0
set_event_counter bonus_level_7 0
set_event_counter bonus_level_8 0
set_event_counter bonus_level_9 0
set_event_counter bonus_level_10 0
end_if
if I_CompareCounter bonus_level == 2
set_event_counter bonus_level_1 0
set_event_counter bonus_level_2 1
set_event_counter bonus_level_3 0
set_event_counter bonus_level_4 0
set_event_counter bonus_level_5 0
set_event_counter bonus_level_6 0
set_event_counter bonus_level_7 0
set_event_counter bonus_level_8 0
set_event_counter bonus_level_9 0
set_event_counter bonus_level_10 0
end_if
;note you have to set each one EVERY single time or bonuses will stack up
;do this for each bonus_level
end_monitor
At this point we end the settlement processing for this settlement. What we need to do now is start plugging in numbers for the regional status and coming up with values for each building as we create the new trees. We can add as many bonus levels as we want, I havent ran into a cap on those yet.
This is FAR from a finished outline, but I wanted to get some process down in writing so I have a good base to work from.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
As discussed via PM, each region will have a unique status set at slave TurnEnd. There are 11 regions.
british isles
spanish peninsula
africa
america
middle east
italy
russia
turkey
romania - includes greece
eastern europe
western europe
For weather/farming I suggest 5 options: normal, drought, severe_drought, good_harvest, great_harvest
For income/economy I suggest 5 options: normal, recession, severe_recession, expansion, boom
I will set them all completely at random at game start. After that we need to decide how to move between levels. If we do it randomly we could have a severe_drought one turn and a great_harvest the next, which while remotely possible might not be exaclty the way we want to do it.
I suggest we either go up one level, go down one level, or stay the same.
~~~~~~~~~~~~~~~~~~
I definitely agree with go up/go down or stay the same and I think it should be increasingly rare to go very high or go very low. So huge droughts and abundant harvests should be the most rare scenarios with normal being the most common. Bell curve style.
~~~~~~~~~~~~~~~~~~
I set up a quick version of this, but it needs to be tweaked a bit. The region status is set randomly at the beginning of the game, 60% chance of normal 10% chance for everything else. It works but as you say severe_drought shouldnt have as good a chance as drought. Just the initial monitor alone is 665 lines of code but I might be able to trim that a bit.
How about this for initial setup?
1. 5% severe_drought
2. 15% drought
3. 60% normal
4. 15% good_harvest
5. 5% great_harvest
1. 5% severe_recession
2. 15% recession
3. 60% normal
4. 15% expansion
5. 5% boom
Then after that everything should normalize towards center.
If normal (3) then 70% chance remaining normal 15% chance of going up/down.
If 2 or 4 then 70% chance of moving towards center, 20% stay the same, 10% move to extreme levels.
If 1 or 5 then 10% chance of staying the same, 90% chance of moving towards center.
~~~~~~~~~~~~~~~~~~~~
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
I think our merchants should extend from the resources. We can ignore merchants like cobblers and such that do not come from resources because they would be present in nearly city and generate little income. We can always add them later if we have room. I have broken up resources into the following categories and italicized premium resources (values are default but I think we will eventually adjust them heavily). I'll add a list from this of the various guilds/craftsman that would appear. For example, Timber + coastal access = Shipwright.
Land Resources
coal 4
gold 20
iron 9
marble 10
silver 12
sulfur 5
tin 6
spices 12
furs 3
ivory 12
slaves 8
Agricultural Resources
cotton 8
grain 5
silk 12
timber 6
tobacco 15
wine 8
wool 6
textiles 8
sugar 10
chocolate 15
spices 12
Water Resources
amber 12
fish 5
dyes 8
~~~~~~~~~~~~~~~~~~~~~~~
What about something to do with Coin minting? In RS, I've branched mines for public and private ownership (for different bonuses) and smiths branch into weapons or gold smithing/coin minting. (We've only got 64 building trees, so I have to combine trees I'd rather have separate)
Are these industries going to be tied to specific regional resources? I think it could add more of a strategic element to the strat map. Regions that were historically rich will be able to build more industries due to the presence of more resources. We have a 'capital' type resource in the major cities where any industry can be built, but you make more money off an industry if you don't have to import the raw materials. In RS, I have weapon upgrades tied to the quality of metal in the region. I realize iron/copper/bronze was often imported and exported, but I felt the additional strategic element was too valuable to pass up. I believe some cannons were made from bronze during this period, this can be simulated with copper+tin.
Other things might be a construction guild (improve build times of buildings, maybe increase levy troops) as it requird a lot of organized labor to build massive public works. I believe that was how armies first formed, levying the harvesters in the fields, but I don't know if they fit in this era or not.
One thing I do for the RS industry is allow a certain number of 'slots' for industry buildings. Every 'upgrade' for a city allows another slot. We have 8 types of industry, with only 5 able to be built in any particular city (as long as they have the resources) YOu may want more in your era (as you have more buildings to use) but it's something to consider. Make it so each city isn't built identical to the next one! It's how it happened in real life, we should be able to get that in game.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hidden_resources hardcode maximum 64
16 Default hidden_resources
11 set aside for regions
Normal Resources
Grain extends Brewer, Baker
Cotton extends Haberdasher, Draper, Milliner
Wool extends Haberdasher, Draper, Milliner, Wool-merchant, Stockyard
Textiles extends Mercer, Tailor
Fish extends Fishmonger
Gold extends Goldsmith, Mint
Furs extends Skinner
Spices extends Grocer
Wine extends Vintner
Sulfur extends Gunsmith (late era)
Charcoal extends Gunsmith (late era)
Iron extends Armorsmith
Marble extends Mason
Hidden Resources
Honey extends Brewer, Grocer
We have 9 levels per tree so for reasons of necessity, some things will have to be tied together. Like a gold Mines might extend into Goldsmith and then into Mints.
~~~~~~~~~~~~~~~~~~~~~~~~~~
A couple other issues I'm trying to resolve in RS:
1. City Growth vs. Number of buildings
My only experience with MTW2 is the SS mod for kingdoms, so keep this in mind. A notice the growth is better, but frequently there is little reason to construct buildings commonly found in cities, such as schools. I think an educated labor force should unlock higher tier industrial buildings. Furthermore, in RTW at least, cities get to the highest level fairly quickly, with most of the buildings unnecessary for this expansion. The AI as well, rarely builds most building because they have little effect. I mean, bonuses like
'taxable_income_bonus bonus 10'
or
'trade_bonus bonus 1'
Don't have a large impact unless there is huge trade happening in the cities. In SS, it might take me the whole game to get a profit off those trade buildings! They need to provide more tangible benefits, which is what I"m working on, and leads us to issue 2...
2. Uniqueness of cities
In Every RTW mod, EVERY CITY IS THE SAME. I build the best temple, best farms and health for the population, and I'm done. Cities like Carthage, Rome, and Byzantium should be huge centers of commerce, and yet rarely (unless they have a huge bonus at the beginning) reach a level of prospertity over their neighbors. With a larger amount of buildings available, it will force the player to (hopefully...) specialize between military and economic concerns. It might also be interesting if base resources, even without industry, provided small bonuses (areas with grain may farm better, amber doesn't necessarily need a whole indutry around it to generate revenue, etc.)
The largest issue is balancing growth so cities don't expand too fast (thus not having the buildings they historically would have had), and not having too many buildings, overwhelming the player with options. I see no reason to quantify every type of industry available, especially for every city. Can we assume every province has some sort of blacksmithy available? I like to think the buildings as areas of specialization, as well as government intervention. However, without knowing the philosophy this modifcation has, it's difficult to come up with more ideas.
What do buildings represent to you guys?
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------