69 m_activity_level *= growth; |
69 m_activity_level *= growth; |
70 DEBUG(eco, 4, "Set global EAL to %.3f", (double)m_activity_level); |
70 DEBUG(eco, 4, "Set global EAL to %.3f", (double)m_activity_level); |
71 } |
71 } |
72 |
72 |
73 /** |
73 /** |
|
74 * Adds random events to the economic growth. This should call a random event every |
|
75 * 20 months. Well at least it should if RandomRange would be distributed in a |
|
76 * linear fashion. Note that there's one event in RandomEvents with a value of |
|
77 * -100 that doesn't have a positive "partner". This one simulates a big crash |
|
78 * or any other catastrohic event (war, disease, terrorism, whatever). |
|
79 * @todo Add news events for higher modifications in the economy (=> 2%) |
|
80 */ |
|
81 void MonthlyLoop() |
|
82 { |
|
83 /* Modifications of the global economic activity one-tenth of a percent */ |
|
84 static const int RandomEvents[] = {-1, 1, -2, 2, -5, 5, -10, 10, -12, 12, -15, 15, -20, 20, -25, 25, 32, -32, 50, -50, -100}; |
|
85 /* I didn't use the 19, because it hardly ever is the return of RandomRange for whatever reason */ |
|
86 if (RandomRange(20) != 18) return; |
|
87 |
|
88 FixedT<int32, 16> mod( RandomEvents[RandomRange(lengthof(RandomEvents))], 1000); |
|
89 mod += 1; |
|
90 |
|
91 m_activity_level *= mod; |
|
92 DEBUG(eco, 5, "Added a random event with a value of %f, adjusted EAL to %f", (double)mod, (double)m_activity_level); |
|
93 } |
|
94 |
|
95 /** |
74 * Computes the modification of economic growth by cyclic events |
96 * Computes the modification of economic growth by cyclic events |
75 * @return The growth modification |
97 * @return The growth modification |
76 */ |
98 */ |
77 FixedT<int32, 16> GetCyclicGrowth() const |
99 FixedT<int32, 16> GetCyclicGrowth() const |
78 { |
100 { |