List Info

Thread: (PR#20606) patch to reduce corruption losses under Despotism




(PR#20606) patch to reduce corruption losses under Despotism
user name
2006-09-09 02:42:53
<URL: 
http://bugs.freeciv.org/Ticket/Display.html?id=20606
>

   I'd like to propose a solution to a longstanding problem
with 

Freeciv, but I need some help to implement it.  The problem
is the 

punishing effect of corruption in the early stages of the
game. 

 

   Essentially Freeciv offers only one solution to the
effects of 

corruption - change to another form of government.  But what
if 

you could reduce corruption before you were able to switch
to 

another form of government? 

 

   Here's my idea:  reduce the corruption losses in each
city by a 

percent equal to the percent of happy citizens in that city.
 Here's 

an example with some made up numbers: 

 

.You have a size 1 city that is located 6 tiles away from
the 

capital. 

 

.That city's center is on a spice tile. 

 

.Its only citizen is working a wine tile. 

 

.The government is still Despotism. 

 

   The base output of that city is 1-1-6 (1 food (3-2), 1
shield, 

and 6 trade).  But after the effects of corruption are
computed, the 

output drops to 1-1-3. 

 

   Now change the tax rate to 40% Science / 60% Luxury.  Now
that 

city is producing 2 luxuries from its 3 trade points.  2
luxuries 

change that city's only citizen from content to happy. 

 

   1 happy citizen in (a city of) 1 is a 100% happy
percentage.  So 

the corruption effects in that city are reduced by 100% (to
0).  Now 

the city produces 6 trade points instead of 3. 

 

   Now you can change the tax rate to 60% Science / 30%
Luxury / 

10% Gold.  That will be enough to keep that city happy and
to allow 

you to reap a decent amount of science and gold from that
city (even 

though its still governed under Despotism).  No more need to
hurry 

up to research a new form of government. 

 

   Size 2 cities could reduce their corruption penalties by
50% 

if one citizen is happy or 100% if both citizens are happy. 
Size 

3 cities could get 33%, 66%, or 100% reduction.  Larger
cities would 

work similarly.  As with celebration, all other citizens
have to be 

content (or specialists). 

 

   The research flexibility this change offers is key.  It
makes 

numerous alternative research strategies viable.  Without
it, there 

is effectively only one strategy - research a new form of
government 

as quickly as possible.  Researching anything else only
extends the 

duration of the effects of corruption (which overwhelm any
benefits 

that other strategies might provide). 

 

 

   This simple mod that I've made implements the basic
function 

that I've described; but it has some problems.  I believe
those 

problems result from where the mod is in the calculation
sequence. 

 

   I've tried to figure out where to place the mod so that
it works 

reasonably and doesn't cause undesirable side effects.  But
I'm not 

getting anywhere with that.  This is where I need the help
of the 

big brains on this list. 

 

 

   I put my mod in city_waste.  One of the symptoms of that 

placement is that the first tax rate change (setting
luxuries to 

60%) doesn't take effect until the following turn.  By the
next 

turn the happiness due to luxuries is apparently recalc'd. 
Only 

then does the corruption reduction take effect. 

 

   However, even on the following turn, you can't switch
that size 

1 city's citizen to work a different tile.  That's
because, as soon 

as you remove the citizen from the tile that he's on, he
becomes an 

entertainer. 

 

   The entertainer is *not* happy (because he's a
specialist) and 

so the corruption effects instantly return.  Placing the
citizen on 

a new tile doesn't necessarily produce enough luxuries
(from the 

corruption depleted trade output) to make the citizen happy
again. 

 

   That means that you have to bump the luxury rate back to
60% and 

wait for the next turn again.  Clearly this effect is
annoying. 

 

   I assume that if the mod were placed somewhere else
(perhaps 

followed by a recalc of the effect of luxuries), then these
problems 

could be fixed.  But I don't know where the mod can safely
be 

inserted into the existing code.  Set_city_production seems
to be 

delicately balanced to make the existing functions work the
way 

that they are supposed to. 

 

   Can anyone suggest a more effective placement for this
mod (or 

one like it)? 

 

   I also considered implementing this feature as an effect.


Unfortunately, I couldn't figure out how to do it.  One of
the 

pieces is already available:  EFT_OUTPUT_WASTE_PCT. 

 

   Unfortunately, I couldn't figure out how to access the
city size 

and the number of happy citizens to code them into
effects.ruleset 

reqs.  Is there a way to do that?  (Also I would also need
to be 

able to access the numbers of unhappy and angry citizens -
for 

nreqs.) 

 

   Even if I could use effects to implement this, it would
probably 

only be practical to add effects rules for city sizes up to
3.  That 

would require only 6 rules.  Each additional city size would
require 

N additional effects rules (for Nth city).  Besides, by the
time 

cities grow to size 4, many players may have already
completed the 

research they need to change their form of government. 

 


   Regardless, here is the patch.  Any advice or suggestions
on making
it work better will be appreciated. 

 -Eddie 


Index: common/city.c
============================================================
=======
--- common/city.c	(revision 12298)
+++ common/city.c	(working copy)
 -2177,7
+2196,7 
 ***********************************************************
***************/
 int city_waste(const struct city *pcity, Output_type_id
otype, int total)
 {
-  int penalty = 0;
+  int city_size, happy_count, penalty = 0;
   int waste_level = get_city_output_bonus(pcity,
get_output_type(otype),
                                          
EFT_OUTPUT_WASTE);
   int waste_by_dist = get_city_output_bonus(pcity,
get_output_type(otype),
 -2221,6
+2240,18 
 
   penalty -= penalty * waste_pct / 100;
 
+  /* reduce waste based on pct happy citizens in city (also
must
+   * have no unhappy citizens).  This is particularly
helpful in
+   * the early stages of the game (before new government
types
+   * have been researched). */
+
+   if (pcity->ppl_happy[4] > 0 &&
pcity->ppl_unhappy[4] == 0
+       && pcity->ppl_angry[4] == 0) {
+     city_size = pcity->size;
+     happy_count = pcity->ppl_happy[4];
+     penalty -= (penalty * happy_count) / city_size;
+   }
+
   return MIN(MAX(penalty, 0), total);
 }
 
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )