Logo Platform
logo amplifiers simplified

About Priority

Reply
Copied to clipboard!
9 years ago
Nov 25, 2015, 6:12:21 PM
Hi,

after some test of the mod i'm working on, I have some trouble with this :

[CODE]18:34:02:714STACKA cylic reference have been found in the modifiers of the properties BaseDustPerPopulation.

18:34:02:714STACKA cylic reference have been found in the modifiers of the properties BaseFoodPerPopulation.

18:34:02:714STACKA cylic reference have been found in the modifiers of the properties CityApproval.

18:34:02:714STACKA cylic reference have been found in the modifiers of the properties NetCityApproval.

18:34:02:714STACKA cylic reference have been found in the modifiers of the properties Approval.[/CODE]

and this :

[CODE]

18:34:02:715STACKThe patch renderer has caught an exception while regenerating: The simulation has a compute which use more than 20 properties. Cyclic computing or really complex one? at Amplitude.Unity.Simulation.SimulationPropertyRefreshContext.GetContext (Int32 requestId) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationObject.Unsafe_PropertyRefresh (Int32 propertyIndex, Int32 propertyContextRequestId) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationObject.Unsafe_PropertyRefresh (Amplitude.StaticString propertyName, Int32 propertyContextRequestId) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationModifierDescriptor.GetValue (System.Object value, Amplitude.Unity.Simulation.SimulationObject context, Amplitude.Unity.Simulation.SimulationObject modifierSource, Amplitude.Unity.Simulation.SimulationPropertyRefreshContext propertyRefreshContext) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationModifierDescriptors.BinarySimulationModifierDescriptor.ComputeValue (Amplitude.Unity.Simulation.SimulationObject context, Amplitude.Unity.Simulation.SimulationObject source, Amplitude.Unity.Simulation.SimulationPropertyRefreshContext propertyRefreshContext) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationModifierDescriptor.Process (Amplitude.Unity.Simulation.SimulationPropertyRefreshContext propertyRefreshContext, Amplitude.Unity.Simulation.SimulationModifierProvider provider, Amplitude.Unity.Simulation.SimulationObject target) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationPropertyRefreshContext.Process (Amplitude.Unity.Simulation.SimulationProperty property, Amplitude.Unity.Simulation.SimulationObject context, Boolean isBase, System.Action`2 forEachModifierProvider) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationObject.Unsafe_PropertyRefresh (Int32 propertyIndex, Int32 propertyContextRequestId) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationObject.Unsafe_PropertyRefresh (Amplitude.StaticString propertyName, Int32 propertyContextRequestId) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationModifierDescriptor.GetValue (System.Object value, Amplitude.Unity.Simulation.SimulationObject context, Amplitude.Unity.Simulation.SimulationObject modifierSource, Amplitude.Unity.Simulation.SimulationPropertyRefreshContext propertyRefreshContext) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationModifierDescriptors.BinarySimulationModifierDescriptor.ComputeValue (Amplitude.Unity.Simulation.SimulationObject context, Amplitude.Unity.Simulation.SimulationObject source, Amplitude.Unity.Simulation.SimulationPropertyRefreshContext propertyRefreshContext) [0x00000] in :0 at Amplitude.Unity.Simulation.SimulationModifierDescriptor.Process (Amplitude.Unity.Simulation.SimulationPropertyRefreshContext propertyRefreshContext, Amplitude.Unity.Simulation.SimulationModifierProvider provider, Amplitude.Unity.Simulation.SimulationObject target) [0x00000] in :0 at ............ ETC ETC ETC [/CODE]



I suppose there is some "cycling" problem.

Example : BaseDustPerPopulation give bonus to BaseFoodPerPopulation, and another cityimprovement make BaseFoodPerPopulation give bonus to BaseDustPerPopulation.

More complex maybe, but I'm almost sure there is something like that with the massive interactions in cityimprovements i've made.



So, I think a solution could be to put a priority in some descriptor, and then remove the cycling problem.

One cityImprovement get priority="1", the other one get priority="2"



I'm looking for that, but when searching what priority to write, I found this in CityClass :



[CODE]



































[/CODE]



In tuto PDF, it's said priority is : the smallest triger first.

Then if I read this code the last go first.

But How can it work, it look like CityFood is calculate BEFORE to put WorkedFood from BaseFoodPerPopulation and from DistrictFoodNet into.

It's not logical, should be inverted ! first, add productions from everywhere, THEN put WorkedFood into CityFood.



So there is a mystery here, because cityImprovement of the game have no priority (so, it's "zero"). so they should not give what they product into CityFood.





Last thing (but it's another problem) :

There is also this warning :

[CODE]Fmod error reported: ERR_EVENT_NOTFOUND - The requested event, event group, event category or event property could not be found.[/CODE]



There is no many clues here, where to look at ? event property could be a wrong value in a value of a descriptor ? Or other ?



THanks,
0Send private message
9 years ago
Nov 26, 2015, 10:34:26 AM
Hi!



You are starting to touch a really high versatile part of the simulation.



I will start by explaining how the priority work, then dig in the city food computation to demonstrate how the property are updated and finally try to explain why you will probably have to change a little how you are processing your datas to avoid cyclic reference.



Priority in simulation modifiers

At the beginning, we add no priority. The fact is: we are processing the operation in a certain order. First addition and base value, then multiplication and division, then power and finally we apply the percentages.

But sometimes you want to add something after you have multiply it by something else.

So we ended up by adding priority to allow our mighty designer to do some strange computation.



This is how work the computation of one property value. Regardless of his dependencies on other properties values.



Property update order and cyclic reference

Now that we are able to update a value of one property, we need to look at the whole object.

So properties are depending from other properties. Which force us to update first the dependencies. To do that, we have a small algorithm which is able to order the properties depending of the dependencies between them.



If you have a "RaffinedResource" property which depend of the value of the "RawResource" property. We assure you that "RawResource" value will be computed before "RaffinedResource" and when "RawResource" is modified by anything (new modifier, change in the code, etc), both will be marked as "Dirty" and updated at the next simulation update pass.



Based on that, you should never have two properties that are needed to compute each other. Never.



Now, if we look at the Growth computation of a city we have the following properties:

[CODE]



















[/CODE]



We also have some conversion properties... which are use to modify the conversion from one step to another or transfer some yield of one resource in another resource gain.

[CODE]













[/CODE]



If you look at the modifier of the city, we can deduce the following operation:

[CODE]

DistrictFood: Is the sum of the tile production (city tiles or exploitation). Nothing seams to change it in the city.



DistrictFoodNet = DistrictFood * DistrictFoodToDistrictFoodNetConversionFactor



// I didn't know this line exists... I think it's an error to do it that way, but...

BaseFoodPerPopulation = BaseFoodPerPopulation + (BaseDustPerPopulation * BaseDustPerPopulationToBaseFoodPerPopulationConversionFactor)



WorkedFood = (BaseFoodPerPopulation * FoodPopulation) + DistrictFoodNet



CityFood = WorkedFood



CityGrowth = (CityFood * CityFoodToCityGrowthConversionFactor) + (CityIndustry * CityIndustryToCityGrowthConversionFactor)



CityGrowthUpkeep = Population * CityGrowthUpkeepPerPopulation





// I voluntary put AlmostNetCityGrowth out of the equation because it is use for specific gui purpose if I remember correctly...

NetCityGrowth = CityGrowth - CityGrowthUpkeep

[/CODE]



As you can see, the order of the Growth is quite obvious.



We use "Force" combined with "under 0" properties for gui reason. So I am able, when building the tooltip procedurally, to jump over the Forced properties. We do that because we want a control about what is displayed or not.



But at the same time, as they are under 0, they are process before any building trying to push a modifier on them, so the gain of building is applied on the forced properties too!



How to cross reference two resource without making cross reference

As you have seen, we have a lot of separate property which separate our computation in different step.

You should always try to use a step before you to influence another properties and back. For example, we have, from the beginning decided to allow the possibility to replace the food by industry to growth the system and to use food to produce building.

To do that we have create a conversion property "CityFoodToCityGrowthConversionFactor" which is able to nullify the gain from food to growth and another "CityFoodToCityProductionConversionFactor" which is able to transfer all the food gathered from the district and population to the production.



These conversion properties are also define for the industry (CityIndustryToCityGrowthConversionFactor and CityIndustryToCityProductionConversionFactor).



All that to say: if you want to use some dust to produce growth, you need to use a previous step properties and push it to another step properties. you should never use two properties that are on the same level.

If you need, you may create a new "step" by adding a temporar property which gather the normal and conversion yield.



I hope it will help you even a little and if you do not understand something or need more detail on something, just ask away!



Cheers,

Flo.
0Send private message
9 years ago
Nov 26, 2015, 6:49:53 PM
Hello,

Thank for your reply.

My english level go to the limit here, and a little difficult to understand, will need to read it again.



Fact is I broke the game with this silly city improvement :

[CODE]



[/CODE]

And another one doing this :

[CODE]



[/CODE]



I just deleted this effect and replace it with another very cool effect that don't break the game.

I launched a game and go era 1 to era 6 with all new techs, and there is no crash, and no warning. Near perfect, except the mod is not very balanced yet and there is no greats IAParameters. It will be very difficult to do, and i will need new one. Maybe I will release an Alpha version without full rework of these parameters, but I have a lot of work before with many improvements not done yet.

It look like there is some change in this IAParameters coming from last release, I saw many complicated formulas i didn't remember saw before. Should have not be a lot of fun to do ;-(
0Send private message
9 years ago
Nov 26, 2015, 7:02:52 PM
Preview, here my first AI creation.

I'm walking in a new path, I never really look at this kind of stuff before

[CODE]@path=AI\AIParameterConverters[Food].xml.xml









$(Input) * $Property(CityFoodToCityGrowthConversionFactor) * $Count(ClassCity/TerrainTagAnomaly)

$(Input) * $Property(CityFoodToCityProductionConversionFactor) * $Count(ClassCity/TerrainTagAnomaly)



$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityGrowthConversionFactor) * $Count(ClassEmpire/ClassCity/TerrainTagAnomaly)

$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityProductionConversionFactor) * $Count(ClassEmpire/ClassCity/TerrainTagAnomaly)

[/CODE]



But what i want really do is this :



[CODE]





$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityGrowthConversionFactor) * $SumProperty(ClassEmpire/ClassCitysmiley: biggrinistrictFood,TerrainTagAnomaly)

$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityProductionConversionFactor) * $SumProperty(ClassEmpire/ClassCitysmiley: biggrinistrictFood,TerrainTagAnomaly)



$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityGrowthConversionFactor) * $SumProperty(ClassEmpire/ClassCitysmiley: biggrinistrictFood,TerrainTagAnomaly)

$(Input) * $Property(ClassEmpire/ClassCity:CityFoodToCityProductionConversionFactor) * $SumProperty(ClassEmpire/ClassCitysmiley: biggrinistrictFood,TerrainTagAnomaly)

[/CODE]



But i don't know if it work.

The improvement give +100% districtfood on a anomaly
0Send private message
?

Click here to login

Reply
Comment