Wanted: Hard action requirements that could be made obligatory

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

Wanted: Hard action requirements that could be made obligatory

Postby sveinung » Mon Feb 22, 2021 8:19 pm

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.