New Fuel Settings?

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Message
Author
User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: New Fuel Settings?

#31 Post by alleryn »

Geoff the Medio wrote: Mon Oct 14, 2019 8:15 am
I can't seem to find where the hull->Speed(), hull->Fuel(), etc stuff is coming from in the code.
What do you mean by "stuff" and "coming from in the code"?
I can find a lot of places hull_type->Fuel() gets used (where hull_type is a const HullType*) but when i search for HullType* i'm having difficulty following the thread to where these methods are defined.
Do you mean you can't find the HullType class definition? Or where the code for HullType::Fuel is located? Or where the value that that method returns is determined?
I can't find where the code for HullType::Fuel is located or where the value that that method returns is determined.


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

Re: New Fuel Settings?

#33 Post by Ophiuchus »

Geoff the Medio wrote: Mon Oct 14, 2019 10:46 am Perhaps compromise by doing both the tag check and hull base fuel add-subtract, then?
Hull base fuel add-subtract is ok to me. I suggested that option in the PR discussion, without getting an answer. I also said that in my comment above.

Tag check is unrelated. Not sure where the compromise is.

The main work for hull base fuel add-subtract that is that all but the average fuel efficiency the hulls have to be changed accordingly (can be speed up with bash magic). Anyway I will probably not get around to do that in the next two weeks.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: New Fuel Settings?

#34 Post by alleryn »

Ophiuchus wrote: Mon Oct 14, 2019 7:58 pm The main work for hull base fuel add-subtract that is that all but the average fuel efficiency the hulls have to be changed accordingly (can be speed up with bash magic). Anyway I will probably not get around to do that in the next two weeks.
I can do that, if you like.

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

Re: New Fuel Settings?

#35 Post by Ophiuchus »

alleryn wrote: Mon Oct 14, 2019 8:03 pm
Ophiuchus wrote: Mon Oct 14, 2019 7:58 pm The main work for hull base fuel add-subtract that is that all but the average fuel efficiency the hulls have to be changed accordingly (can be speed up with bash magic). Anyway I will probably not get around to do that in the next two weeks.
I can do that, if you like.
Be my guest
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: New Fuel Settings?

#36 Post by alleryn »

I'll give it a day or two to see if there are any objections to this approach, then i'll go ahead with it.

Done: https://github.com/freeorion/freeorion/pull/2596

Everything looked okay after a skim through Pedia/Hulls in game and adding a fuel tank to a smattering of hulls in the Shipyard.

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: New Fuel Settings?

#37 Post by alleryn »

Looks like there are a number of things to do yet here. I'm confused about some of them, so i'll try to summarize.

Original issue: https://github.com/freeorion/freeorion/ ... -543218868
Pull request thread: https://github.com/freeorion/freeorion/pull/2596 (Pull request changes formula to

effects = SetMaxFuel value = (Value - HullFuel name = ThisHull) * @[email protected] + HullFuel name = ThisHull

and adjusts base fuel values of hulls to compensate.)

What still needs to be done:
  1. Geoff, you said we can put the fuel efficiency into the hull's description text in the stringtable. You are talking about editing each e,g, SH_ROBOTIC_DESC, right?

    The HULL_DESC template we can't use is that correct?

    Code: Select all

    HULL_DESC
    '''[[metertype METER_SPEED]]: %1%
    [[metertype METER_FUEL]]: %2%
    [[metertype METER_STRUCTURE]]: %4%'''
    Requires the C++ code

    https://github.com/freeorion/freeorion/ ... 1363-L1367

    Code: Select all

            detailed_description += UserString(hull->Description()) + "\n\n" + str(FlexibleFormat(UserString("HULL_DESC"))
                % hull->Speed()
                % hull->Fuel()
                % hull->Speed()
                % hull->Structure());
    ? And we "aren't allowed" / "shouldn't" access FOCS from C++ so there's no way to add the fuel efficiency into the HULL_DESC in the stringtable. Is that correct?
  2. Testing replacing Object id = Source.ID with just Source. What exactly am i testing for? How will i know if it breaks?
  3. And I didn't really understand the purpose of the HasTag name = "@[email protected]_FUEL_EFFICIENCY" other than it was a safety check for scripting errors

    You understood the purpose. Only the emphasis on hard-to-catch scripting errors is missing in your description.

    , but could that condition be put into the activation condition of the effectsgroup instead?

    @agrrr3 ?

    As with this PR base fuel is gone, the check is not really helpful anymore. Without base fuel modified by efficiency you only see the discrepancy if you have additional fuel effects and care about those.

    So I would rather put it in the activation condition of another effect writing a sitrep. The feature I am trying to emulate is a fail-fast assert which checks the condition after loading the FOCS files and stops the game from starting - but we do not have such a feature.
    Should i just leave this part to someone else? I don't really understand what to do.
Edit: Edited question 1 a couple of times

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

Re: New Fuel Settings?

#38 Post by Ophiuchus »

alleryn wrote: Sat Oct 19, 2019 11:10 am What still needs to be done:
  1. Geoff, you said we can put the fuel efficiency into the hull's description text in the stringtable. You are talking about editing each e,g, SH_ROBOTIC_DESC, right?
Yes. That is the most simple implementation at this point.
alleryn wrote: Sat Oct 19, 2019 11:10 am The HULL_DESC template we can't use is that correct?

Code: Select all

HULL_DESC
'''[[metertype METER_SPEED]]: %1%
[[metertype METER_FUEL]]: %2%
[[metertype METER_STRUCTURE]]: %4%'''
..? And we "aren't allowed" / "shouldn't" access FOCS from C++ so there's no way to add the fuel efficiency into the HULL_DESC in the stringtable. Is that correct?
I think "aren't allowed" / "shouldn't" does not apply. In my opinion there is only a technical reason, it is currently impossible to do this from FOCS only. You need to change C++ code a bit so this works.

I think it would be valid to iterate through the hull tags and add sitrep information if you find *_FUEL_EFFICIENCY e.g. UserString("GREAT_FUEL_EFFICIENCY_LABEL" for tag "GREAT_FUEL_EFFICIENCY"). To make this work there needs an intermediate decision though:

hardcoding looking for fuel efficiency tags in c++ would allow to write stringtable entry like (This implementation we probably do not want):

Code: Select all

HULL_DESC
'''[[metertype METER_SPEED]]: %1%
[[metertype METER_FUEL]]: %2%
[[metertype METER_STRUCTURE]]: %4%
Fuel Efficiency: %5%'''

or

looking for generic tag information in c++ and pass a list of looked up descriptions would allow to write stringtable entry like (this may be good enough)

Code: Select all

HULL_DESC
'''[[metertype METER_SPEED]]: %1%
[[metertype METER_FUEL]]: %2%
[[metertype METER_STRUCTURE]]: %4%
Additional Features: %5%'''
or

looking for dynamic, specific tag information in c++ as given in FOCS would allow to write stringtable entry like (we want probably something like this)

Code: Select all

HULL_DESC
'''[[metertype METER_SPEED]]: %1%
[[metertype METER_FUEL]]: %2%
[[metertype METER_STRUCTURE]]: %4%
Fuel Efficiency: [[tag *_FUEL_EFFICIENCY %TAG%_LABEL]]'''
Something like this needs quite some work though (adapting parser, adding the function, and not at least finding a suitable syntax).
So thats why adding the fuel efficiency manually to the hulls is considered KISS at this point.
alleryn wrote: Sat Oct 19, 2019 11:10 am Testing replacing Object id = Source.ID with just Source. What exactly am i testing for? How will i know if it breaks?

...
HasTag name = "@[email protected]_FUEL_EFFICIENCY" ... safety check for scripting errors
Should i just leave this part to someone else? I don't really understand what to do.
Had a look again at the FOCS code, it still makes sense without applying fuel efficiency to hull/base fuel. The idea is that if the right fuel efficiency tag is missing, the ship max fuel gets set to zero so you see something is wrong. Without this the AI will miscalculate without us noticing.

Moving the guard to the activation condition does not suffice - the hull would show the base fuel instead of zero fuel.

The theory is that if you replace "Object id = Source.ID" with "Source" it should behave exactly the same.
You could test it by putting a wrong _FUEL_EFFICIENCY tag on a hull - the ship should always have zero fuel.


In your list of TODOs one is missing: rewrite FUEL_REFUEL_EFFICIENCY_TEXT and METER_FUEL_VALUE_DESC so it fits the calculation (fuel efficiency only applies to additional fuel effects like fuel tanks, species modifiers, metabolism tech)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: New Fuel Settings?

#39 Post by alleryn »

Ophiuchus wrote: Sun Oct 20, 2019 2:23 pm The theory is that if you replace "Object id = Source.ID" with "Source" it should behave exactly the same.
You could test it by putting a wrong _FUEL_EFFICIENCY tag on a hull - the ship should always have zero fuel.
I guess i just don't understand the difference between these two statements. What is it sufficient (or at least 'reasonably sufficient') to test to ensure that this doesn't break anything? Is verifying that the fuel values are displaying correctly in the pedia enough, or are there other things likely to break?

Also the suggestion is referring only to the "Object id = Source.id" in HULL_FUEL_EFFICIENCY_EFFECTSGROUP, right? (There are also similar tags in other ship_hulls.macros, namely Object id = Source.FleetID in UNOWNED_MOVE and Object id = Source.SystemID in REFUEL_MESSAGE.

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

Re: New Fuel Settings?

#40 Post by Geoff the Medio »

alleryn wrote: Mon Oct 21, 2019 1:44 pmI guess i just don't understand the difference between these two statements. What is it sufficient (or at least 'reasonably sufficient') to test to ensure that this doesn't break anything? Is verifying that the fuel values are displaying correctly in the pedia enough, or are there other things likely to break?
The Source version is simpler and possibly slightly (but insignificantly) faster. Just testing that the effects still do the same thing is a sufficient test.
Also the suggestion is referring only to the "Object id = Source.id" in HULL_FUEL_EFFICIENCY_EFFECTSGROUP, right? (There are also similar tags in other ship_hulls.macros, namely Object id = Source.FleetID in UNOWNED_MOVE and Object id = Source.SystemID in REFUEL_MESSAGE.
Those aren't checking that an object is the source; they are checking if an object is the source's system or fleet. The Source condition just works to replace Object id = Source.id.

User avatar
Oberlus
Cosmic Dragon
Posts: 2937
Joined: Mon Apr 10, 2017 4:25 pm

Re: New Fuel Settings?

#41 Post by Oberlus »

Should a 200% fuel efficiency hull have twice it's standard fuel?
Check out attached screenshot. The symbiotic hull has 2.0 + 0.0 from 200% fuel efficiency. Seems counter-intuitive. Or is this a bug?
Attachments
fuel_efficiency.png
fuel_efficiency.png (399.37 KiB) Viewed 523 times

User avatar
alleryn
Space Dragon
Posts: 259
Joined: Sun Nov 19, 2017 6:32 pm

Re: New Fuel Settings?

#42 Post by alleryn »

Oberlus wrote: Sat Nov 02, 2019 9:14 pm Should a 200% fuel efficiency hull have twice it's standard fuel?
Check out attached screenshot. The symbiotic hull has 2.0 + 0.0 from 200% fuel efficiency. Seems counter-intuitive. Or is this a bug?
This looks like the result of the change i made to try to fix the Pedia in https://github.com/freeorion/freeorion/pull/2596. Basically the old fuel efficiency modifier only affects fuel parts now. It no longer affects hull fuel. Instead the base hull fuel values were all manually adjusted. (E.g. the base fuel of the scout was 2, with 400% fuel efficiency. Now the scout has 8 base fuel.)

The base fuel of the symbiotic hull before the change was 1. So you are seeing twice the (old) base fuel.

The +0.0 being reported in the fuel meter is an unintended consequence.

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

Re: New Fuel Settings?

#43 Post by Ophiuchus »

alleryn wrote: Sat Nov 02, 2019 10:19 pm The +0.0 being reported in the fuel meter is an unintended consequence.
Probably we can skip the effect if there are no fuel effects. Somebody please open an (UI) issue.

Anybody knows if we can move base hull fuel effect to be after fuel efficiency effect?
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Oberlus
Cosmic Dragon
Posts: 2937
Joined: Mon Apr 10, 2017 4:25 pm

Re: New Fuel Settings?

#44 Post by Oberlus »

Thank you for the answers.
alleryn wrote: Sat Nov 02, 2019 10:19 pmThe base fuel of the symbiotic hull before the change was 1.
Before fuel efficiency was introduced, syb. hull had 2 fuel (actually, there were no hulls with less than 2 fuel). I'm wondering. Is it the point of giving the hull less base fuel as well as good fuel efficiency to make fuel tanks more relevant or something. That could make sense, but it is a problem for me in this case because the symbiotic hull only has two internal slots, so I can't have appropriate stealth as well as fuel reach on a symbiotic coloniser.
Well, not a real problem, now I realise the hull I should be using for this is the Protoplasmic (3 internal slots, plus +10 stealth).

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

Re: New Fuel Settings?

#45 Post by Ophiuchus »

Oberlus wrote: Sun Nov 03, 2019 12:18 pm Thank you for the answers.
alleryn wrote: Sat Nov 02, 2019 10:19 pmThe base fuel of the symbiotic hull before the change was 1.
Before fuel efficiency was introduced, syb. hull had 2 fuel (actually, there were no hulls with less than 2 fuel).
I know this is a bit confusing. We have four levels of fuel efficiency and the average fuel efficiency should be 100% for consistency. As a rule of thumb the small hull(s) are great efficiency, many of the hulls are "medium sized" which translates now to good fuel efficiency (fluff: that is what military uses, civilian ships usually have average fuel efficiency), so the large hulls are average efficiency and the huge ones are bad efficiency.

So symb. hull has effective fuel 2 as "always". Fuel tank without extra research also gives 1 fuel on a good efficiency hull as it was. So the symbiotic hull is like it was.


Anybody knows if we can move base hull fuel effect to be after fuel efficiency effect?
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

Post Reply