Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Project & Mod Development > Civ4 - Rhye's and Fall of Civilization

Notices

Reply
 
Thread Tools
Old Dec 02, 2009, 09:33 AM   #1
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
RFC's Great Depression Debacle

As I've illustrated in the Bug Report post -

http://forums.civfanatics.com/showpo...&postcount=906

there are some serious issues in the current "Great Depression" mechanisms and modelling algorithms.

"Great Depression" as described in the wiki -
"Great Depression
It happens if a civilization has excessive production over commerce (which causes deflation), while it's running a free market economy. It's a big hit to a country's stability and can affect all the civs which have an open border agreement with this civilization. Switching away from free market is a solution to quit the depression, but it's dangerous! A period of anarchy is definitely the last step towards civil war. You'd better be careful then, and if your total rating is unstable or worse, it's better to improve stability by other means (such as building wonders) and wait until it's over."
Yet there is no clear display in the UI of exactly what is being considered "commerce" for the purpose of this calculation. As it turns out, even though "production" is displayed and graphed in the "Info" screens, "commerce" is surpisingly absent.

At first glance, it is easy to assume that "GNP (Gold)" is what is being referred to, but it absolutely has nothing to do with the final calculations of when a "Great Depression" is triggered.

The point of this post is to illustrate that if a player has any hope to even a limited ability to avert a "Great Depression", then they need access to meaningful information as to the market conditions that prompt its occurence.

The only advise given being - "switching away from free market" is woefully inadequate.

Last edited by DorianGray; Dec 02, 2009 at 11:37 AM. Reason: adjust link to specific post
DorianGray is offline   Reply With Quote
Old Dec 02, 2009, 09:39 AM   #2
FakeShady
Prince
 
FakeShady's Avatar
 
Join Date: Sep 2009
Location: Singapore
Posts: 372
i admit i never really cared how to avoid a Great Depression when i'm on free market, but i do realize that if i spam cottages, have lots of commerce and low production, i never once had a Great Depression.
FakeShady is offline   Reply With Quote
Old Dec 02, 2009, 09:58 AM   #3
Panopticon
Utilitarian
 
Join Date: Aug 2007
Location: Ireland
Posts: 1,151
Images: 4
This is probably why Great Depressions seem so random. I'm glad someone finally went through the code. Well done.
Panopticon is offline   Reply With Quote
Old Dec 02, 2009, 10:26 AM   #4
AnotherPacifist
Deity
 
AnotherPacifist's Avatar
 
Join Date: Sep 2007
Posts: 4,878
Well, random depressions and recessions happen in life too. And it's usually the Republicans' fault. (or is it the Democrats' who then take the credit for getting us out of recession)
What is seriously needed is a displayable Great Depression gauge that would allow you to adjust commerce. We know more about turn-to-turn stability since Rhye adopted the numeric +/- system, maybe he can put one more piece of code to let us know how much excess production and commerce is present each turn.
__________________
Ferengi Rule of Acquisition no. 34:
War is good for business... only from a distance, the closer to the front lines, the less profitable it gets.
AnotherPacifist is offline   Reply With Quote
Old Dec 02, 2009, 10:40 AM   #5
Panopticon
Utilitarian
 
Join Date: Aug 2007
Location: Ireland
Posts: 1,151
Images: 4
Maybe Great Depressions should destroy your cities' Banks.
Panopticon is offline   Reply With Quote
Old Dec 02, 2009, 11:03 AM   #6
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Quote:
Originally Posted by AnotherPacifist View Post
What is seriously needed is a displayable Great Depression gauge that would allow you to adjust commerce.
Agreed. What I'm thinking is a modfication to the "Info" screen that adds another historical graph similiar to GNP, Production, etc; but would correctly display the "Commerce" value that is used in the "Great Depression" calculations.
(I know how to do this, but it would require a change to the DLL and the save game format.)

I'm thinking this will also help in the final adjustment in the "Great Depression" algorithms to model the occurences more accurately.

Ultimately, there are going to be times when your economy gets so "out of wack" that there are going to be nothing you can do to avert a "Great Depression". ( as when it is inherited from one of you neighbors ) However, a player needs to have reasonable access to key indicators to allow various tweaks along the way and means to help recover from a "Great Depression" when it does occur.
DorianGray is offline   Reply With Quote
Old Dec 02, 2009, 11:10 AM   #7
apenpaap
Ceridwen
 
apenpaap's Avatar
 
Join Date: Apr 2008
Location: Amsterdam
Posts: 1,041
Images: 10
Great Depressions should have very low effect on nations in State Property. The Soviet Union was about the only country in the world that had little problems with it.
apenpaap is offline   Reply With Quote
Old Dec 02, 2009, 11:28 AM   #8
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Quote:
Originally Posted by apenpaap View Post
Great Depressions should have very low effect on nations in State Property. The Soviet Union was about the only country in the world that had little problems with it.
You are correct sir. To the best of my knowledge, this is only applicable to "Free Market" economies.
DorianGray is offline   Reply With Quote
Old Dec 02, 2009, 11:41 AM   #9
apenpaap
Ceridwen
 
apenpaap's Avatar
 
Join Date: Apr 2008
Location: Amsterdam
Posts: 1,041
Images: 10
Yeah, only Free Markets can get it, but State Properties can get the negative effects of someone else having it.
apenpaap is offline   Reply With Quote
Old Dec 02, 2009, 12:24 PM   #10
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Further probable issues

After some more research, it appears that some of the underlying function calls used in Stability.py script to calculate "iIndustry" and "iEconomy" have changed from Civ:Vanilla, Civ:Warlords as described here:

http://www.civfanatics.com/civ4/stra...mographics.php

Some of these same functions are also used in the "Demographics" screen.

I don't know the history of modifications made to "Stability.py", but there may have been an attempt to compensate for the change in the underlying return values from these functions that just didn't get it right.

As pointed out in the Bug post, the underlying functions that are getting called in Stability.py are inconsistent in their implementation now and do not mirror the use of specialists and building modifiers the same now. At an early time, they may have behaved more consistent.

After review of the referenced link above, it becomes easier to understand how the RFC "Great Depression" model has become so horked now.
DorianGray is offline   Reply With Quote
Old Dec 04, 2009, 03:12 AM   #11
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
I have been working to address some of the underlying problems in the "Great Depression" implimentation. Most importantly, a better "iEconomy" representation that takes "Trade Routes", "Merchants", "Corporations" and "Religious" factors into consideration.

I used one of "Sevo" Mods as a baseline for the UI modifications, but added several python scripts to correctly calculate the commerce data. (in the upper left hand corner)

Following are the relevent modifications to CvMainInterface.py

Spoiler:


szBuffer = "Plot Raw Commerce:"

screen.setLabel( "MaintenanceTextb", "Background", szBuffer, CvUtil.FONT_LEFT_JUSTIFY, 15, 146, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTextb" )

szBuffer = "Trade Routes:"

screen.setLabel( "MaintenanceTextc", "Background", szBuffer, CvUtil.FONT_LEFT_JUSTIFY, 15, 166, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTextc" )

szBuffer = "Buildings and Specialists:"

screen.setLabel( "MaintenanceTextd", "Background", szBuffer, CvUtil.FONT_LEFT_JUSTIFY, 15, 186, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTextd" )

szBuffer = "<color=205,180,55,255>Net iEconomy:</color>"

screen.setLabel( "MaintenanceTexte", "Background", szBuffer, CvUtil.FONT_LEFT_JUSTIFY, 15, 206, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTexte" )

pPlayer = gc.getPlayer(pHeadSelectedCity.getOwner())

pySelectedCity = PyCity(pPlayer.getID(), pHeadSelectedCity.getID())

iPlotCommerce = pySelectedCity.getWorkingPlotsYield(YieldTypes.YIE LD_COMMERCE)

iBuildingsAndSpecialistsCommerce = pySelectedCity.getSpecialistsCommerce(CommerceType s.COMMERCE_GOLD) + pySelectedCity.getBuildingsCommerce(CommerceTypes. COMMERCE_GOLD)

szBuffer = u"-%d.%02d %c" %(iMaintenance/100, iMaintenance%100, gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).ge tChar())

screen.setLabel( "MaintenanceAmountText", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, 220, 126, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_HELP_MAINTENANCE, -1, -1 )

screen.show( "MaintenanceAmountText" )

# Show Plot Commerce
szBuffer = u"%s%d %c" %( "+", iPlotCommerce, gc.getYieldInfo(YieldTypes.YIELD_COMMERCE).getChar ())

screen.setLabel( "MaintenanceTextf", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, 220, 146, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTextf" )

iEconomyTimes100 = iPlotCommerce * 100

# Show Trade Route Commerce
szBuffer = u"%s%d %c" %( "+", iNetTradeAmount, gc.getYieldInfo(YieldTypes.YIELD_COMMERCE).getChar () )

screen.setLabel( "MaintenanceTextg", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, 220, 166, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTextg" )

iEconomyTimes100 += (iNetTradeAmount * 100)

# Show Buildings and Specialists
szBuffer = u"%s%d %c" %( "+", iBuildingsAndSpecialistsCommerce, gc.getYieldInfo(YieldTypes.YIELD_COMMERCE).getChar ())

screen.setLabel( "MaintenanceTexth", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, 220, 186, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTexth" )

iEconomyTimes100 += (iBuildingsAndSpecialistsCommerce * 100)
iEconomyTimes100 -= iMaintenance

# Show Total iEconomy
szBuffer = u"<color=205,180,55,255>%s%d.%02d</color> %c" %( "+", iEconomyTimes100 / 100, iEconomyTimes100 % 100, gc.getYieldInfo(YieldTypes.YIELD_COMMERCE).getChar () )

screen.setLabel( "MaintenanceTexti", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, 220, 206, -0.3, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

screen.show( "MaintenanceTexti" )


Previously "iEconomy" was not displayed and did not include commerce from "Trade Routes", "Specialists", "Corporations" or "Religions".

This meant that "iProduction" would rapidly outpace "iEconomy" and trigger a "Great Depression" as soon as you switched over to a "Free Market" economy. As it turns out from many players, their solution to the problem was to never play a "Free Market" economy in RFC.

In my modifications, I am calculating "iEconomy" as follows:

iCityEconomy = CityPlotCommerce + CityTradeRouteCommerce + CitySpecialistCommerce + CityBuildingCommerce - CityMaintenance

iEconomy = Summation of all iCityEconomies - some kind of Inflation Calculation.

And then, per RFC's current "Great Depression" algorithm, a more reasonable comparision between "iEconomy" and "iProduction" should result in a more manageable "Great Depression" occurrence.

(anyways, that is the theory on paper.... )
Attached Thumbnails
Click image for larger version

Name:	Civ4ScreenShot0001.JPG
Views:	198
Size:	342.3 KB
ID:	236202   Click image for larger version

Name:	Civ4ScreenShot0000.JPG
Views:	152
Size:	332.2 KB
ID:	236203  

Last edited by DorianGray; Dec 04, 2009 at 03:24 AM. Reason: typo
DorianGray is offline   Reply With Quote
Old Dec 04, 2009, 03:32 AM   #12
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Modifications to PyHelpers.py to support new commerce calculations.

Spoiler:

###################################
# DorianGray - begin
###################################

def isValid(self):
return (self.city.isNone() == False)

def isWorkingPlotByIndex(self, iIndex):
return self.city.isWorkingPlotByIndex(iIndex)

def getCityIndexPlot(self, iIndex):
return self.city.getCityIndexPlot(iIndex)

def getWorkingPlotList(self):
lPlots = []
numCityPlots = gc.getNUM_CITY_PLOTS()
for iIndex in range(numCityPlots):
if (self.isWorkPlotByIndex(iIndex)):
pLoopPlot = self.city.getCityIndexPlot(iIndex)
if (not pLoopPlot.isNone()):
lPlots.append(pLoopPlot)
return lPlots

def getWorkingPlotsYield(self, eYield):
iYield = 0
numCityPlots = gc.getNUM_CITY_PLOTS()
for iIndex in range(numCityPlots):
if (self.isWorkingPlotByIndex(iIndex)):
pLoopPlot = self.city.getCityIndexPlot(iIndex)
if (not pLoopPlot.isNone()):
iYield += pLoopPlot.getYield(eYield)
return iYield

def getSpecialistsCommerce(self, eCommerce):
iSpecialistCommerce = self.city.getSpecialistCommerce(eCommerce)
iExtraCommerce = (self.city.getSpecialistPopulation() + self.city.getNumGreatPeople()) * self.player.getSpecialistExtraCommerce(eCommerce)
iReturn = iSpecialistCommerce + iExtraCommerce
return iReturn

def getBuildingsCommerce(self, eCommerce):
iReturn = 0
iReturn += self.city.getReligionCommerce(eCommerce)
iReturn += self.city.getCorporationCommerce(eCommerce)
iReturn += self.city.getBuildingCommerce(eCommerce)
return iReturn

###################################
# DorianGray - end
###################################
Attached Files
File Type: zip PyHelpers.zip (12.4 KB, 34 views)
DorianGray is offline   Reply With Quote
Old Dec 04, 2009, 10:37 AM   #13
deanej
Deity
 
deanej's Avatar
 
Join Date: Apr 2006
Location: New York State
Posts: 4,859
You want to use code tags for including the code so that indentation is preserved. Also, you might want to consider using a different name for the display on the city screen so that it doesn't look like debug text.
deanej is offline   Reply With Quote
Old Dec 04, 2009, 11:34 AM   #14
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Deanej,

Points noted. I did find it fustrating how everything got reformated. I didn't see the [CODE] button to denote source code snipet. But I may have overlooked it.

The "iEconomy" text on the city status screen was more of an interim implementation until a proper moniker could be kicked around that seems to be indicative of the datum.
DorianGray is offline   Reply With Quote
Old Dec 04, 2009, 11:39 AM   #15
deanej
Deity
 
deanej's Avatar
 
Join Date: Apr 2006
Location: New York State
Posts: 4,859
It's in the advanced editor - I think it looks like a # sign.

For the text name, "Economy" or something similar might work.

Is there also a way to get total production so that it can easily be seen how likely a great depression is? Perhaps a Production display below it, with the economy one being total amount traded.
deanej is offline   Reply With Quote
Old Dec 04, 2009, 11:42 AM   #16
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Also, the "iEconomy" data that is being displayed on the individual city status screens is really "iCityEconomy" data previously mentioned specific to only that city.

I did not really mean for the "iEconomy" label to stick around and so just left it until later. But it may be a bit confusing in context of my previous post.
DorianGray is offline   Reply With Quote
Old Dec 04, 2009, 11:47 AM   #17
deanej
Deity
 
deanej's Avatar
 
Join Date: Apr 2006
Location: New York State
Posts: 4,859
Oh. In that case maybe something could be added to the Interior Advisor.
deanej is offline   Reply With Quote
Old Dec 04, 2009, 11:56 AM   #18
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Deanj,

The total production is already currently displayed in the graphs & demographics screens.

http://www.civfanatics.com/civ4/stra...mographics.php

Quote:
Mfg. Goods- The Manufactured Goods is the total of the production you produce on each turn. The raw production is the total hammers you get from each worked tile and specialists.
However, as of BTS 3.17, the GNP being displayed is completely unrelated solely to commerce and irrelevant to the "Great Depression" calculations.

I am working on adding to the demographics screen a value representative of "iEconomy" that could be used to make a meaningful comparison against the current "Mfg Goods" that are displayed now. (this would be a summization of all the "iCityEconomy" values for your civilization)
DorianGray is offline   Reply With Quote
Old Dec 05, 2009, 03:00 AM   #19
Soda
Chieftain
 
Join Date: Aug 2007
Posts: 59
To be fair to the wiki, it was probably written when the GNP (Gold) in the Demographics screen did actually show raw commerce - costs. While that isn't a meaningful value, it's at least less volatile than more "realistic" measures of economy, so I think using that in stability calculations is ok.

The disconnect is that, while the basic stability and great depression framework hasn't changed that much, BTS made two changes (for Civ 4 overall, not just RFC) - the revised GNP (Gold) calculations and corporations. Corporations really throw the great depression calculation out of whack: while the net effect to your cash flow may not be large in either direction (assuming you control the corporation headquarters), there's actually a large increase in maintenance costs (which makes great depression more likely) combined with a large increase in income at the corporation headquarters (which has NO EFFECT on stability calculations).

So if anything needs to be fixed, it's probably that corporation income should be factored into the great depression calculation somehow (or maybe not - I suppose it could be argued that having corporations should make great depression more likely).
Soda is offline   Reply With Quote
Old Dec 05, 2009, 09:29 AM   #20
DorianGray
Chieftain
 
Join Date: Apr 2008
Posts: 21
Soda,

The current mechanism further considers "Engineers" in the production calculations, but ignore "Merchants" in the economy calculations. That is another problem that is being looked at.

IMO, corporations SHOULD be factored into the "Great Depression" calculations (and will be in my modifications). They will be factored in both their "positive" effects and "negative" effects.

The "positive" effects, as Soda noted, come from the corporation headquarters. The "negative" effects are subtly factored into the "city maintenance" calculations and will be directly subtracted from the individual "CityEconomy" values.

The point of this is to allow properly run corporations to be a positive influence on avoiding "Great Depressions", but improperly run corporations to actually increase the likelyhood.
DorianGray is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Project & Mod Development > Civ4 - Rhye's and Fall of Civilization > RFC's Great Depression Debacle

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
On Great Depression Barak Civ4 - Rhye's and Fall of Civilization 46 Jul 13, 2008 04:23 AM
Great Depression? Gen.Rommel Civ4 - Rhye's and Fall of Civilization 2 Jan 31, 2007 06:37 PM
The Great Depression Barak Civ4 - Rhye's and Fall of Civilization 2 Jan 12, 2007 01:00 PM
Help on the Great Depression Dreadnought World History 3 Jul 31, 2005 10:14 AM


Advertisement

All times are GMT -6. The time now is 04:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR