bugFreeciv - Bugs: bug #16413, Gold upkeep and Military...

 
 
Show feedback again

bug #16413: Gold upkeep and Military unhappiness

Submitted by:  -Deleted Account- <tirolalira>
Submitted on:  Thu 12 Aug 2010 10:48:09 PM UTC  
 
Category: rulesetsSeverity: 2 - Minor
Priority: 5 - NormalStatus: Fixed
Assigned to: Matthias Pfafferodt <syntron>Open/Closed: Closed
Release: 2.2.2Operating System: None
Planned Release: 2.2.5, 2.3.0

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sun 19 Jun 2011 11:03:22 PM UTC, comment #25:

Negative balance issue was reproduced and fixed in bug #18221

Marko Lindqvist <cazfi>
Project Administrator
Fri 14 Jan 2011 07:38:34 PM UTC, SVN revision 18930:

update gold upkeep style 2 to sell alternatively a unit and a building

  • only comments are changed in the ruleset files

see bug #16413

(Browse SVN revision 18930)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Fri 14 Jan 2011 07:21:08 PM UTC, SVN revision 18929:

update gold upkeep style 2 to sell alternatively a unit and a building

  • only comments are changed in the ruleset files

see bug #16413

(Browse SVN revision 18929)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Fri 14 Jan 2011 07:04:02 PM UTC, SVN revision 18928:

update gold upkeep style 2 to sell alternatively a unit and a building

  • only comments are changed in the ruleset files

see bug #16413

(Browse SVN revision 18928)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Wed 12 Jan 2011 12:35:54 AM UTC, comment #21:

I'm sure I got negative income in the test, but maybe I did not apply the patch properly.
I'm sorry I can't recheck it, currently I have no linux.
Thank you for keep working on it.

-tirolalira

Anonymous
Mon 15 Nov 2010 09:17:39 AM UTC, comment #20:

rebased patch (no further changes); a negative treasure value should not be possible as in all of the functions asserts are placed which check for treasure >= 0. Could you please recheck?

(file #11222)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Sat 11 Sep 2010 05:46:09 AM UTC, comment #19:

Oh, true, the savegame is useless without my changes to experimental ruleset... you may trust me treasure can become negative with this patch.

(there is no way to edit my posts nor my attaches, doesn't it?)

-Deleted Account- <tirolalira>
Sat 11 Sep 2010 05:00:15 AM UTC, comment #18:

Ooops, while I was testing the other patch I have noticed a bug in this one.
With gold_upkeep_style = 2, it is possible to reach negative treasure!
In my test, there were no buildings to sell, and only one unit was disbanded. Note I have seen other cases were all the excess of units are disbanded.

Savegame playing with slightly modded experimental ruleset. Press end turn and you will end with -2 gold.

However, now that you are patching AI behavior to take into account unit gold upkeep, I do not think it is worth to try to fix this patch.

(file #10303)

-Deleted Account- <tirolalira>
Fri 10 Sep 2010 07:48:53 PM UTC, comment #17:

> I have to check this but if it is the case, the AI has to
> learn to take into account all the over expenses


could you test the patch for bug #16677?

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Thu 09 Sep 2010 06:59:52 AM UTC, comment #16:

> Now I understand the problem is not that AI can't disband
> units, the problem seems to be that AI do not take into
> account the support of units and buildings unless included in
> the gold balance per city (not verified, just a guess).


I have to check this but if it is the case, the AI has to learn to take into account all the over expenses

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Thu 09 Sep 2010 06:35:50 AM UTC, comment #15:

I confirm the new patch is working properly.

Unfortunately, it does not solve AI bankrupts. It seems AI simply does not know to balance his economy with gold_upkeep_style != 0.

Based on the behavior I see in my tests, I'd say AI set the tax/sci/lux bar based on the income per city, no matter the global economy of the nation.

I have seen an AI under democracy, with tax=10%(science=90%), losing -30 gold per turn until treasure reaches 0, losing units and buildings, and still keeping science=90%.
If I reload that save game with gold_upkeep_style = 0, the AI balances the economy immediatly to tax=60% and +30 income per turn.

The reason I suggested this patch is I used to play gold_upkeep_style = 1, and AI seems to be unable to balance the economy when his income become negative due to amount of units supported by gold. I though to kill the excess of units would be the solution.

Now I understand the problem is not that AI can't disband units, the problem seems to be that AI do not take into account the support of units and buildings unless included in the gold balance per city (not verified, just a guess).

I still think it is a good think to dissband a unit and then to sell a building alternatively, as you did with this patch.

-Deleted Account- <tirolalira>
Tue 07 Sep 2010 11:04:57 PM UTC, comment #14:

Sure, I'll test it.
I did not try to hurry you, if you can't work on it until next month, it's ok, I know you are working on many other things. I was just using this patch to learn how to help developers, to avoid wasting your time in future tests ;).
Sorry me I uploaded a wrong savegame2. I had another one with same error over experimental ruleset.
Note I did not played manually the savegame1 until The Corporation, I switched to AI control to see how it was working.

Thank you for the new patch.

-Deleted Account- <tirolalira>
Tue 07 Sep 2010 10:11:46 PM UTC, comment #13:

could you test the attached patch?

changes:

  • first sell a unit, only in the second step sell a building
  • rework the while loop; it did run in an endless loop before ...

(file #10237)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Tue 07 Sep 2010 09:58:12 PM UTC, comment #12:

> 1) I have played a game with unmodded "experimental" ruleset
> and gold_upkeep_style = 1, played until Corporation is
> researched, and it seems to work same than always.


You do not have to play till Corporation is research. You could use the editor or set techlevel to a high value.

file #10214 (goldupkeep2.sav.gz) does not use the experimental ruleset but a ruleset which define 'Tribal' as government

file #10213 (goldupkeep1.sav.gz) seems to burn the cpu but does not go to the next turn? Can you reproduce the problem with a smaller map and perhaps 'set techlevel 100'?

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Tue 07 Sep 2010 07:39:47 AM UTC, comment #11:

> If, in the middle of that game, I switching to
> gold_upkeep_style = 2, when I press end turn the game stops
> with the error: "Lost connection to server!".


This means that there is a bug in the patch. I will try to fix it but it could have to wait till the end of this month.

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Tue 07 Sep 2010 02:39:56 AM UTC, comment #10:

You are right about error message, I forgot I had a modded "default" ruleset in my "/home/.freeciv" folder...
I did not planned to report a bug unless tested with default rulesets.

I'm afraid my previous results about your patch are not valid for same reason, I was changing the gold_upkeep_style in a file that was not used. Sorry me, I'm novice here, I'll be more careful with future tests, and I'll try to limit the amount of my posts :)

I have tested a bit more your patch with trunk revision 17877, I'm almost sure I tested it properly this time, I attach the savegames with the error:

1) I have played a game with unmodded "experimental" ruleset and gold_upkeep_style = 1, played until Corporation is researched, and it seems to work same than always.
If, in the middle of that game, I switching to gold_upkeep_style = 2, when I press end turn the game stops with the error: "Lost connection to server!".
If I switch to gold_upkeep_style = 0 the game continues normally.

-> in /data/experimental/game.ruleset, change gold_upkeep_style to 2, then load savegame1 and press end turn.

2) I have started another game with "experimental" ruleset and gold_upkeep_style = 2. As soon as my treasure falls under zero when I press end turn, the server crashes. Even when there is no gold upkeep (The corporation still not researched).

-> load savegame2 and press end turn.

Final comment: if the purpose of the change is to reduce army size when you can not support it, I suggest gold_upkeep_style = 2 to sell alternatively one unit and one building, as you did, but starting by units. Else, the money from the building will surely be enough to support the extra units this turn, and next time you run out of money, another building will be sold. If I'm right.

(file #10213, file #10214)

-Deleted Account- <tirolalira>
Mon 06 Sep 2010 09:09:17 PM UTC, comment #9:

for point 1) see patch #1936

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Mon 06 Sep 2010 09:01:24 PM UTC, comment #8:

> I'm still testing it, but I'm afraid it does not seem to work
> as expected.


Thanks for testing; I can check it again at the end of this month ...

> Current Trunk revision 17939 gives me this error message when
> I start new game:
>
> Please report this message at
> https://gna.org/projects/freeciv/
> in can_player_build_unit_direct() [unittype.c::631]:
> assertion '((void *)0) != punittype' failed.


Does this happen with the included rulesets or only with your own ruleset? If it is your own ruleset, can you pin it down to one change (in units.ruleset?)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Mon 06 Sep 2010 06:38:36 PM UTC, comment #7:

>If you look into the directory where the patch was rejected, i'll find the file with the correct modifications and a .rejected and .orig files.
>The .orig is the original file before the patch process took over it, and the .rejected containts the parts of the patch that didn't got applied. In that file i'll find information of the code to apply and what did find the patch process.


Thank you jnf.
I have finally been able to apply and compile the patch over trunk revision 17877 (the day Matthias uploaded the patch).
I'm still testing it, but I'm afraid it does not seem to work as expected.
Units are killed even when the treasure is not under zero, and it happens even with gold upkeep style 1 that are supposedly unchanged... if I understood.

I'll keep testing until I understand how exactly worked the old gold upkeep styles and how are currently working the new ones.

-Deleted Account- <tirolalira>
Mon 06 Sep 2010 03:15:49 AM UTC, comment #6:

Now I think I understood your post...

Yes, I have verified the upkeep problem. It is true that with shield upkeep you can not create or rehome units if the city production is already 0.
Still, you can construct Bach's wonder (force content 2) and it would allow a city with pop = 2 to send to war as much units as his production, without any unhappiness under democracy.

Pop 2 city with railroads and mines can support a lot of units, arround 10 or so. And that is much higher than the effect of police stations or Women suffrage wonder.
Also, it is a known multiplayer trick/exploit to construct Shakespeare theater (no unhappy) in a city with a lot of production and to rehome all your attacking units to that city. It practically dissables the military unhappiness by Democracy/Republic governments.

With gold upkeep is even worse, because there is no limit to the units you can construct or rehome, even if your income is negative. It is logical, else when you move the tax bar you would affect the max units per city.

That is why I suggest to use population as an alternative limit for both gold and shield upkeep.

In my civ2-3 ruleset, I solved partially the exploit of force_content, make_happy and no_unhappy, by replacing them by luxury bonuses in the central tile of cities. Because luxuries can not remove the unhappiness caused by military units (they are taken into account before), and at same time luxuries can create other happy citizens to counter the citizens unhappy by military units.
But I guess people do not like such changes in default ruleset.

Btw, I have been able to compile and execute the trunk, and I'm trying to edit manually the file cityturn.c with your changes, to test them.
Current Trunk revision 17939 gives me this error message when I start new game:

-Deleted Account- <tirolalira>
Mon 06 Sep 2010 01:03:49 AM UTC, comment #5:

Sorry me the double post, we post previous comment at same time.

I'm trying to apply the patch right now, but it is the first time I compile the svn trunk version, and I advance slowly.

>Did you test the upkeep problem? I'm also playing longturn and at >the moment I can't build a military unit because my city is to >small to support it.


>City size: 1
>Possible military units: 1 (needs more testing; using shield >upkeep)


I'm not sure if I understood your post, does it mean that you already included the population limit into the patch?
I'll verify it as soon as I can patch and compile it.

-Deleted Account- <tirolalira>
Sun 05 Sep 2010 08:57:10 PM UTC, comment #4:

I'm not experienced user of svn patches and I found troubles to test this patch, maybe you can help me.

When I try to patch the head version of the current trunk I receive this error "FAILED at 1746":

Do I need to test the patch over certain previous trunk version?
Or it might be something I'm doing wrong?

(let me know if there is other place more apropiate for such novice questions)

-Deleted Account- <tirolalira>
Sun 05 Sep 2010 08:47:13 PM UTC, comment #3:

Did you test the upkeep problem? I'm also playing longturn and at the moment I can't build a military unit because my city is to small to support it.

City size: 1
Possible military units: 1 (needs more testing; using shield upkeep)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Tue 31 Aug 2010 11:48:08 PM UTC, comment #2:

Great!, thank you for this patch.
I'll try to compile the trunk just to test this patch.

About the other wish/suggestion:

I guess it would be much more simple to implement only the second part:

And it should be enough to avoid the exploit to bypass military unhappiness.
I believe it could be useful even for default ruleset, though I suppose other players should discuss it before.

Let's test this one first.

-Deleted Account- <tirolalira>
Sat 28 Aug 2010 10:48:46 PM UTC, comment #1:

> 2) Another issue about Gold upkeep:
> I have been testing a lot this system, watching AI behavior
> carefully, and I have seen the AI sometimes enter banckrupt
> due to the ammount of units supported by gold, and when
> buildings start to be destroyed they lose even more money due
> to missing marketplaces, banks, or temples replaced by
> luxury...
> At the end I have seen some AI unable to restore positive
> income, losing most of the buildings in their cities, and
> still supporting a huge ammount of units...
>
> It might be a good idea to disband at least one unit supported
> by gold, everytime you end turn with negative cash.


This (untested) patch changes the gold upkeep style 2 to alternatively sell an unit and an improvement. Please test it.

Part 1 needs another ticket ...

(file #10063)

Matthias Pfafferodt <syntron>
Project MemberIn charge of this item.
Thu 12 Aug 2010 10:48:09 PM UTC, original submission:

1) There is a side effect of some wonders that allows you to bypass the unhappiness caused by military units under Republic or Democracy governments.

If you have one wonder with the effect force_content (as Bach cathedral) or make_happy (as Hanging gardens) or no_unhappy (as Shakespeare theatre), then cities with same population than the wonder effect (or less), can support any number of military units out of the borders without revolt.
In fact, it seems cities with pop=1 can always avoid revolt switching his only citizen to a specialist.
This issue is not very important when units are supported by shields because the shield production of the city limits the ammount of units that can use this cheat/exploit, but it is a mayor issue for any Ruleset based on gold upkeep:
[code]
; Method of paying unit and improvement gold upkeep
; 0 - The player's total gold must be non-negative after paying upkeep
; costs associated with each city. If for any city the player's gold
; is negative, random buildings in the city are sold off. If the gold
; is still negative, then supported units with gold upkeep are
; disbanded.
; 1 - In the first step, the player's total gold must be non-negative after
; paying upkeep for all buildings within a city. If for any city the
; player's gold is negative, random buildings in the city are sold off.
; In the second step, gold upkeep for all units is paid in a lump sum.
; If the player does not have enough gold, random units with gold upkeep
; are disbanded.
; 2 - Gold upkeep for all buildings and units is paid in a lump sum after
; all cities have been processed. If the player does not have enough
; gold, random buildings from random cities are sold. If still more
; gold is needed, then random units with gold upkeep are disbanded.
gold_upkeep_style = 0[/code]

It is hard to balance Rulesets based on Gold upkeep, and the main problem is that there is no limit to the ammount of units that a player can create, nor to the number of units that a city can support (under democracy you could even support thousands of units by gold).

I thought a simple solution that could solve all these issues, and it would ensure balanced wars under any type of government:

I would wish a new optional Rule, that sets the ammount of population as the maximun number of military units that a city can support.
This way, a city that supports as much units as his population value, can not build new units, and you can not select it as the home city for other units.

I have verified that AI already uses to create a number of units lower than his total population, and I think it is a balanced number, that you'd expect to find in a city a number of units equal to his population.

2) Another issue about Gold upkeep:
I have been testing a lot this system, watching AI behavior carefully, and I have seen the AI sometimes enter banckrupt due to the ammount of units supported by gold, and when buildings start to be destroyed they lose even more money due to missing marketplaces, banks, or temples replaced by luxury...
At the end I have seen some AI unable to restore positive income, losing most of the buildings in their cities, and still supporting a huge ammount of units...

It might be a good idea to disband at least one unit supported by gold, everytime you end turn with negative cash.

Please, tell me what do you think, because I feel those changes would be important to get a balanced ruleset based on gold upkeep, even when I know it is not a priority.

-Deleted Account- <tirolalira>

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

 

Digest:
   bug dependencies.

Digest:
   patch dependencies.

 

Carbon-Copy List
  • -unavailable- added by cazfi (Updated the item)
  • -unavailable- added by syntron (Updated the item)
  • -unavailable- added by tirolalira (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 15 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 14 Jan 2011 07:39:02 PM UTCsyntronStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Fri 14 Jan 2011 12:43:51 AM UTCsyntronAssigned toNone=>syntron
    Tue 11 Jan 2011 09:33:09 PM UTCcazfiPlanned Release2.2.4, 2.3.0=>2.2.5, 2.3.0
    Mon 15 Nov 2010 09:17:39 AM UTCsyntronAttached File-=>Added 20101115-trunk-update-gold-upkeep-style-2-to-sell-alternatively-a-u.patch, #11222
    Sat 11 Sep 2010 05:00:15 AM UTCtirolaliraAttached File-=>Added treasurenegative.sav.gz, #10303
    Fri 10 Sep 2010 07:49:30 PM UTCsyntronDependencies-=>Depends on bugs #16677
    Fri 10 Sep 2010 07:49:08 PM UTCsyntronPlanned Release2.3.0=>2.2.4, 2.3.0
    Tue 07 Sep 2010 10:11:46 PM UTCsyntronAttached File-=>Added 20100907-09-trunk-update-gold-upkeep-style-2-to-sell-alternatively-a-u.patch, #10237
    Tue 07 Sep 2010 02:39:56 AM UTCtirolaliraAttached File-=>Added goldupkeep1.sav.gz, #10213
      Attached File-=>Added goldupkeep2.sav.gz, #10214
    Sat 28 Aug 2010 10:48:46 PM UTCsyntronAttached File-=>Added 20100828-01-trunk-update-gold-upkeep-style-2-to-sell-alternatively-a-u.patch, #10063
      Severity1 - Wish=>2 - Minor
      StatusNone=>In Progress
      Planned Release=>2.3.0
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup