1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Extending the generic property system

Discussion in 'Civ4 - Caveman 2 Cosmos' started by AIAndy, Jan 20, 2012.

  1. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    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.
     
  2. BlueGenie

    BlueGenie Emperor

    Joined:
    Apr 23, 2009
    Messages:
    1,575
    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
     
  3. ls612

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,072
    Location:
    America
    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.
     
  4. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    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.
     
  5. ls612

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,072
    Location:
    America
    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.
     
  6. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    Post the XML and test case and I have a look at what it does and what it should have done tomorrow evening.
     
  7. ls612

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,072
    Location:
    America
    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.
     
  8. DRJ

    DRJ Hedonist

    Joined:
    Dec 1, 2005
    Messages:
    1,514
    Location:
    Hamburg, Germany
    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.
     
  9. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    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.
     
  10. Hydromancerx

    Hydromancerx C2C Modder

    Joined:
    Feb 27, 2008
    Messages:
    16,281
    Location:
    California, USA
    In general it would be nice to have weather besides the sea storms or random events.
     
  11. Hanny

    Hanny Prince

    Joined:
    Sep 3, 2007
    Messages:
    343
    Location:
    IOW UK
    Erebus continent map script has enough of that, for tile plots and resources/major river because of water table, and is C2C compatable.
     
  12. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    Most map scripts have something like that, but the current interfaces do not provide it and it is not in the same format.
     
  13. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    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.
     
  14. ls612

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,072
    Location:
    America
    All this is now on the SVN.
     
  15. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,540
    Gender:
    Male
    Location:
    Canberra, Australia
    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. ;)
     
  16. AIAndy

    AIAndy Deity

    Joined:
    Jun 8, 2011
    Messages:
    3,419
    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
     
  17. Koshling

    Koshling Vorlon

    Joined:
    Apr 11, 2011
    Messages:
    9,254
    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:
     
  18. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,540
    Gender:
    Male
    Location:
    Canberra, Australia
    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.;)
     
  19. Koshling

    Koshling Vorlon

    Joined:
    Apr 11, 2011
    Messages:
    9,254
    The Conway function reference was a joke. Ignore me - I was in a funny mood.:rolleyes:
     
  20. DRJ

    DRJ Hedonist

    Joined:
    Dec 1, 2005
    Messages:
    1,514
    Location:
    Hamburg, Germany
    Hey Sheldon, next Big Bang Theory up tonight ;)
     

Share This Page