RFC: A single source for default values (FOCS, python, stringtables, backend)

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.

Moderators: Oberlus, Oberlus

Post Reply
Message
Author
Ophiuchus
Programmer
Posts: 1096
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

RFC: A single source for default values (FOCS, python, stringtables, backend)

#1 Post by Ophiuchus » Sat Nov 16, 2019 9:51 am

How about we add a file (or files in directory tree) for having a single source of default game values so FOCS, AI, stringtables and backend can use it.

At the moment we often have to replicate values manually in all those places and keep consistent. For example i think many values in languages other than french and english are wrong or not even mentioned because we fear they could change. Also AI could rely on outdated values.

If we have a single place to take those values from the values are always "auto-magically" consistent.

That file format should only contain key/value pairs and could be put into files default/default.values or e.g. default/scripting/ship_hulls/ship_hulls.values.

The mechanism which comes closest are game rules, but i think it is UI-overkill to add a rule for each base value which might change in development.
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.

o01eg
Programmer
Posts: 626
Joined: Sat Dec 10, 2011 5:46 am

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#2 Post by o01eg » Sat Nov 16, 2019 11:35 am

Gentoo Linux x64, gcc-9.2, boost-1.72.0
Ubuntu Server 18.04 x64, gcc-7.4, boost-1.65.1
Welcome to slow multiplayer game at freeorion-lt.dedyn.io. Version 2020-01-26.adf31db 0.4.9 RC2.
Donates are welcome: BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK

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

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#3 Post by Oberlus » Sat Nov 16, 2019 11:50 am

o01eg wrote:
Sat Nov 16, 2019 11:35 am
What about https://freeorion.org/forum/viewtopic.php?f=9&t=10215 ?
I'm totally in favor of that. For all the reasons listed there, and because I still don't understand the syntax of FOCS. Wiki and the such are helpful but not enough, at all, there is always places were all you (non FOC-expert) can do is trial and error until Geoff or someone else comes in rescue. If I have to learn a new language, Python would be more interesting than FOCS.

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

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#4 Post by Geoff the Medio » Sat Nov 16, 2019 1:52 pm

Oberlus wrote:
Sat Nov 16, 2019 11:50 am
...because I still don't understand the syntax of FOCS. Wiki and the such are helpful but not enough, at all, there is always places were all you (non FOC-expert) can do is trial and error until Geoff or someone else comes in rescue. If I have to learn a new language, Python would be more interesting than FOCS.
I don't think replacing FOCS with Python-parsed structs would help much with needing help or learning Python in general. The hard-to-learn domain-specific issues of what stuff can be scripted wouldn't change, and very little Python code would be involved, as the "scripting" would still be mostly declarative definitions of parts, techs, species and such with their contained effects, conditions, and valuerefs. There may be advantages to Python-declared scripting vs. Boost-parsed scripting, but those aren't. (See the example in the linked post.)
Ophiuchus wrote:
Sat Nov 16, 2019 9:51 am
...single source of default game values so FOCS, AI, stringtables and backend can use it.
What default values are you referring to?

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

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#5 Post by Oberlus » Sat Nov 16, 2019 2:07 pm

Geoff the Medio wrote:
Sat Nov 16, 2019 1:52 pm
What default values are you referring to?
Any value you can find in a FOCS file, like the base structure of a hull, the boost to a meter from a tech/building, etc.

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

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#6 Post by Geoff the Medio » Sat Nov 16, 2019 2:45 pm

The issue in that case doesn't depend on what scripting language is used; switching to Python won't change anything.

What you want is either:
1) A way to look up a scripted value in another script, in a stringtable entry, or in the AI code
or
2) A way to define those values in a single place and reference the defined value in any of

(2) would could be awkward to use for things like part costs or hull structure, as it would essentially mean having a big table, or many small tables, of macro definitions, which can be inserted / referenced like normal stringtable or script macros into scripts or stringtables, rather than putting those values into the scripts themselves. This would mean the values wouldn't be defined where the content that uses them is defined. This can already be done, however, as you can #include files into other stringtable or FOCS files, and both can use macros lookups by [[KEY]].

(1) would require a way to look up scripted values by writing a little script to do so, and be able to do so within stringtable macros. It's already possible for some things in FOCS, like using the HullStructure complex value ref and passing the name of the hull ( https://github.com/freeorion/freeorion/ ... er.cpp#L47 ). But there's no way to write an equivalent FOCS script into a stringtable macro though, and have it be evaluated at runtime, and it would be a bit of work to allow it. Notably, it would be a run-time / lazy lookup, so that it can look up the data in the current game using the currently-applicable parsed content, which could change if the resources directory is changed or a game's rules are changed. Something similar is already done by having various parameters in stringtables like %1% which are replaced when the string is rendered in-game, based on the C++ code expecting a particular stringtable entry to have %1% and similar fields in it to be replaced. Scripting those substitutions in the stringtable entry itself would be more complicated and require some additional coding to support, but shouldn't be impossible... maybe something like:

[[FOCSVAL HullStructure name = "SH_COLONY_BASE"]]

Which would be replaced by whatever the stucture is of the colony base hull in the current game, evaluated when the string is being rendered.

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

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#7 Post by Oberlus » Sat Nov 16, 2019 5:10 pm

Geoff the Medio wrote:
Sat Nov 16, 2019 2:45 pm
The issue in that case doesn't depend on what scripting language is used; switching to Python won't change anything.
Indeed. My issues with FOCS syntax and preference for Python were properly addressed with your previous post :)

2) A way to define those values in a single place and reference the defined value in any of
(2) would could be awkward to use for things like part costs or hull structure, as it would essentially mean having a big table, or many small tables, of macro definitions, which can be inserted / referenced like normal stringtable or script macros into scripts or stringtables, rather than putting those values into the scripts themselves. This would mean the values wouldn't be defined where the content that uses them is defined. This can already be done, however, as you can #include files into other stringtable or FOCS files, and both can use macros lookups by [[KEY]].
I think that's what I'd prefer.

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

Re: RFC: A single source for default values (FOCS, python, stringtables, backend)

#8 Post by Ophiuchus » Tue Nov 19, 2019 9:04 pm

Geoff the Medio wrote:
Sat Nov 16, 2019 2:45 pm
1) A way to look up a scripted value in another script, in a stringtable entry, or in the AI code
or
2) A way to define those values in a single place and reference the defined value in any of

(2) would could be awkward to use for things like part costs or hull structure, as it would essentially mean having a big table, or many small tables, of macro definitions, which can be inserted / referenced like normal stringtable or script macros into scripts or stringtables, rather than putting those values into the scripts themselves. This would mean the values wouldn't be defined where the content that uses them is defined. This can already be done, however, as you can #include files into other stringtable or FOCS files, and both can use macros lookups by [[KEY]].
A combination of both approaches would be best in my opinion. But standard things like part costs, hull structure etc are well enough addressed as you can simply experiment in the ship designer and have a look at the results and also the AI has access to such values.

So what is more pressing are things like organic hull growth effects and similar for which approach 2) is probably enough.
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.

Post Reply