Bell-Production and Rebel-Sentiment

historix69

Emperor
Joined
Sep 30, 2008
Messages
1,412
(Moved from general Col-Forum to Strategy&Tipps)

1. City-Bell-Production and City-Rebel-Sentiment
--------------------------------------------------

Each City has its own value of Rebel-Sentiment which can be raised to a certain level by producing bells in the city. The code for calculating the Rebel-Sentiment can be found in source-file "...\CvCity.cpp", method (function) CvCity::doRebelSentiment().

Spoiler :

from "...\CvCity.cpp"

void CvCity::doRebelSentiment()
{
int iTurnFactor = std::max(1, GC.getDefineINT("REBEL_SENTIMENT_TURN_WEIGHT") * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getGrowthPercent() / 100);

int iPast = (iTurnFactor - 1) * getRebelSentiment();
int iNew = 0;

if (!GET_PLAYER(getOwnerINLINE()).isEurope())
{
iNew = calculateNetYield(YIELD_BELLS) * GC.getDefineINT("REBEL_SENTIMENT_BELLS_FACTOR");
}

if (!isHuman())
{
iNew *= 100 + GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIRebelModifier();
iNew /= 100;
}

setRebelSentiment((iNew + iPast) / iTurnFactor);
}

int CvCity::getRebelPercent() const
{
return std::max(0, std::min(100, getRebelSentiment() / std::max(1, getPopulation())));
}

int CvCity::getRebelSentiment() const
{
return m_iRebelSentiment;
}

...

void CvCity::setRebelSentiment(int iValue)
{
m_iRebelSentiment = iValue;
FAssert(getRebelSentiment() >= 0);
}



At the beginning of each turn, the game calculates the new Rebel-Sentiment for each city which is not owned by european homeland. The City's new Rebel-Sentiment is based on the bell-production in the city, the City's already accumulated Rebel-Sentiment and the decay of the City's already accumulated Rebel-Sentiment.

See Code for details
Spoiler :


1. iTurnFactor : a Production-Modifier based on GameSpeed

int iTurnFactor = std::max(1, GC.getDefineINT("REBEL_SENTIMENT_TURN_WEIGHT") * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getGrowthPercent() / 100);

-> REBEL_SENTIMENT_TURN_WEIGHT is defined in "GlobalDefines.xml" and has the value 10

<Define>
<DefineName>REBEL_SENTIMENT_TURN_WEIGHT</DefineName>
<iDefineIntVal>10</iDefineIntVal>
</Define>


-> iGrowthPercent is based on GameSpeed (see "CIV4GameSpeedInfo.xml") and has the values 100 (normal) and 300 (marathon)

so
iTurnFactor = max(1, 10 * iGrowthPercent / 100);


-> iTurnFactor = 10 (normal)
-> iTurnFactor = 30 (marathon)

2. iPast : Old Level of Rebel-Sentiment with decay, multiplied with Production-Modifier

int iPast = (iTurnFactor - 1) * getRebelSentiment();


3. iNew : Bell-Production converted to Rebel-Sentiment multiplied with Production-Modifier

iNew = calculateNetYield(YIELD_BELLS) * GC.getDefineINT("REBEL_SENTIMENT_BELLS_FACTOR");

-> REBEL_SENTIMENT_BELLS_FACTOR is defined in "GlobalDefines.xml" and has the value 25

<Define>
<DefineName>REBEL_SENTIMENT_BELLS_FACTOR</DefineName>
<iDefineIntVal>25</iDefineIntVal>
</Define>

so iNew = ProducedBells * 25;


4. New Rebel-Sentiment :

setRebelSentiment((iNew + iPast) / iTurnFactor);

For reasons of economic computing and minimizing rounding errors, the division in the code is done at the last step ...


5. To produce some more intuitive mathematic formula, you can transform the code ...


RebelSentiment_new =

= (iNew + iPast) / iTurnFactor)

= (iNew / iTurnFactor) + (iPast / iTurnFactor)

= (ProducedBells * 25 / iTurnFactor) + ((iTurnFactor - 1) * RebelSentiment / iTurnFactor)

= (ProducedBells * 25 / iTurnFactor) + RebelSentiment - (1 / iTurnFactor) * RebelSentiment

= (ProducedBells * 25 / ProductionModifier) + RebelSentiment - (1 / ProductionModifier) * RebelSentiment


=> RebelSentiment_new = RebelSentiment_by_Bell_Production + RebelSentiment_old - RebelSentiment_Decay

with

RebelSentiment_by_Bell_Production = ProducedBells * 25 / ProductionModifier
RebelSentiment_old
RebelSentiment_Decay = (1 / ProductionModifier) * RebelSentiment_old
ProductionModifier = 10 (normal), 30 (marathon) (= iTurnFactor)

(Note : Due to rounding, the results of the formula may slightly vary from the results of the original game-code due to changing the order of mathematical operations as addition, division, etc...)


RebelSentiment_new = RebelSentiment_old - RebelSentiment_Decay + RebelSentiment_by_Bell_Production​

with

RebelSentiment_by_Bell_Production = ProducedBells * 25 / ProductionModifier
RebelSentiment_old
RebelSentiment_Decay = (1 / ProductionModifier) * RebelSentiment_old
ProductionModifier = 10 (normal), 30 (marathon)​


GameSpeed = normal (ProductionModifier = 10) :
------------------------------------------------

On GameSpeed = normal, a City gets 2.5 Points of RebelSentiment for each Bell it produces.

RebelSentiment_by_Bell_Production = ProducedBells * 25 / 10 = 2.5 * ProducedBells​

So it must produce 40 Bells to get 100 Points of RebelSentiment (without deacay!).

Decay-rate on normal is (1 / ProductionModifier) = 1 / 10 = 0.1 = 10%, so every turn the City looses 10% of the already accumulated RebelSentiment Points.
Spoiler :


Decay of 100 Points RebelSentiment on normal :

00 100
01 90
02 81
03 72
04 64
05 57
06 51
07 45
08 40
09 36
10 32
11 28
12 25
13 22
14 19
15 17
16 15
17 13
18 11
19 9
20 8
21 7
22 6
23 5
24 4
25 3
26 2
27 1
28 0





GameSpeed = marathon (ProductionModifier = 30) :
------------------------------------------------

On GameSpeed = marathon, The City gets only a third of the RebelSentiment Points for each Bell compared with normal.

RebelSentiment_by_Bell_Production = ProducedBells * 25 / 30 = 2.5 * ProducedBells / 3​

So it must produce 120 Bells to get 100 Points of RebelSentiment (without deacay! and without losses through to rounding errors!).

Decay-rate on marathon is (1 / ProductionModifier) = 1 / 30 = 0.033 = 3.33%, so every turn the City looses 3.33% of the already accumulated RebelSentiment Points.
Spoiler :


Decay of 100 Points RebelSentiment on marathon :

00 100
01 96
02 92
03 88
04 85
05 82
06 79
07 76
08 73
09 70
10 67
11 64
12 61
13 58
14 56
15 54
16 52
17 50
18 48
19 46
20 44
21 42
22 40
23 38
24 36
25 34
26 32
27 30
28 29
29 28
30 27
31 26
32 25
33 24
34 23
35 22
36 21
37 20
38 19
39 18
40 17
41 16
42 15
43 14
44 13
45 12
46 11
47 10
48 9
49 8
50 7
51 6
52 5
53 4
54 3
55 2
56 1
57 0




RebelSentiment in Percent for a City
--------------------------------------

Rebel Sentiment Points are equivalent to the Rebel Sentiment of a Size 1 - City in Percent. A Size 1 - City with 100 or more Rebel Sentiment Points has 100% Rebel Sentiment.

To compute the RebelSentiment in Percent for a City with arbitrary size, just divide the City's accumulated RebelSentiment Points by the Population. If the number is greater equal 100, then it is regarded as 100 % Rebel Sentiment.

RebelSentiment in Percent = Minimum( 100; RebelSentiment Points / City-Size)​

100 RebelSentiment Points in Size-1-City -> 100 %
100 RebelSentiment Points in Size-2-City -> 50 %
100 RebelSentiment Points in Size-3-City -> 33 %
100 RebelSentiment Points in Size-4-City -> 25 %
100 RebelSentiment Points in Size-10-City -> 10 %

800 RebelSentiment Points in Size-8-City -> 100 %
1.000 RebelSentiment Points in Size-8-City -> 100 %

Spoiler :

from "...\CvCity.cpp"

int CvCity::getRebelPercent() const
{
return std::max(0, std::min(100, getRebelSentiment() / std::max(1, getPopulation())));
}




Theoretical Limit of RebelSentiment Points due to Decay
----------------------------------------------------------

As can be seen from the formula,

RebelSentiment_new = RebelSentiment_old - RebelSentiment_Decay + RebelSentiment_by_Bell_Production​

the accumulation of RebelSentiment Points will stop when the new points from Bell-Production and the Decay will reach a balance at

RebelSentiment_Decay = RebelSentiment_by_Bell_Production​

or
Spoiler :

RebelSentiment_Decay = RebelSentiment_by_Bell_Production

(1 / ProductionModifier) * RebelSentiment_Max = ProducedBells * 25 / ProductionModifier

RebelSentiment_Max = ProducedBells * 25

(Allthough this value is independent from ProductionModifier, ProductionModifier will influence roundings during computation of the RebelSentiment in the game and so the higher ProductionModifier will lead

to slightly smaller RebelSentiment_Max-Values.)


RebelSentiment_Max = ProducedBells * 25​


Example : 100%-City
---------------------

A City with 3 Elder Statesmen (3 x 6 = 18 bells) with PRINTING_PRESS + NEWSPAPER (+ 100% Bell-Production) + 100% Rebel-Sentiment (+ 50% Bell-Production) without any Bell-Production-related FoundingFathers has a Bell-Production of 18 + 18 + 9 = 45 Bells.

RebelSentiment_Max = 45 * 25 = 1.125 RebelSentiment Points​

So without any Bell-Production-related FoundingFathers, the Population of a 100%-RebelSentiment-City is limited to 10 - 11 colonists (including the 3 Elder Statesmen who will have to produce Bells forever to keep the 100%-RebelSentiment).
(Due to Rounding issues the City will probably not reach this theoretical value but a slightly smaller value, so better calculate with Size 10.)

Example : 50%-City
---------------------

A City with 3 Elder Statesmen (3 x 6 = 18 bells) with PRINTING_PRESS + NEWSPAPER (+ 100% Bell-Production) + 50% Rebel-Sentiment (+ 25% Bell-Production) without any Bell-Production-related FoundingFathers has a Bell-Production of 18 + 18 + 4 = 40 Bells.

RebelSentiment_Max = 40 * 25 = 1.000 RebelSentiment Points​

So without any Bell-Production-related FoundingFathers, the Population of a 50%-RebelSentiment-City is limited to 19 - 20 colonists (including the 3 Elder Statesmen who will have to produce Bells forever to keep the 50%-RebelSentiment).

Spoiler :


Simulation of Size-3-City with 3 Elder Statesmen on marathon.

Turn
RS = accumulated RebelSentiment Points
RSP = RebelSentiment Percent in City -> Production-Bonus
BP = Bell-Production
RSP-Pop = Max Population for 100% RebelSentiment (to keep Production-Bonus)

Turn 1 : 36 Bells * 2.5 / 3 = 30 RebelSentiment Points = 10 % RebelSentiment in Size-3-City

Turn RS RSP BP RSP-Pop
000 0 0 36 0
001 30 10 36 0
002 59 19 37 0
003 87 29 38 0
004 115 38 39 1
005 143 47 40 1
006 171 57 41 1
007 199 66 41 1
008 226 75 42 2
009 253 84 43 2
010 280 93 44 2
011 307 100 45 3
012 334 100 45 3
013 360 100 45 3
014 385 100 45 3
015 409 100 45 4
016 432 100 45 4
017 455 100 45 4
018 477 100 45 4
019 498 100 45 4
020 518 100 45 5
021 538 100 45 5
022 557 100 45 5
023 575 100 45 5
024 593 100 45 5
025 610 100 45 6
026 627 100 45 6
027 643 100 45 6
028 659 100 45 6
029 674 100 45 6
030 689 100 45 6
031 703 100 45 7
032 717 100 45 7
033 730 100 45 7
034 743 100 45 7
035 755 100 45 7
036 767 100 45 7
037 778 100 45 7
038 789 100 45 7
039 800 100 45 8
040 810 100 45 8
041 820 100 45 8
042 830 100 45 8
043 839 100 45 8
044 848 100 45 8
045 857 100 45 8
046 865 100 45 8
047 873 100 45 8
048 881 100 45 8
049 889 100 45 8
050 896 100 45 8
051 903 100 45 9
052 910 100 45 9
053 917 100 45 9
054 923 100 45 9
055 929 100 45 9
056 935 100 45 9
057 941 100 45 9
058 947 100 45 9
059 952 100 45 9
060 957 100 45 9
061 962 100 45 9
062 967 100 45 9
063 972 100 45 9
064 977 100 45 9
065 981 100 45 9
066 985 100 45 9
067 989 100 45 9
068 993 100 45 9
069 997 100 45 9
070 1001 100 45 10
071 1005 100 45 10
072 1009 100 45 10
073 1012 100 45 10
074 1015 100 45 10
075 1018 100 45 10
076 1021 100 45 10
077 1024 100 45 10
078 1027 100 45 10
079 1030 100 45 10
080 1033 100 45 10
081 1036 100 45 10
082 1038 100 45 10
083 1040 100 45 10
084 1042 100 45 10
085 1044 100 45 10
086 1046 100 45 10
087 1048 100 45 10
088 1050 100 45 10
089 1052 100 45 10
090 1054 100 45 10
091 1056 100 45 10
092 1058 100 45 10
093 1060 100 45 10
094 1062 100 45 10
095 1064 100 45 10
096 1066 100 45 10
097 1067 100 45 10
098 1068 100 45 10
099 1069 100 45 10
100 1070 100 45 10
101 1071 100 45 10
102 1072 100 45 10
103 1073 100 45 10
104 1074 100 45 10
105 1075 100 45 10
106 1076 100 45 10
107 1077 100 45 10
108 1078 100 45 10
109 1079 100 45 10
110 1080 100 45 10
111 1081 100 45 10
112 1082 100 45 10
113 1083 100 45 10
114 1084 100 45 10
115 1085 100 45 10
116 1086 100 45 10
117 1087 100 45 10
118 1088 100 45 10
119 1089 100 45 10
120 1090 100 45 10
121 1091 100 45 10
122 1092 100 45 10
123 1093 100 45 10
124 1094 100 45 10
125 1095 100 45 10
126 1096 100 45 10
127 1096 100 45 10





2. Global RebelSentiment
--------------------------

100%-RebelSentiment in a City is usefull due to Production-Bonus, but more important for Rebellion is reaching the 50%-Global-RebelSentiment. The Global RebelSentiment Points are calculated by summing up the local RebelSentiment Points of all Cities.

Global RebelSentiment Points = Sum( RebelSentiment Points(City) )​

The Global RebelSentiment - Percentage is calculated by dividing the Global RebelSentiment Points by the number of all colonists (including those in Europe on the dock).

Global RebelSentiment = Global RebelSentiment Points / Total Population​

Spoiler :


int CvTeam::getRebelPercent() const
{
PROFILE_FUNC();

int iRebelSentiment = 0;

for (int iPlayer = 0; iPlayer < MAX_PLAYERS; ++iPlayer)
{
CvPlayer& kPlayer = GET_PLAYER((PlayerTypes) iPlayer);
if (kPlayer.isAlive() && kPlayer.getTeam() == getID() && kPlayer.getParent() != NO_PLAYER && GET_PLAYER(kPlayer.getParent()).isAlive())
{
int iLoop;
for (CvCity* pCity = kPlayer.firstCity(&iLoop); pCity != NULL; pCity = kPlayer.nextCity(&iLoop))
{
iRebelSentiment += pCity->getRebelSentiment();
}
}
}

return std::max(0, std::min(100, (iRebelSentiment / std::max(1, getTotalPopulation()))));
}




Example 1:
---------------

Game-Speed = marathon
Small Empire with 5 Cities and a total Population of 100 colonists :
15 Elder Statesmen,
5 Expert Farmer,
80 Soldiers outside.​
Every 3 Elder Statesmen + 1 Farmer run a small City producing Bells (RebelSentiment Points). After a few turns the Cities have reached 100% RebelSentiment and produce 45 Bells each. After about 70 - 80 turns, every City should have reached about 1.000 RebelSentiment Points, summing up to a total 5 x 1.000 = 5.000 => 50% RebelSentiment for 100 colonists population.

(I tested this scenario with the Worldbuilder ... If I did not have forgotten colonists in Europe on the dock, I probably would have reached the 50% around Turn 70.)

Example 2:
----------------

Game-Speed = marathon
Small Empire with 10 Cities and a total Population of 100 colonists :
30 Elder Statesmen,
10 Expert Farmer,
60 Soldiers outside.​
Every 3 Elder Statesmen + 1 Farmer run a small City producing Bells (RebelSentiment Points). After a few turns the Cities have reached 100% RebelSentiment and produce 45 Bells each. After 20 turns, every City should have reached about 500 RebelSentiment Points, summing up to a total of 10 x 500 = 5.000 => 50% RebelSentiment for 100 colonists population.

The Bells not being wasted for Decay compared with the 1st example should be worth around 5 * 30 * 45 = 6.750 Bells.
Spoiler :

Example 1 :
5 Cities produce 70 turns = ca. 350 City-Production-cycles

Example 2 :
10 Cities produce 20 turns = ca. 200 City-Production-cycles

-> ca. 150 City-Production-cycles = 150 * 45 = 6.750 Bells saved.


RebelSentiment-Level, Bell-Production and REF-Size :
----------------------------------------------------

After asymptoticaly reaching the Maximum-Value of RebelSentiment Points in a City, all new Bells produced in the City will just serve to compensate the Decay of RebelSentiment (and generate politically FF-Points). The same applies in global context. Unfortunately, all these Bells produced in all the Cities also go into the calculation of REF-Size. So while the player must produce Bells to keep a constant level of RebelSentiment, the REF will grow unlimited (until the Game ends or Revolution starts.)
 
Very interesting post. So units have no rebel sentiment. Only cities do.

I heard that military units had bonuses related to the rebel sentiment. And I saw that some people put their veteran units into the cities some turns before the war of independance so that they acquire a rebel sentiment and get these bonuses.
From what you wrote, it appears this idea is pointless. Am I wrong ?
 
So units have no rebel sentiment. Only cities do.

correct

I heard that military units had bonuses related to the rebel sentiment.

The combat-bonus is based on your overall Rebel Sentiment which can be seen in the Revolutionary Screen where also REF is listed. In my current game, I have 72% Overall Rebel Sentiment Percentage and 100% in the City I'm attacking from. The unit gets a +22% bonus. So the bonus is calculated

Combat-Bonus = Overall Rebel Sentiment Percentage - 50%​

Choose the Spanish with Simon Bolivar to get the full bonus ...

And I saw that some people put their veteran units into the cities some turns before the war of independance so that they acquire a rebel sentiment and get these bonuses.

There is only rebel sentiment per City and overall ... based on accumulated LBs ... there is no rebel sentiment for individual colonists or units ...
Putting soldiers into a city will only give a bonus if the soldiers itself can produce additional LBs which will add to the Overall Rebel Sentiment. If you already have 3 Elder Statesmen or other colonists producing LBs in the city, you should not place the soldiers in the city because you may lower the production-bonus from the City's Rebel Sentiment.

From what you wrote, it appears this idea is pointless.

correct
 
Actually, that just partially true.
If you, for example, have city with close to 100% rebel sentiment, adding solider in is good thing, since then he could also be converted to rebel.
 
Actually, that just partially true.
If you, for example, have city with close to 100% rebel sentiment, adding solider in is good thing, since then he could also be converted to rebel.

1. There is no such thing as "rebel sentiment for individual colonists". Your soldiers are not divided into Rebels and Torys. All units get the same Overall Rebel Sentiment.
2. You can push your Overall Rebel Sentiment by adding soldiers to Cities when the soldiers are used to increase Bell-production in the city. However you should better hire Elder Statesmen for this job.
3. If you already have 3 people producing bells in your city, your suggestion to add soldiers to the city will have no effect or a negative effect : By adding the soldiers you will most likely lower Rebel Sentiment percentage in the city and so you will lower the production bonus and your city can contribute less Rebel Sentiment points to your Overall Rebel Sentiment. With lower Bell-production, the maximum of Rebel Sentiment Points the city can contribute is lowered. So in worst case your Overall Rebel Sentiment will actually decrease by a few points ...

Please re-read the 1st post if you have problems to understand Rebel Sentiment - mechanics.
 
Back
Top Bottom