One complex EffectsGroup or many simpler?

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer, Oberlus, Committer

Post Reply
Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 1941
Joined: Mon Apr 10, 2017 4:25 pm

One complex EffectsGroup or many simpler?

#1 Post by Oberlus » Thu Feb 13, 2020 9:26 am

While reviewing FOCS changes for PR#2756 I got this doubt:

Are the FOCS scripts in techs, weapon parts, etc., like the one in SHP_FIGHTERS_2.focs.txt, executed every turn?

Could one of these alternatives be faster (require less condition checks) than the other?

One EffectsGroup with a single "scope" for different cases and a single "effects" with conditional effects to distinguish between cases.

Code: Select all

    effectsgroups =
        EffectsGroup
            scope = And [
                Ship
                OwnedBy empire = Source.Owner
                Or [
                    DesignHasPart  name = "FT_HANGAR_1"
                    DesignHasPart  name = "FT_HANGAR_2"
                    DesignHasPart  name = "FT_HANGAR_3"
                ]
            ]
            effects = [
                SetMaxCapacity      partname = "FT_HANGAR_1" value = Value + (PartsInShipDesign name = "FT_HANGAR_1" design = Target.DesignID)
                SetMaxSecondaryStat partname = "FT_HANGAR_2" value = Value + 2
                SetMaxSecondaryStat partname = "FT_HANGAR_3" value = Value + 3
                ]

One EffectsGroup for each scope case, each with a simple "effects":

Code: Select all

    effectsgroups = [
        EffectsGroup
            scope = And [
                Ship
                OwnedBy empire = Source.Owner
                DesignHasPart  name = "FT_HANGAR_1"
            ]
            effects = SetMaxCapacity      partname = "FT_HANGAR_1" value = Value + (PartsInShipDesign name = "FT_HANGAR_1" design = Target.DesignID)

        EffectsGroup
            scope = And [
                Ship
                OwnedBy empire = Source.Owner
                DesignHasPart  name = "FT_HANGAR_2"
            ]
            effects = SetMaxSecondaryStat partname = "FT_HANGAR_2" value = Value + 2

        EffectsGroup
            scope = And [
                Ship
                OwnedBy empire = Source.Owner
                DesignHasPart  name = "FT_HANGAR_3"
            ]
            effects =  SetMaxSecondaryStat partname = "FT_HANGAR_3" value = Value + 3
    ]
The "partname" parameter is always mandatory, right?

(Not sure if this should be here or in Programming.)

Ophiuchus
Programmer
Posts: 1158
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: One complex EffectsGroup or many simpler?

#2 Post by Ophiuchus » Thu Feb 13, 2020 3:11 pm

the target object is the ship. partname is mandatory, it is used to look up the part to which you want to apply the effect.
I think you are right, splitting the application of the effect would make it (neglibly) faster. OTH i am not sure if splitting the condition helps or not.

I guess the change wont matter either way. But if you are intrrigued: measure both implementations against each other (use the logs luke)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12528
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: One complex EffectsGroup or many simpler?

#3 Post by Geoff the Medio » Thu Feb 13, 2020 3:14 pm

I'd guess the multi-effect first example would be a bit faster, as some of the initial filtering doesn't need to be repeated. If attempting to set a part meter that a ship doesn't have generates an error message in the log, that might dominate, though. It might also depend on how many ships would have multiple effects executed on them unnecessarily in the combined case.

But testing to be sure would be best, but qould also probably show minimal difference...

Post Reply