Wanted: Hard action requirements that could be made obligatory

Do you want to help out with Freeciv development? Then check out this forum.
Post Reply
sveinung
Elite
Posts: 548
Joined: Wed Feb 20, 2013 4:50 pm

Wanted: Hard action requirements that could be made obligatory

Post by sveinung »

Note: This thread is only about low hanging fruit. It is not about introducing new requirement types or about changing the obligatory hard requirement system.

If you don't already know the words used in the post title skip this paragraph and the next and get back to it after reading the rest.
Hard requirements that could be made obligatory may have been overlooked while making new actions enabler controlled. A hard requirement that can be fully expressed in its enabler's requirement vectors should be added to non data file format frozen versions of Freeciv. If you discover one let me know here or - even better - file an issue. A patch is even more appreciated. If only parts of a hard requirement can be expressed in a requirement vector but you have a reason why it should be made obligatory - like broken reasoning code - it could still be added.

The obligatory hard action requirement system is expressed logically like this: "(A or B or C) and (D or E) and (F)", where each letter represents a single requirement to actor or target reqs all enablers must contradict. (A and B) or (C and D)" is not currently (February 2021) possible.

For those that didn't understand what was said above
Actions is Freeciv will often have requirements that must be fulfilled to make it possible to perform the action. These are called hard requirements. Hard requirement can be there because of limitations in the Freeciv code or because no one has suggested a sane use of their absence. Some, but not all, hard requirements can be expressed in an action enabler. Putting them there makes it clearer to both human readers and to code that reasons about the rules what the rules actually are.

Freeciv - staring with Freeciv version 3.0 - can require an action enabler to include certain hard requirements of the action it enables. This is called an obligatory hard requirement. Not all hard requirements are obligatory. Some can't be expressed in a requirement vector of an action with the specified (actor kind and) target kind. Some can be expressed but only partially. Others can be expressed but no one has added them yet.

Making a hard action requirement obligatory has 3 classes of benefits.
  • It makes it easier for developers to write code than reasons about if an action is enabled. There is no need for custom code for action specific hard requirements when they are expressed in the requirement vector. This makes the life of developers easier and provides more and less buggy features to the users.
  • It helps ruleset authors find out that their action enabler doesn't work and why it is broken. It is easy to forget about a hard requirement for the enabled action when writing an action enabler. It may therefore end up contradicting the enabled action's hard requirement so it never will work. Having to include the action's hard requirements in the enablers makes these bugs easier to spot. It also makes it possible for tools to automatically find the problem.
  • It makes the hard requirement more visible, increasing its chance of someone taking care of the issues keeping it a hard requirement so it can be dropped.
Go here if you want a hard requirement dropped.
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: Wanted: Hard action requirements that could be made obligatory

Post by bard »

Every time I start modding a new version of freeciv, I read the whole topic "Changes in what a 3.x ruleset can do", and the wiki "How to update a ruleset from 3.x to 3.y". They are very useful.

I recently ported my custom ruleset from 2.6 to 3.0 and the guide works like a charm. The only tricky part for me was to get animals working because freeciv launched the error:
"All action enablers for Conquer City must require a non animal player actor".
These kind of warnings are also very useful for ruleset editors, but it was not that easy to understand that I needed to add something like this as req for all action = "Conquer City":

action = "Conquer City"
actor_reqs =
{ "type", "name", "range", "present"
"Nation", "Animal Kingdom", "Player", FALSE
}

I think it could help future modders if this requirement was added by default to the rulesets.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Wanted: Hard action requirements that could be made obligatory

Post by cazfi »

bard wrote:Every time I start modding a new version of freeciv, I read the whole topic "Changes in what a 3.x ruleset can do", and the wiki "How to update a ruleset from 3.x to 3.y". They are very useful.

I recently ported my custom ruleset from 2.6 to 3.0 and the guide works like a charm. The only tricky part for me was to get animals working because freeciv launched the error:
"All action enablers for Conquer City must require a non animal player actor".
Even when you prefer doing the update manually (for better formatted ruleset, preserving your comments etc), you may do parallel update with freeciv-ruleup, so you can check, for reference, how it updated certain part of the ruleset.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Wanted: Hard action requirements that could be made obligatory

Post by Ignatus »

cazfi wrote:Even when you prefer doing the update manually (for better formatted ruleset, preserving your comments etc), you may do parallel update with freeciv-ruleup, so you can check, for reference, how it updated certain part of the ruleset.
Two-column view ruleup *_*
bard
Veteran
Posts: 121
Joined: Fri Jun 14, 2013 2:00 pm

Re: Wanted: Hard action requirements that could be made obligatory

Post by bard »

cazfi wrote:Even when you prefer doing the update manually (for better formatted ruleset, preserving your comments etc), you may do parallel update with freeciv-ruleup, so you can check, for reference, how it updated certain part of the ruleset.
Nice feature, I didn't know that ruledit tool was able to automatically update a ruleset, thank you for pointing it.

I like to update the ruleset manually, checking the changes side by side, because it allows to understand better what was changed, and to notice the new features, but this ruleup feature is pretty useful too.

The output format is not very useful to compare to the original version, but I have found it is possible to compare properly the changes:
1) save the ruleset (for v2.6) with ruledit v2.6
2) open the ruleset (for v2.6) with ruledit v3.0, and save it so it is automatically updated
3) compare side by side both versions that share similar format, to check exactly what was changed from v2.6 to v3.0.

I have noticed the Animal Kingdom requirement that we were talking about is automatically added this way. Good reference for future updates.
Post Reply