Page 1 of 1

Hanging Gardens Mystery

Posted: Thu Dec 14, 2017 1:55 pm
by fran
[effect_hanging_gardens_1]
type = "Output_Add_Tile"
value = 4
reqs =
{ "type", "name", "range"
"Building", "Hanging Gardens", "City"
"CityTile", "Center", "Local"
"OutputType", "Luxury", "Local"
}

Could anybody tell me, why a city with Hanging Gardens should have only 3 lux?
If lux tax is set to 0%, all other cities have 0 lux, and there is nothing else worth mentioning, the city owning the wonder should have 4 lux, or am I mistaken?

Posted: Thu Dec 14, 2017 4:14 pm
by Corbeau
Is it possible that Despotism reduces all 3+ tiles by 1, including this?

Posted: Thu Dec 14, 2017 4:41 pm
by fran
Corbeau wrote:Is it possible that Despotism reduces all 3+ tiles by 1, including this?

wieder said the same, but I didn't understand it then.

[effect_gov_tile_penalty_despotism]
type = "Output_Penalty_Tile"
value = 2
reqs =
{ "type", "name", "range"
"Gov", "Despotism", "Player"
}
nreqs =
{ "type", "name", "range"
"Building", "Pyramids", "Player"
"Tech", "Railroad", "World"
}

compared to

[effect_palace_despotism]
type = "Output_Bonus"
value = 75
reqs =
{ "type", "name", "range"
"Gov", "Despotism", "Player"
"Building", "Palace", "City"
"OutputType", "Gold", "Local"
}

I guess either the implementation of the Hanging Gardens is incorrect, because it uses

type = "Output_Add_Tile"

or it should be documented. Documentation as it is now is wrong because it states:

* Each worked tile that gives more than 2 Food, Shield, or Trade will suffer a -1 penalty, unless the city working it is celebrating. (Cities below size 3 will not celebrate.)

because the luxury points do not stem from trade, but from the wonder. According to the documentation the luxury points from the wonder have nothing to do with trade. So you expect to get luxury, but what you really get is trade?

What's more, the ordinary player does not expect luxury to be implemented via tiles. I expected it to be calculated per city, not per tile. For me tiles had food, production and trade, but no luxury. It should be possible to implement it via some Bonus effect that's not affected by Output_Penalty_Tile.

At least I understand now why I'm screwed. Thanks for hinting.

Next question is how this tax stuff is implemented and the division of trade in sci gold lux. If I have a tile with 6 trade (gold mountain), which is divided into 3 gold and 3 sci, does that mean I get the penalty twice, which would be rather unfortunate.
I would assume the penalty is applied to trade before division into sci gold lux, and this is exactly what the tile says (6 - 1), but IF this is so, why do the 4 added points explicitly labeled as lux get the penalty?
In my opinion it's just wrong. Would be necessary to know what data structure holds Output_Tile stuff.

In fact, if the implementation is consistent, even the 75% increase in gold by effect_palace_despotism would be reduced afterwards by 1, if above 2. That's clearly not intended.

Let's have a closer look at the affected city:
It has 7 trade, 5 from city center. One tradepoint is wasted, one obviously added to gold by the 75% bonus.
That gives 3 gold and 4 science.
With that, trade is consumed. And then the city has 3 lux from the wonder.
So the penalty in fact is applied twice to the tile.

Posted: Thu Dec 14, 2017 8:15 pm
by Caedo
(Tl;dr at the bottom)

Now hold on. A tile can have any of six types of output: Food, Shield, Trade, Science, Gold and Luxury. Typically, tiles won't have the latter three as output.
Now, since the Output_Penalty_Tile effect doesn't specify any output types as a requirement, it affects all six of those. Since the autogenerated help text doesn't expect the latter three (again), they are not mentioned.

The Hanging Gardens add Luxury output to a tile. This is subject to any other effects affecting tile output, including the Output_Penalty_Tile effect.

As for the division of Trade into Science, Gold and Luxury, that happens after all trade has been summed up. If you open the city dialog and click on the numbers next to "Gold", "Science" and "Luxury", it should detail where they come from. In the case of effects such as the Hanging Gardens, there will be an entry "Citizens", which is also present for Food, Shield and Trade. Below that, there will be "Taxed from trade" – this value is not affected by any tile-based effects, but is only calculated once the city's total Trade has been determined.

So essentially the whole process looks like this:
First, the total citizen output is added up. This includes each worked tile's output, which in part depends on Output_*_Tile effects such as Output_Add_Tile; as well as any specialist output (which, in most rulesets, only happens for Science, Gold and Luxury).
Second, some additional stuff might be added, such as revenue from trade routes.
Next, various output bonuses that are not tile-specific are factored in (such as factories), as well as waste/corruption.
Finally, upkeep is subtracted.

Now, this can be immediately done for Food, Shield and Trade output. For Science, Gold and Luxury, the final, total Trade (after all bonuses and corruption) for the entire city is split up based on tax rates and added in step two, before any other effects are applied.

Tl;dr:
Confusion happens because usually, tiles only have Food, Shield and Trade output, not Science, Gold or Luxury. The Despotism penalty applies to everything. Dividing Trade into Science, Gold and Luxury is not done on a per-tile basis, but after the total amount of trade has been determined. Details on where output comes from can be seen by clicking on the numbers in the city dialog.

Posted: Thu Dec 14, 2017 9:24 pm
by fran
Thanks for explaining, I will need some time to grok your post, forgive me a few premature comments.
Caedo wrote: The Hanging Gardens add Luxury output to a tile.
We need to separate the purpose of the wonder from its implementation.
The Hanging Gardens *promise* to make 2 content citizens happy in the city that owns them, regardless of government. That is what the help text says.
The implementation of the Hanging Gardens *fails* to keep that promise at least under anarchy, despotism or tribalism. So either the purpose of the wonder is not adequately described or the implementation is wrong.
In modern software development you first specify your goal and then you implement it. So the specification takes precedence over the implementation. The current implementation makes 2 content citizens happy in all governments except the aforementioned, were it seems to make 1 content citizen happy.
Given the fact the Hanging Gardens is a tech level 1 wonder and obsoleted by Electricity, in my opinion it's unlikely the implementors deliberately crippled it for the early govs without noting that explicitely in the docs.
Caedo wrote: A tile can have any of six types of output: Food, Shield, Trade, Science, Gold and Luxury. Typically, tiles won't have the latter three as output.
Ok. If there is lux independent from tiles, why not adding the 4 lux of the wonder to that?
Caedo wrote: Since the autogenerated help text doesn't expect the latter three (again), ...
... the user doesn't expect them either.
Caedo wrote: If you open the city dialog and click on the numbers next to "Gold", "Science" and "Luxury", it should detail where they come from.
Thanks for mentioning. I was totally ignorant of this, if I ever knew I forgot.
Caedo wrote: So essentially the whole process looks like this:
First, the total citizen output is added up. This includes each worked tile's output, which in part depends on Output_*_Tile effects such as Output_Add_Tile; as well as any specialist output (which, in most rulesets, only happens for Science, Gold and Luxury).
Second, some additional stuff might be added, such as revenue from trade routes.
Where is the penalty applied? At the very beginning, I assume?
Caedo wrote: Next, various output bonuses that are not tile-specific are factored in (such as factories), as well as waste/corruption.
So the following would be a suitable alternative implementation of the Hanging Gardens?

[effect_hanging_gardens_1]
type = "Output_Bonus"
value = 4
reqs =
{ "type", "name", "range"
"Building", "Hanging Gardens", "City"
"OutputType", "Luxury", "Local"
}

Interestingly, all this happiness stuff has
type = "Make_Content" or
type = "Make_Content_Mil"
Because there seems to be no "Make_Happy", you have to go for something else.

Posted: Fri Dec 15, 2017 10:02 am
by wieder
Maybe an easy fix would be making the hanging gardens to remove the tribalism/despotism penalty from the city where it's located. This might also make it more interesting to go for monarchy instead of pyramids. Not much but a bit more interesting.

Posted: Fri Dec 15, 2017 1:57 pm
by fran
wieder wrote:Maybe an easy fix would be making the hanging gardens to remove the tribalism/despotism penalty from the city where it's located. This might also make it more interesting to go for monarchy instead of pyramids. Not much but a bit more interesting.
Wow, nice. Though I have no idea how to do that. The most easy fix for sure is to switch from
Output_Add_Tile to Output_Bonus, if this would work.

Posted: Fri Dec 15, 2017 3:39 pm
by Corbeau
Output_bonus deals with percentages.

Posted: Fri Dec 15, 2017 6:18 pm
by fran
Corbeau wrote:Output_bonus deals with percentages.
True indeed.

To implement wieder's proposal we need to prevent or revert the effect of the penalty for the city that has the Hanging Gardens, if the gov is either despotism or tribal (or anarchy) and the player has neither pyramids nor knows railroad. Or we only go for the city-center tile, or even only for lux on that tile.

For reverting we would need to know if a penalty was applied, I guess that can't be checked via ruleset effects.
So we need to prevent the penalty from being applied from the beginning, and that is only possible if
effect_gov_tile_penalty_* can be locally overriden. I don't know if that is possible, it also should depend on the
order the effects are applied, and if the order of the effects in effects.ruleset matters.

Something like

[effect_hanging_gardens_2]
type = "Output_Penalty_Tile"
value = 9 <----- This number never reached, shall override 2
reqs =
{ "type", "name", "range"
"Gov", "Despotism", "Player"
"Building", "Hanging Gardens", "City" <---- So here we're done if we want to take away penalty from city?
"CityTile", "Center", "Local" <---- If this is would be possible, perhaps even the next line is possible
"OutputType", "Luxury", "Local" <---- As opposed to wieder's proposal that would restrict it to lux
}
nreqs = <------ Strictly not necessary
{ "type", "name", "range"
"Building", "Pyramids", "Player"
"Tech", "Railroad", "World"
}

and that also for tribal (and anarchy).

BTW, what is the difference between Output_Bonus and Output_Bonus2, Output_Add_Tile and Output_Inc_Tile ?

Posted: Fri Dec 15, 2017 6:50 pm
by Corbeau
If I may say so, it's an awful lot of work just to increase Luxuries by 1 :)

Posted: Fri Dec 15, 2017 10:08 pm
by fran
I tested this one

[effect_hanging_gardens_2]
type = "Output_Penalty_Tile"
value = 9
reqs =
{ "type", "name", "range"
"Gov", "Despotism", "Player"
"Building", "Hanging Gardens", "City"
}

by adding the effect to the end of effects.ruleset, and it just worked(TM).
Wonder city got 4 lux and was freed from penalty, but the other cities kept their penalties.

I propose doing this for despotism and tribalism, have no opinion on anarchy.

Posted: Sat Dec 16, 2017 2:57 pm
by Caedo
Honestly, I believe you're patching the wrong end here. First things first:

(1) There is no way to add output apart from tiles and specialists; all city-ranged effects only deal with relative values/percentages.
(2) There is a difference between adding luxury and making citizens happy. A "Make_Happy" effect exists (and is used by the Hanging Gardens in the classic ruleset). The big difference between these two is that firstly, luxury output is subject to Marketplace, Bank and Stock Exchange bonuses (making that implementation technically more powerful), and secondly, that they are applied at different times – if you open the "Happiness" tab of the city dialog, the "Make_Happy" effects would be applied under "Wonders", i.e. pretty much at the end, while luxury is applied right after determining the basic unhappiness, i.e. pretty much at the beginning.
(3) When calculating tile output, the penalty (I believe) is applied last (and only if the city isn't celebrating), so that it both catches every case where it should apply, and doesn't impact relative increases (e.g. Supermarket+Farmland).


That said, if we want to keep the Hanging Gardens the way they are (giving luxury), that should (a) be reflected in the help text (e.g. "Adds 4 luxury to the city where it is built (enough to make two citizens content)"), possibly including the fact that Marketplace etc. boost this, and (b) the output penalty should be circumvented by simply not applying it to Science, Gold and Luxury, e.g.

[effect_gov_tile_penalty_despotism]
type = "Output_Penalty_Tile"
value = 2
reqs =
{ "type", "name", "range"
"Gov", "Despotism", "Player"
}
nreqs =
{ "type", "name", "range"
"Building", "Pyramids", "Player"
"Tech", "Railroad", "World"
"OutputType", "Science", "Local" ; this is new
"OutputType", "Gold", "Local" ; this is new
"OutputType", "Luxury", "Local" ; this is new
}

That way, Output_Penalty_Tile will be 0 for Science, Gold and Luxury for every tile, so it won't be applied at all and we're all safe from voodoo-workarounds.
I also believe this should be added to all governments' Output_Penalty_Tile effects; including anarchy.

Posted: Sat Dec 16, 2017 3:46 pm
by wieder
Why would it be patching the wrong end if the penalty was removed from the city with this wonder? The pyramids is not not only thing that will remove the despotism/tribalism penalty. If anyone has railroad the penalty will be removed from everyone. It's also one of the most common "errors" players testing the test games report. It almost never happens on the real games but on test games it's common that someone has rails when someone starts testing the game and notices that there is no d/t penalty.

I think that the penalty could be removed, from anyone, when the first player invents trade. The players should be allowed to make mistakes but just like tech leakage, there are some situations where helping the new players makes lots of sense.

Posted: Sat Dec 16, 2017 4:20 pm
by Caedo
With "patching the wrong end", I was talking about the idea of increasing the Output_Penalty_Tile effect (by an arbitrary value) in order to disable it. That said, since the Hanging Gardens are the only thing that ever even gives luxury tile output, i.e. we never want it capped by the penalty, it should probably be disabled in the first place. The same thing applies to science and gold output, because otherwise we'll be having thi very same discussion in a couple of months or years, when a change to the ruleset gives that to tiles in sufficient amounts to trigger the penalty.

Whether or not the Hanging Gardens should completely remove the penalty from that city is an entirely different debate. I believe it wouldn't be that great. It will create two wonders with partially overlapping, but not stacking, effects, which weakens both of them to a certain degree (relative to having only one of them with the effect). It might be more practical to keep each wonder in its respective domain, with the Gardens' being happiness.

Posted: Sat Dec 16, 2017 4:47 pm
by wieder
Oh right. Misunderstood that.

Overlapping might not be that bad since it allows you to choose what to build to get specific effects and also gives ""penalty" for building two improvements with partially the same effect. The "penalty" part comes from overlapping. I also like more and more about the idea of making the pyramids less important by improving something else instead.

In any case I'll fix the help text.

About trade and happiness, it's still a shame there wasn't a way to make the ruins to give a small trade bonus. That would have been really nice :)

Posted: Sat Dec 16, 2017 7:49 pm
by fran
I tested the solution Caedo provided by adding the 3 lines and of course it works.
I think his patch is the way to go.

Thanks to Caedo for his insightful explanations.

Posted: Tue Dec 19, 2017 7:49 am
by fran
After I switched from despotism to tribal the city now has 4 lux. I'm startled.

Posted: Tue Dec 19, 2017 9:00 am
by wieder
That sounds really really weird. The city is however just happy now, not celebrating?

Another option is that this could be happening because tribalism has less waste.

I guess when can agree on that Freeciv is a really complex game and knowing everything about it is almost impossible :D

Posted: Tue Dec 19, 2017 10:15 am
by fran
wieder wrote:That sounds really really weird. The city is however just happy now, not celebrating?

Another option is that this could be happening because tribalism has less waste.
Sure, it's celebrating right away. The only way it could be waste-related is that in despotism there is some hidden
lux-waste, i.e. waste that is not shown as 4 - 1. As Caedo said, lux source shows up in city dialog as citizens. 3 in despo, 4 in tribal. I should had taken a screenshot, just for the case sb thinks I'm making this up ...

Posted: Tue Dec 19, 2017 11:00 am
by Corbeau
Well, if it's celebrating, it means it propelled itself out of the despotism/tribalism 3+ tile restriction and is now able to harvest all four luxuries.

Posted: Tue Dec 19, 2017 11:24 am
by fran
Corbeau wrote:Well, if it's celebrating, it means it propelled itself out of the despotism/tribalism 3+ tile restriction and is now able to harvest all four luxuries.
No. It celebrates because it now gets 4 lux instead of 3, making half of the population happy.
Celebration is not a black box from heaven.

Posted: Tue Dec 19, 2017 3:40 pm
by wieder
Maybe the city went happy the turn you went to anarchy and managed to switch to celebration the next turn? In any case it should be happy for one turn before celebrating.

Posted: Tue Dec 19, 2017 4:13 pm
by fran
wieder wrote:Maybe the city went happy the turn you went to anarchy and managed to switch to celebration the next turn? In any case it should be happy for one turn before celebrating.
If half of trade in anarchy is made to lux, and city size is 4, I need at least 8 trade to gain 4 lux to get 2 citizens happy. City had either 7 or 10 trade in anarchy, from that we need to subtract waste, if any.
So 8 trade/ 4 lux/ 2 happy in anarchy are theoretically possible.

The surprising thing is, that the city should celebrate next turn after anarchy and this should determine the production of that same turn. I would had expected that celebration is instantely canceled, so never starts at all.

If this is what happened Corbeau is kind of right: It's self propelled and should last if the city does not grow
above size 4. At size 5 celebration should break down and lux again should be 3. I won't test that :)

This is really weird stuff! Having the city at 10 trade in anarchy was unintentional, an accident.

If anarchy was able to jumpstart this the next question is if lux taxing also could do the trick.

Posted: Tue Dec 19, 2017 5:07 pm
by Corbeau
Image