Page 1 of 2

Troubleshooting the ruleset

Posted: Sun Sep 09, 2018 12:33 am
by Corbeau
Any ideas why this doesn't work?

Code: Select all

[effect_building_upkeep_anarchy]
type    = "Upkeep_Free"
value   = 99
reqs    =
    { "type", "name", "range"
      "Gov", "Anarchy", "Player"
    }
I am definitely in Anarchy and an improvement got disbanded due to lack of funds (had 17, needed 18).

There are no other conflicting "Upkeep_Free" effects in the ruleset: total two more, one requires Communism, the other requires Adam Smith (not present).

Re: Troubleshooting the ruleset

Posted: Sun Sep 09, 2018 1:15 am
by Akechi
Economy Tab (F5) may help you.
Have you checked unit gold upkeep?

Re: Troubleshooting the ruleset

Posted: Sun Sep 09, 2018 8:44 am
by Corbeau
Oh hell... Yes, that's it, the units. Thanks.

Re: Troubleshooting the ruleset

Posted: Thu Sep 13, 2018 4:29 pm
by Corbeau
The situation:

A city is 19.3 tiles away from the capital (coordinates of both: (134,8) and (152,15))

Corruption per distance: 4
Base corruption: 25

Code: Select all

[effect_corruption_distance_monarchy]
type    = "Output_Waste_By_Distance"
value   = 4
reqs    =
    { "type", "name", "range"
      "OutputType", "Trade", "Local"
      "Gov", "Monarchy", "Player"
    }

[effect_corruption_monarchy]
type    = "Output_Waste"
value   = 25
reqs    =
    { "type", "name", "range"
      "Gov", "Monarchy", "Player"
      "OutputType", "Trade", "Local"
    }
In all, this should be (at least) 19*4 + 25 = 101

However, the city Trade is 1/14 (Corruption: 13).

No anti-corruption buildings. Techs don't influence corruption.

What am I missing?

Re: Troubleshooting the ruleset

Posted: Thu Sep 13, 2018 6:50 pm
by Alien Valkyrie
Are you sure the waste by distance calculation uses pythagorean distance? If we use shortest path, that's only 18, which would lead to a corruption of 97 (which is in percent, according to README.effects). 14 * 97% yields 13.58, which (I would assume) is truncated to 13.

I would like to mention, though, that I did not take any look at the code that does these calculations; this is just educated guesswork.

Re: Troubleshooting the ruleset

Posted: Thu Sep 13, 2018 8:42 pm
by Corbeau
By shortest path I assume you mean diagonally?

Hm, here is another faraway city, dx=9, dy=10. Temple present, "Output_Waste_Pct" = 15. End result: trade 11 (+5), so corruption: 6. But it has a -15% corruption builsing and with so many steps and rounding ups/downs, I don't even want to try calculating...

Re: Troubleshooting the ruleset

Posted: Fri Sep 14, 2018 12:19 pm
by Alien Valkyrie
Well, if you punch those numbers into a caclulator without rounding, you get a base corruption of 25 + 9*4 = 61. Deduce 15% of that and you get 61 * 85% = 51.85. Applying that to 11 trade, you'd get 11 * (100 - 51.85)% = 11 * 48.15% = 5.2965 trade left. If we'd rounded before, we'd have gotten 11 * 49% = 5.39 (or, if we rounded the other way, 11 * 48% = 5.28). Either way, that final value would come out to be 5, so 5 trade points are left after corruption, i.e. corruption 6.

Really, the only problem here is that there isn't an exact breakdown of corruption in the city dialog (or an exact explanation in the help browser). If, instead of just writing "Corruption: 6" into the city overview screen, it actually said "Corruption: 51%", all of this would probably a lot clearer.

Re: Troubleshooting the ruleset

Posted: Fri Sep 14, 2018 12:37 pm
by Akechi
Corbeau wrote:By shortest path I assume you mean diagonally?

Hm, here is another faraway city, dx=9, dy=10. Temple present, "Output_Waste_Pct" = 15. End result: trade 11 (+5), so corruption: 6. But it has a -15% corruption builsing and with so many steps and rounding ups/downs, I don't even want to try calculating...
Corruption from trade = 11, corruption percentage = 25, distance corruption percentage = 4 per tile is:
First, corruption = 11 * (25 + 4 * 10) / 100 = 7.15 ... truncated to 7.
Next, corruption is deducted by 7 * 15 / 100 = 1.05 ... truncated to 1.
Then, final corruption is 7 - 1 = 6.
All truncation is towards zero.

Re: Troubleshooting the ruleset

Posted: Fri Sep 14, 2018 12:41 pm
by Alien Valkyrie
Akechi wrote:
Corbeau wrote:By shortest path I assume you mean diagonally?

Hm, here is another faraway city, dx=9, dy=10. Temple present, "Output_Waste_Pct" = 15. End result: trade 11 (+5), so corruption: 6. But it has a -15% corruption builsing and with so many steps and rounding ups/downs, I don't even want to try calculating...
Corruption from trade = 11, corruption percentage = 25, distance corruption percentage = 4 per tile is:
First, corruption = 11 * (25 + 4 * 10) / 100 = 7.15 ... truncated to 7.
Next, corruption is deducted by 7 * 15 / 100 = 1.05 ... truncated to 1.
Then, final corruption is 7 - 1 = 6.
All truncation is towards zero.
Wait, seriously? Corruption is calculated against the city's trade output before Output_Waste_Pct effects are taken into account? That sounds like it would introduce unnecessary rounding errors. When was that code written?

Re: Troubleshooting the ruleset

Posted: Fri Sep 14, 2018 12:49 pm
by Akechi
Caedo wrote:Wait, seriously? Corruption is calculated against the city's trade output before Output_Waste_Pct effects are taken into account? That sounds like it would introduce unnecessary rounding errors. When was that code written?
Code is written from around https://github.com/freeciv/freeciv/blob ... ty.c#L2933