Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2002:
[Freeciv-Dev] Re: Civ 2 style happiness (PR#1436)
Home

[Freeciv-Dev] Re: Civ 2 style happiness (PR#1436)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, Thanasis Kinias <tkinias@xxxxxxxxxxxxx>, "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Civ 2 style happiness (PR#1436)
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Sun, 12 May 2002 12:59:18 -0400

Quickie background:

From CivII Multiplayer Gold Edition manual pg 216-217, the order in 
which happiness effects are computed is.

1)  Natural happiness from ruleset/difficulty level. The number of
    initially content citizens (i.e. elvis bonus) is determined from
    the ruleset/difficulty level, normal citizens start off unhappy.
    The elvis bonus can be negative (i.e. creates angry citizens).
2)  Luxury effects, content -> happy then unhappy->content, ...
3)  Unhappiness reducing improvements (temples, ...)
4)  Martial law and field duty (unit effects)
5)  Wonders

So long as add_buildings_effect() only changes base trade related counts, 
Freeciv more or less follows these steps in generic_city_refresh().


I see you are removing just the default ruleset content people at the 
base of the compute cycle, i.e. the natural happiness. This is what
PayCiv does as well, so I'm happy with these changes and withdraw the
cautions now you have made clear this is all you want to change. 

But you should fix the bug in the code below before it goes in. And
look at the various worker_loop and AI emergency_reallocate code to 
see if you are more likely to trigger undesirable behaviour now.

Just to make clear that what you say you are doing and what you did
are different ...

It is still possible for unhappy/angry people to be specialists in your
code - to get a better approximation to what you said you were doing you 
would need to be done after unhappy reducing improvement effects were 
applied in step 3. This would not be following the Civ rules, and may not 
even always be possible. There is another alternate fix below, but Payciv
does not appear to do this either (i.e. create angry citizens).

Note you now have increased the chance of cases where creating a specialist 
will produce more unhappy/angry people, moreover, even creating an elvis 
could actually increase unhappiness. This is because the specialist does 
not produce trade which could be even more than the elvis effect in a 
developed city. In addition to lost trade, you are now including the lost 
native elvis bonus from the ruleset as well. ai_fix_unhappy() for example
doesn't understand these things and may need a parallel adjustment now.

At 07:46 PM 02/05/11 -0700, Raahul Kumar wrote:
>
>--- "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx> wrote:
>> 
>> I'm not sure you can "take specialists" from any category. The code
>> recomputes happiness based on luxury, improvements, wonders and units
>> effects, I believe. Only workers produce the basic trade. And the
>> various ppl_happy counts get filled in and adjusted by the computation.
>> 
>>   pcity->luxury_total += (pcity->ppl_elvis * 2);
>>   pcity->science_total += (pcity->ppl_scientist * 3);
>>   pcity->tax_total +=
>>       (pcity->ppl_taxman * 3) + get_city_tithes_bonus(pcity);
>> 
>> Elvis boost luxury, scientists research and taxmen income from the
>> trade.
>> 
>> So, elvis specialists will improve the happiness levels while the
>> others don't. Your comments seem incorrect in this regard. Do you
>> have an explicit example to explain what you want to change here?
>
>Ross: It always helps to read the patch. Take Christian's example of
>a size 11 city, 3 unhappy people. If you see what the effect would be
>with the original code, 3 scientists would make the happiness problem
>disappear.

No the example doesn't. It also depends on the trade values that the 
workers are producing/would have produced. It is possible for you to 
actually increase the unhappiness by creating scientists. So this 
doesn't guarantee you fix your unhappiness problem.

Your fix will actually make this happen more often. I'm not sure the
code in worker_loop() or ai_fix_unhappy() can cope with this extra
unhappy effect. It currently always assumes that creating elvii will
make things better, so there may be more problems generated here that
to date aren't happening (or that often anyway).

>static void citizen_happy_size(struct city *pcity)
> {
>-  int workers, tmp;
>+  int specialists, tmp; 
> 
>-  workers = pcity->size - city_specialists(pcity);
>
>The above line introduces problems here! This makes it possible for
>unhappy/angry people to be used as specialists. This is what I mean
>when I say making scientists helps your happiness problems. If you have
>one unhappy person in a city, making a scientist helps just as much
>as making an elvis. You should not be able to turn a rioter unhappy
>with the government into a content specialist churning out gold/lux.

The code fix doesn't prevent turning rioters into specialists, it just
delays it. As long as you don't push beyond this stage I'm happy.

>+  specialists = city_specialists(pcity);
>   tmp = content_citizens(city_owner(pcity));

To really do what you say, you need to leave the initial code and
change the above line to
    tmp = content_citizens(city_owner(pcity)) - specialists;

But this creates angry citizens when no content are found which PayCiv
appears not to do.

>-  pcity->ppl_content[0] = MAX(0, MIN(workers, tmp));
>+  pcity->ppl_content[0] = MAX(0, MIN(pcity->size, tmp) - specialists);
>   if (game.angrycitizen == 0)
>     pcity->ppl_angry[0] = 0;
>   else
>     pcity->ppl_angry[0] = MIN(MAX(0, -tmp), pcity->size);

This line is wrong. It should look exactly like the content line except
that it uses -tmp. The bug will be triggered when all new citizens are
angry and you make one a specialist, This then creates a new negative
unhappy citizen with your fix.

>   pcity->ppl_unhappy[0] =
>-      workers - pcity->ppl_content[0] - pcity->ppl_angry[0];
>+  ((pcity->size - specialists) - pcity->ppl_content[0]) -
pcity->ppl_angry[0];
>   pcity->ppl_happy[0] = 0;    /* no one is born happy */
> }
>
>Contrast and compare.
>
><snip>
>__________________________________________________
>Do You Yahoo!?
>LAUNCH - Your Yahoo! Music Experience
>http://launch.yahoo.com

Cheers,
RossW
=====




[Prev in Thread] Current Thread [Next in Thread]