Troubleshooting the ruleset

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
User avatar
Corbeau
Elite
Posts: 1291
Joined: Mon Jan 13, 2014 11:13 pm

Troubleshooting the ruleset

Post 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).
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
Akechi
Posts: 34
Joined: Thu Dec 07, 2017 12:17 pm

Re: Troubleshooting the ruleset

Post by Akechi »

Economy Tab (F5) may help you.
Have you checked unit gold upkeep?
User avatar
Corbeau
Elite
Posts: 1291
Joined: Mon Jan 13, 2014 11:13 pm

Re: Troubleshooting the ruleset

Post by Corbeau »

Oh hell... Yes, that's it, the units. Thanks.
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
User avatar
Corbeau
Elite
Posts: 1291
Joined: Mon Jan 13, 2014 11:13 pm

Re: Troubleshooting the ruleset

Post 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?
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
User avatar
Alien Valkyrie
Elite
Posts: 513
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Troubleshooting the ruleset

Post 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.
~ AVL
User avatar
Corbeau
Elite
Posts: 1291
Joined: Mon Jan 13, 2014 11:13 pm

Re: Troubleshooting the ruleset

Post 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...
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
User avatar
Alien Valkyrie
Elite
Posts: 513
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Troubleshooting the ruleset

Post 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.
~ AVL
Akechi
Posts: 34
Joined: Thu Dec 07, 2017 12:17 pm

Re: Troubleshooting the ruleset

Post 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.
User avatar
Alien Valkyrie
Elite
Posts: 513
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Troubleshooting the ruleset

Post 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?
~ AVL
Akechi
Posts: 34
Joined: Thu Dec 07, 2017 12:17 pm

Re: Troubleshooting the ruleset

Post 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
Post Reply