PDA

View Full Version : corruption calculation


Socrates
12-03-2004, 22:31
This is using C3C 1.15b.

I wanted to clarify things about how corruption works, so I read this post by Alexman on CFC (tell me if I'm wrong) :



Everything about Corruption: C3C edition
This is a guide about how corruption works in Conquests. It's slightly different than how it used to work in PTW and vanilla Civ3.

The information that follows was discovered by extensive testing and contributions by numerous members of the Civ3 community, including Aeson, DaviddesJ, Nor Me, and Qitai. We also recently got some inside information (a look at some of the actual corruption code), which helped find the last few missing pieces of the corruption puzzle.

DEFINITIONS

Corruption in Civilization 3 is commerce from city tiles that cannot be used by the empire. Corrupted commerce is indicated graphically in the city screen by stacks of red coins. There are numerous factors that influence corruption, all of which are addressed in this article.

Waste is the loss of production as opposed to commerce, and is governed by almost the same rules as corruption. Everything in this article that applies to corruption, also applies to waste, unless otherwise mentioned.

CORRUPTION BASICS

The total corruption in each city is equal to the sum of two independent components: distance corruption, and rank corruption.

For non-communal government types, distance corruption depends on the distance of each city from its closest palace. Rank corruption in a city depends on how many other cities are closer than that city to the palace.

For communal government types, distance corruption does not actually depend on distance. Each city is considered to be the same distance from the Palace. Rank corruption depends on the total number of cities in the empire.

You can reduce corruption in your cities by building appropriate city improvements and Wonders, changing to a more efficient government, choosing a Commercial civilization, and connecting your cities to the trade network of your empire. In addition, you can reduce waste by bringing your cities into a WLTKD celebration.

You can determine the total number of ‘red’ commerce in a city by multiplying its total corruption by the number of raw commerce produced by citizens working the land, rounded to the closest integer.


DISTANCE CORRUPTION

For all non-communal government types, the distance corruption component is proportional to the distance of a given city from its closest Palace. For communal governments, the distance to the closest Palace is considered to be the same for all cities on a given map. The “closest palace” to a city can be the Palace, the Forbidden Palace, or any other Wonder with the “reduces corruption” ability.

For corruption purposes, distance is always an integer number, and is given by:


code:--------------------------------------------------------------------------------
d = max(x,y) + min(x,y)/2
where
max(x,y) denotes the maximum between x and y,
min(x,y) denotes the minimum between x and y,
x is the distance in the NW/SE direction,
y is the distance in the NE/SW direction,
and the integer division is rounded down.
--------------------------------------------------------------------------------


In the special case of communal governments, the distance for all cities is taken as:

code:--------------------------------------------------------------------------------
d = (MaxD) / 4
--------------------------------------------------------------------------------

where MaxD = (MapW+MapH)/4, MapW is the width of the map, and MapH is the height of the map, as given in the editor.

The distance, d, is used to get the adjusted distance, da, as follows:

code:--------------------------------------------------------------------------------
da = 0.5^Ni * min(Gd * t * d, MaxD)
where
Ni is the number of anti-corruption buildings,
t = 1 if the city is on the trade network
5/4 otherwise
Gd = 3/2 for Rampant corruption (Despotism)
3/4 for Minimal corruption (Democracy)
1 otherwise
--------------------------------------------------------------------------------

So each anti-corruption building, which is a city improvement with the “reduces corruption” ability in the editor (Courthouse and Police Station), divides distance corruption by 2.

Finally, the exact value of the distance corruption component is given by:

code:--------------------------------------------------------------------------------
Cd = da /MaxD
--------------------------------------------------------------------------------


RANK CORRUPTION

The rank corruption component depends on the rank (R) and optimal city number (Nopt) of each city.

In a non-communal type of government all cities of an empire are ranked in order of distance to the capital, starting at zero for the capital itself. If several cities have the same distance to the capital, they are ranked in order of founding, and if they also have the same date of founding, they are ranked by their order in the database. In a communal form of government, all cities have the same rank, which is half the total number of cities in the empire, rounded down.

Each city also has its own optimal city number, Nopt, given by:

code:--------------------------------------------------------------------------------
Nopt = max(OCN * (L/100 + c + Gr + Gp*Nwe + 0.25*Ni), 1)
where
OCN is the optimal number of cities for the map size,
as found in the editor
L is the percentage of optimal cities for the current
difficulty level, as given in the editor
Nwe is the number of active Wonders in the empire with
the “reduces corruption” ability
(Forbidden Palace, SPHQ)
c = 0.25 for a commercial civilization,
0 otherwise
Gr = 0.1 for minimal or nuisance corruption
2 for communal corruption
0 otherwise
Gp = 3/8 non-communal corruption
3 for communal corruption
--------------------------------------------------------------------------------

For waste calculations only, when the city is in a WLTKD celebration, add OCN/4 to Nopt.

The rank corruption for a city is then given by:

code:--------------------------------------------------------------------------------
Cr = R / (2 * Nopt), if R < Nopt
(2 * R – Nopt) / (2 * Nopt) otherwise
--------------------------------------------------------------------------------


MAXIMUM CORRUPTION

The sum of the distance and rank components of corruption can be greater than 100%. The game sets an upper limit for the total corruption in a city to be equal to 90% minus 10% for each city improvement and minus 70% for each Wonder in the city with the “reduces corruption” ability:

code:--------------------------------------------------------------------------------
Cmax = 0.9 – (0.1 * Ni + 0.7 * Nwc)
--------------------------------------------------------------------------------


POLICEMAN SPECIALISTS

By assigning one of your citizens to be a policeman, you can cause one corrupted commerce and one wasted shield to become uncorrupted. This reduction in corruption comes before applying the maximum corruption limit described in the previous section, so the city may not show any reduction if was already taking advantage of that limit.

SUMMARY

To summarize the above, distance corruption depends on the distance of the city from the closest palace (or a constant number for communal governments), multiplied by a factor that depends on the government type, and another factor if the city is not connected to your capital by road, harbor, or airport. Each corruption-reducing building in the city halves distance corruption.

Rank corruption depends on the ratio of the city rank to the adjusted optimal city number. The city rank is equal to the number of cities closer to the capital (or half the total number of cities for Communism). The rate of increase of this corruption with rank doubles after rank exceeds the optimal city number. The optimal city number of the map gets modified by the difficulty level, the commercial trait, the current government, and the number of improvements and Wonders with the “reduces corruption” ability.

Courthouses and Police Stations decrease distance corruption and increase the optimal number of cities. They also each decrease the maximum corruption limit.

The Forbidden Palace acts as a second Palace for distance corruption calculations, but not for rank calculations. The Forbidden Palace itself will have low corruption, but if there are many cities closer to the Palace than the Forbidden Palace, the cities around the Forbidden Palace will have high rank corruption. However, even though it doesn’t provide a new set of city ranks, the Forbidden Palace reduces rank corruption throughout the empire by increasing the optimal number of cities.



Now I want to know 2 things :

1. Where can we see that, past the actual OCN, corruption rises more quickly in newly founded cities ?

2. It seems in my games that, at least below the actual OCN, when I found new cities, older cities see their corruption increased, but I can't see that in those formulas...? Is there a limit in this increasing corruption by other cities ?

hint : Looking at it closely, it looks like both questions deal with the part where the rank corruption formula is decided by the final calculation of Cr (where you have to see if R<Nopt or not), but I'm not sure. And it seems the increase I have seen happens just once actually, which may be right with that hint. It would happen in far cities when you found cities closer to the capital than them... Maybe. Anyone ? [???]

Also : "For waste calculations only, when the city is in a WLTKD celebration, add OCN/4 to Nopt." : add OCN/4 to the max brackets (corruption decrease in any case) or to a number inside the brackets ?

Thanks if you REALLY know the answers ! [goodjob]

EDIT : Also, it could be helpful in some cases to have a calculation utility for that... unless it already exists ? It could be used for special cases, like founding a new city when another one is building a wonder... Come on, show us your skills !!! [cool]

anarres
12-03-2004, 22:39
1: Finding the exact value of the rank corrutpion is difficult because of distance corruption added in. You can see it though, if you check the difference in corruption between cities just before the OCN/2 boundary and the cities just after it. This isn't trivial to prove, but it is true...

2: When you found a new city, ALL cities farther away from the captial will increase in corruption. This is because you increase the rank of all of those cities by 1, so their rank corruption increases. This is east to test: take a game with at least a few cities and found a new city as close to the captial as possible and watch you corruption get worse all your other cities. Your overall income will drop significantly.

For the waste calculation you add it inside the brackets, but to the first term only...

Socrates
12-03-2004, 23:02
Hehe, thanks a lot for answering sooo fast ! [coool]

I understand the points you gave. I think that, fur further testing without wallbashing, a nice utility would be nice !! Then I would use it from time to time to decide on a few stuff... Anyway, founding or capturing far junk cities don't affect the core at all, so ? I'm always scared of that, but of course I've already conquered the world, so... but that was in PTW... and against the AI. :D

One thing I got now is that a FP in a 2nd-ring city should be built AFTER a courthouse (preferably rushed of course).

Socrates
16-03-2004, 12:57
Well, just this question : would anyone have the time and the skills to create a utility calculating corruption (and waste) in cities ? I think the formulas are stable by now, but even if they change them a little, we could just have to change them in the utility. So ? I could provide testing if needed. :D

anarres
16-03-2004, 13:42
alexman made on for Civ3/PTW - you could ask him to either update it for C3C or to give you the source code to update yourself. Check the corruption article for Civ3 by him at CFC...

Samson
04-05-2004, 13:34
Hi,

One little question, the only difference you mention between corruption and waste is the WLTKD. However, the other day I had a city I was trying to make a workier factory, so needed 5 sheilds pt. I could get 5 uncorrupted commerce with 7 per corruption, but only 4 sheild with 7 per waste. Any ideas? The city was not in WLTKD (size 6 only) and no policemen.

I am fairly sure this is right, but I cannot check now.

Socrates
04-05-2004, 13:50
Mmmmh not sure. Do you mean (for commerce) : 5 commerce in your pocket and 7 in corruption, or you got 5 commerce out of 7 total (2 in corruption) ? If the latter, then there must be something we don't know, and you could post a pic of the city, with buildings... If the first, then it's possible : the percentage would lead to 4 uncorrupted units out of 11, and 5 uncorrupted units out of 12.

Yes, a good pic is needed.

Samson
04-05-2004, 13:56
Quote -
Mmmmh not sure. Do you mean (for commerce) : 5 commerce in your pocket and 7 in corruption, or you got 5 commerce out of 7 total (2 in corruption) ? If the latter, then there must be something we don't know, and you could post a pic of the city, with buildings.

I do mean the latter, 5 commerce out of 7 total (2 in corruption). I really hope I have not made a mistake, but I spent a while looking at it to try and work out what is going on and could not. I shall post a pic when I get home tonight (about 4 hours).

Samson
04-05-2004, 18:20
I am afraid I cannot find a save that shows this (from getting the worker factory going until my revolution. I could well have made a mistake though, counting the happyness from an entertainer or something. Sorry.

It is great to see this analisis going on.