Extending the generic property system

@AIAndy: I figured out exactly what is wrong with the property displays, as well as finding an actual property bug. The mouseover on the map shows the negative crime, but it does not properly take into account multiple units on a tile, IE if i had three Police Mechs on one tile it would only show -35 crime/turn (what I set it to for testing), as opposed to -105, which is what it should be.

The display bug seems limited only to the Pedia mouseover. Could you try to resolve these bugs please before midnight, when SO plans to release V22?
I don't quite get what you mean. Whatever it is, it will certainly not be fixed before the release of V22 (for which police units are not intended anyway).

Btw, a source on a unit or promotion will only change the property on the unit until a change I intend to do tomorrow evening after which it will be possible to apply it to the city or plot the unit is standing on.
 
Should multiple units really change the crime property that much, or should at most one unit be able to change it? With the new promotions coming too and all?

Cheers
 
I don't quite get what you mean. Whatever it is, it will certainly not be fixed before the release of V22 (for which police units are not intended anyway).

Btw, a source on a unit or promotion will only change the property on the unit until a change I intend to do tomorrow evening after which it will be possible to apply it to the city or plot the unit is standing on.

What I meant is that no matter how many units were on one tile, the amount of crime generated was the same, ie it did not stack.
 
What I meant is that no matter how many units were on one tile, the amount of crime generated was the same, ie it did not stack.
Generated on which object? Currently any source you stick on a unit applies to that unit only. So the crime gets added to the unit, not the city or plot.
 
Generated on which object? Currently any source you stick on a unit applies to that unit only. So the crime gets added to the unit, not the city or plot.

Huh? It was generating on the plot in my tests.:confused: I can't provide a screenshot now as i'm away from my modding computer, but the Crime was being applied to plots, and even diffusing to adjacent plots in my testing.
 
Huh? It was generating on the plot in my tests.:confused: I can't provide a screenshot now as i'm away from my modding computer, but the Crime was being applied to plots, and even diffusing to adjacent plots in my testing.
Post the XML and test case and I have a look at what it does and what it should have done tomorrow evening.
 
Oopsie. I misread the mouseover, the crime is indeed working as you intended:blush:.Sorry about that, you can just go ahead and add the crime to plots as intended.
 
I don't know if this is the right thread to ask this but I'll do anyway (may be shifted to elsewhere by mod if not):

would it be possible to create a value like globalEarthTemperature that may be altered by events or buildings or turn/date? May this value also be local (localEarthTemperature), diffusing to nearby tiles like 'crime' is now?

if the globalEarthTemperature would increase/fall, the chance for certain tiles to switch would also increase/fall
localEarthTemperature could also effect the globalEarthTemperature but only at a small rate.

So some examples how I think it could work in the game,

if you have lets say 5 relatively nearby vulcanoes erupting in a timeframe of few dozen turns in prehistoric era (in eternity speed, for instance), first the global 'temperature' could go down for some turns, more or less slowly changing plots all over the earth
secoundly, the local 'temperature' would change, shifting the landscape in the region more active than elsewhere.

This "local" effect could also be used to simulate the outcome of humanities shaping of landscapes: if you cut down trees to plant farms you would increase the 'temperature' locally, leading to several possible events or just lower tile output, thus balancing the farm-spamming this way etc...

To prevent a certain temperature "inflation" there could be several buildings reducing it, in later game and also, as I wrote vulcanoes could balance higher temperature, as well as the civs could try to end ice ages faster by cutting/burning much wood (a real effect as scientists have shown, mass clearings of forests in bronze age had a massive effect on climate). Planting tree farms/young forests should become available with wood working imho, to cope with the land-shaping dynamics...and thus also have a higher priority for AI, maybe.
 
I don't know if this is the right thread to ask this but I'll do anyway (may be shifted to elsewhere by mod if not):

would it be possible to create a value like globalEarthTemperature that may be altered by events or buildings or turn/date? May this value also be local (localEarthTemperature), diffusing to nearby tiles like 'crime' is now?

if the globalEarthTemperature would increase/fall, the chance for certain tiles to switch would also increase/fall
localEarthTemperature could also effect the globalEarthTemperature but only at a small rate.

So some examples how I think it could work in the game,

if you have lets say 5 relatively nearby vulcanoes erupting in a timeframe of few dozen turns in prehistoric era (in eternity speed, for instance), first the global 'temperature' could go down for some turns, more or less slowly changing plots all over the earth
secoundly, the local 'temperature' would change, shifting the landscape in the region more active than elsewhere.

This "local" effect could also be used to simulate the outcome of humanities shaping of landscapes: if you cut down trees to plant farms you would increase the 'temperature' locally, leading to several possible events or just lower tile output, thus balancing the farm-spamming this way etc...

To prevent a certain temperature "inflation" there could be several buildings reducing it, in later game and also, as I wrote vulcanoes could balance higher temperature, as well as the civs could try to end ice ages faster by cutting/burning much wood (a real effect as scientists have shown, mass clearings of forests in bronze age had a massive effect on climate). Planting tree farms/young forests should become available with wood working imho, to cope with the land-shaping dynamics...and thus also have a higher priority for AI, maybe.
In general, yes, it is possible, but good temperature models are not simple.

If we go and change the map scripts to provide a height/plot map and the starting parameters of a climate model and then have an ongoing climate simulation that reacts to what you do and to events, that would be hilarious. Lots of effort though and it would have serious implications on the gameplay and the AI.
 
In general, yes, it is possible, but good temperature models are not simple.

If we go and change the map scripts to provide a height/plot map and the starting parameters of a climate model and then have an ongoing climate simulation that reacts to what you do and to events, that would be hilarious. Lots of effort though and it would have serious implications on the gameplay and the AI.

Erebus continent map script has enough of that, for tile plots and resources/major river because of water table, and is C2C compatable.
 
Erebus continent map script has enough of that, for tile plots and resources/major river because of water table, and is C2C compatable.
Most map scripts have something like that, but the current interfaces do not provide it and it is not in the same format.
 
Oopsie. I misread the mouseover, the crime is indeed working as you intended:blush:.Sorry about that, you can just go ahead and add the crime to plots as intended.
The change is on the SVN now.
Stick the source on the promotion or unit type with RelationType RELATION_SAME_PLOT and GameObjectType GAMEOBJECT_CITY and it should apply the source to the city in which the unit stands.
 
Well all the anti-crime units have Riot Control I on them so they would all instantly get anti-crime. And since you cannot get the promotion normally it will not have an issue with other types of units (aka non-police).

EDIT: I would also like to bring back Riot Control II, III, IV and V. These would each require the promotion before it and add -5 crime for each additional promotion. Thus at max you could have -25 crime per turn for a single unit.

Could you add those promotions and just have use the same icon. Thus the requirements would be ...

- Riot Control II (Req Riot Control I)
- Riot Control III (Req Riot Control II)
- Riot Control IV (Req Riot Control III)
- Riot Control V (Req Riot Control IV)

All this is now on the SVN.
 
Can you point me at a tutorial, article, PhD that describes the technique you are using here? One with plenty of mathematical formula, or links, is best. I'm a pure maths type of person. ;)
 
Can you point me at a tutorial, article, PhD that describes the technique you are using here? One with plenty of mathematical formula, or links, is best. I'm a pure maths type of person. ;)
I fear I can't do that because I have not taken it out of one.
It is somewhat related to differential equations and a predict-correct numerical integration scheme but not quite because I work with integers and there is no need for 100% accuracy (and an iterative algorithm to converge the solution of an implicit formulation would be too expensive).

So what I do is the following:
For ease of explanation lets leave out interactions for now and lets only use plots. Consider one property that has a value on all those plots. Now you can have any number of sources and propagators active on those plots.
A source can be considered a differential equation, that defines how the value of the plot should change depending on the value of the plot.
dx/dt = g(x)
Since we are turn based and not continuous, we use
Dx = f(x)
where Dx is the change to this property from this source in this turn given by a function depending on the current value.
The easiest source is the unlimited constant source that is just defined by a constant change each turn
f(x) = iAmountPerTurn

We have more than one source though. In the case of the constant unlimited source that is easy, we just sum up all the Dx and have the actual change of that property in this turn. But we have other source types as well. Among them decay.
f(x) = - iPercent * x / 100
Decay is supposed to always get the value towards 0 but if we have two decays on the same plot that each do a decay of 60%, then a simple sum would add up to 120% and make our value negative.
Another example are limited sources. If you have two constant sources that should be limited to 100 on the same plot and you are already close to 100, then while each of them would keep under 100, just adding them up would get you over 100. The limit is an important property though, so something more should be done to keep it.

Now an easy fix would be to just apply the sources in a certain order. This is done between sources, propagators and interactions (first propagators, then interactions, then sources). Unfortunately that means the result depends on that order.
So instead within the categories we first make a prediction by summing up the value that would result if a source were the only source on that plot. Then we give each source a chance to correct its prediction by giving it the prediction sum. Only that result is then used.
So if a limited source sees that the prediction got over the limit, then it reduces its output proportionally.

With propagators it is similar but instead of only changing the property on the plot it is on, instead it can also change the property on a number of target plots. Lets take the diffusion propagator with only two plots, the one it is on (x) and the one it has as target (y):
Dx = - iPercent * (x - y) / 100
Dy = iPercent * (x - y) / 100
 
It is somewhat related to differential equations and a predict-correct numerical integration scheme but not quite because I work with integers

Damn those limitations of computers! Now I can't screw you up with transfer functions that are not continously differentiable. I want my Conway functions!

f(x) = 1 if x is rational, 0 if not
:lol:
 
AIAndy, everything you said made perfect sense but I am still missing something. the last time I did anything with calculus was 1974/5 it was the first and only exam I forgot everything as I walked in the door and had to prove everything from first principles before answering the questions. I did not do well on that exam (just passed) so concentrated on computers and pure mathematics instead.

So I googled "predict-correct numerical integration scheme" and "Conway functions". While interesting the resultant pages were related to that new fangled "Game Theory" stuff. Is that right? I don't think I have done anything on game theory ever.;)
 
AIAndy, everything you said made perfect sense but I am still missing something. the last time I did anything with calculus was 1974/5 it was the first and only exam I forgot everything as I walked in the door and had to prove everything from first principles before answering the questions. I did not do well on that exam (just passed) so concentrated on computers and pure mathematics instead.

So I googled "predict-correct numerical integration scheme" and "Conway functions". While interesting the resultant pages were related to that new fangled "Game Theory" stuff. Is that right? I don't think I have done anything on game theory ever.;)

The Conway function reference was a joke. Ignore me - I was in a funny mood.:rolleyes:
 
The Conway function reference was a joke. Ignore me - I was in a funny mood.:rolleyes:

Hey Sheldon, next Big Bang Theory up tonight ;)
 
Back
Top Bottom