Page 1 of 2

Species trait: Meter bonus/malus

Posted: Tue Sep 15, 2015 1:41 am
by pheonixstorm
Much like the construction tech this could influence the growth rate of a colony and add an extra dimension to certain (current or future) species. For just research and industry is it possible to add this to a species to test it out? I looked over the tech entries but didn't really understand how it is supposed to work.

At present does this only work with whole numbers or can it work with decimals?

Re: Species trait: Meter bonus/malus

Posted: Tue Sep 15, 2015 1:49 am
by MatGB
I don't understand the question? Sorry, I think you're proposing that you could have species that gain points on meters faster (or slower) than the normal.

That would be possible, and yes you could use decimals, it might be horribly unbalanced. Have a look at Force Energy Structures

Code: Select all

Tech
    name = "CON_FRC_ENRG_STRC"
    description = "CON_FRC_ENRG_STRC_DESC"
    short_description = "METER_GROWTH_SHORT_DESC"
    techtype = Application
    category = "CONSTRUCTION_CATEGORY"
    researchcost = 200 * [[TECH_COST_MULTIPLIER]]
    researchturns = 5
    prerequisites = [
        "LRN_FORCE_FIELD"
        "CON_ARCH_PSYCH"
    ]
    effectsgroups = [
        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Industry high = RootCandidate.TargetIndustry - 3
            ]
            effects = SetIndustry value = Value + 2

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Research high = RootCandidate.TargetResearch - 3
            ]
            effects = SetResearch value = Value + 2

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Construction high = RootCandidate.TargetConstruction - 3
            ]
            effects = SetConstruction value = Value + 2

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Industry low = RootCandidate.TargetIndustry - 3 high = RootCandidate.TargetIndustry
            ]
            effects = SetIndustry value = Target.TargetIndustry

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Research low = RootCandidate.TargetResearch - 3 high = RootCandidate.TargetResearch
            ]
            effects = SetResearch value = Target.TargetResearch

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Construction low = RootCandidate.TargetConstruction - 3 high = RootCandidate.TargetConstruction
            ]
            effects = SetConstruction value = Target.TargetConstruction

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Industry low = RootCandidate.TargetIndustry + 5
            ]
            effects = SetIndustry value = Value - 3

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Research low = RootCandidate.TargetResearch + 5
            ]
            effects = SetResearch value = Value - 3

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Construction low = RootCandidate.TargetConstruction + 5
            ]
            effects = SetConstruction value = Value - 3

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Industry low = RootCandidate.TargetIndustry high = RootCandidate.TargetIndustry + 5
            ]
            effects = SetIndustry value = Target.TargetIndustry

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Research low = RootCandidate.TargetResearch high = RootCandidate.TargetResearch + 5
            ]
            effects = SetResearch value = Target.TargetResearch

        EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Construction low = RootCandidate.TargetConstruction high = RootCandidate.TargetConstruction + 5
            ]
            effects = SetConstruction value = Target.TargetConstruction
    ]
    graphic = "icons/tech/force_energy_structures.png"
and work out how to apply it to a specific species, you'd need to create a macro in Species.txt, but keep the initial effect very simple to test, probably just an additional +1.

As an observation, if I am understanding you properly, with the current format this would have the potential to be incredibly unbalanced, you'd probably need to give them actual output maluses to balance the speed.

Re: Species trait: Meter bonus/malus

Posted: Tue Sep 15, 2015 4:17 am
by pheonixstorm
Yes, that was what I was thinking. At a full value (1, 2, etc) as used by Force-Energy Structures it would be very unbalanced. My thoughts were at much much smaller values such as .1 to a maximum of .5 depending on the species. To keep the trait useful but fairly balanced I would think .1 - .3 might work best. For early games having even a +.1 meter growth could mean a lot on getting a new colony world populated or keeping the war effort going (especially if you choose a species with crap piloting).

With a small bonus this should work out to a change from 1.0 growth per turn to 1.1-1.3 if using a decimal correct?

For the following, how would I represent a value of .1 for industry. Change RootCandidate.TargetIndustry - 3 to RootCandidate.TargetIndustry - 1.1 and set Value + 2 to Value + .1? That section has me a little confused. Once I figure out the logic it should be simple to setup and test.

Code: Select all

EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Industry high = RootCandidate.TargetIndustry - 3
            ]
            effects = SetIndustry value = Value + 2

Re: Species trait: Meter bonus/malus

Posted: Tue Sep 15, 2015 4:38 am
by MatGB
That should work as far as I can see.

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 12:32 am
by pheonixstorm
So I think I found the correct names for growth. Does this look about right on how to handle a high birthrate?

Code: Select all

EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Population high = RootCandidate.TargetPopulation + 1.2
            ]
            effects = SetPopulation value = Value + .2
Note: This should NEVER be given to a species with the good population trait w/o also giving a hefty set of negative traits elsewhere such as low industry/research penalty or a slower meter growth in those two sectors.

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 12:48 am
by MatGB
Looks right, give it a few test games.

Re Good Population, the most recent Test game has that trait downpowered significantly because, well, it's been overpowered for ages, still a work in progress.

One issue with the code, population changes differently to a flat +/- 1 per turn anyway, it's determined by your current population and the total possible population (ie bigger populations reproduce more and more habitable planets grow faster) so the rootcandidate numbers are definitely off

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 2:14 am
by pheonixstorm
So suggestions on how to work RootCandidate?

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 3:17 am
by MatGB
To be honest, I don't actually think it'll matter. If an affect takes it over the max it should then go down to the max, so what you've got it at should ensure it always works. Ooh, actually, not at the very low level, if for some reason target population is low (2 or 3) and you've been hit by death spores or similar then having it too high would stop it working. Where to balance that I don't know as it shouldn't really be possible to jump straight to max pop by doubling. Set it to 1 is about right I suspect.

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 3:58 am
by pheonixstorm
perhaps add a check in the bombing effect for a pop growth trait and add an effect to cancel out the trait value? Is it even possible in the current scripting code?

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 4:29 am
by MatGB
Possible, but we don't really want to be adding stuff into weapon parts for specific exception in that way, better to make sure they all work, or put the exception into the trait code (activation not enemy death spores in order, etc).

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 8:39 am
by pheonixstorm
Goofed the first time by using

Code: Select all

EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Population high = RootCandidate.TargetPopulation + 1.2
            ]
            effects = SetPopulation value = Value + .2
instead of

Code: Select all

EffectsGroup
            scope = And [
                ProductionCenter
                OwnedBy empire = Source.Owner
                Population high = RootCandidate.TargetPopulation - 1.2
            ]
            effects = SetPopulation value = Value + .2
In either case it is not working as I had hoped.

Test game, new colony, as of second turn changes the growth went from 2.28 (with reported .20 increase) to 3.33. So actual change for whatever reason ended up being ~1.05 rather than .20 + (trait) .20.

I have been looking over the effects page of the wiki but have not seen much to help me in this case. Though I did spot Population Center (to replace the above Production Center). I also need to find what to set so that all empire species do not take on this trait...

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 11:22 am
by MatGB
scope = source should do that, sorry, yeah, a tech effects all your stuff.

The population growth numbers are hardcoded in the C++ code which I can barely read (I did find the formula once but only just understood it).

There's a chance that priorities might be getting messed up and your increase is applied first, which will change the calculation of the builtin increase as that's based on current pop. But we also know the 'change next turn' estimates aren't very accurate anyway (someone's working on that).

I think basically you're now at the extent of my personal ability to help (I'm good at editing code and saying "it would be better if that number was a 5 not a 6", not actually writing new stuff), but you're heading in teh right direction.

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 5:02 pm
by Dilvish
pheonixstorm wrote:Test game, new colony, as of second turn changes the growth went from 2.28 (with reported .20 increase) to 3.33. So actual change for whatever reason ended up being ~1.05 rather than .20 + (trait) .20.
And just what was your target population when it went from 2.28 to 3.33? It looks to me like those before/after numbers (keeping in mind theat they have some roundoff error) would be spot on if the target population was 36. (Though I'm not sure what's up with whatever you mean by 'reported .20 increase'.)

Any change to Population that you do like this will be applied on each turn *prior* to the built-in population change.

The base calculation for population increase is PopChange = Current * (Target + 1 - Current)/100

So if you're adding some delta (0.2 in the current example) prior to the automatic change, then the end result after both parts is
NewPop = Current + delta + (Current+delta)*(Target + 1 - (Current + delta))/100

Re: Species trait: Meter bonus/malus

Posted: Wed Sep 16, 2015 6:36 pm
by pheonixstorm
The reported .20 increase was what the meter was showing as the change between the current and next turn growth rate. I will get some better numbers when I started playing again in a few. Have to get the kids off the bus shortly.

Re: Species trait: Meter bonus/malus

Posted: Thu Sep 17, 2015 2:24 am
by pheonixstorm
Ok, so I watched one world between turns.

The population jumped by 13 points!
As found from the pop mouseover.
This Turn 26.7
Predicted Next Turn 27.3
Change .61
Target 28.0

I ran the calculations you showed me and got .61 w/o my changes. With my changes (if I followed your second calculation correctly) the change should have been .83

Let me know if this is correct
26.7 x (28 + 1 - 26.7)/100 which would be 61.41/100
26.7 + 0.2 + (26.7 + .0.2) x (28 + 1 - (26.7 + 0.2))/100 which would give me 26.7 + 0.2 + 56.49/100 not 83.39/100

But.. none of it really makes sense since the actual change isn't .83 or 27.4 unless I'm missing something or not doing it right...