Page 1 of 1

OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Fri Jul 19, 2024 6:13 pm
by Corbeau
The requirement vectors in one effect are connected with AND operator: they all have to be fulfilled for the effect to have effect. However, it isn't possible to combine them in a way that the effect is active if ANY of them is fulfilled. It was possible to do while the nreq field was active, but since nreq is deprecated, it isn't possible anymore.

Having the OR operator (or returning the nreqs) would simplify some things and also make possible stuff that is impossible right now. Right now, if I want to do a simple OR requirement, I have to write down a separate effect for each requirement. Also, implementing the OR (or returning nreqs) would make it possible for building and unit requirements, too, which are now limited to only one "effect".

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Sat Jul 20, 2024 6:33 pm
by Ignatus
It was theoretically NOT possible with nreqs to make an OR-vector sich that you can't achieve an equivalent effect in reqs (provided that you don't bump into vector length limit):

!(a || b || c) <=> !a && !b && !c

If I recall it right, nreqs are innerly stored in reqs since the version when individual req negation was implemented.

For the building or unit problem, a long while ago city-performed action concept was proposed, when you can have multiple enablers for "Build Unit" or "Build Improvement" actions.

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Sat Jul 20, 2024 6:53 pm
by Corbeau
Ignatus wrote: Sat Jul 20, 2024 6:33 pm It was theoretically NOT possible with nreqs to make an OR-vector sich that you can't achieve an equivalent effect in reqs
I don't understand what this sentence means.

Also, I'm not sure what exactly <=> means.

a OR b OR c

is equal to

NOT ( NOT a AND NOT b AND NOT c)

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Sat Jul 20, 2024 9:50 pm
by Ignatus
Corbeau wrote: Sat Jul 20, 2024 6:53 pm
Ignatus wrote: Sat Jul 20, 2024 6:33 pm It was theoretically NOT possible with nreqs to make an OR-vector sich that you can't achieve an equivalent effect in reqs
I don't understand what this sentence means.

Also, I'm not sure what exactly <=> means.

a OR b OR c

is equal to

NOT ( NOT a AND NOT b AND NOT c)
I mean that you have lost actually nothing without nreqs. For example, if a building can be built if the city is on Tundra or on Forest, how can nreqs help you? <=> I mean logical equivalence, yes.

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Sun Jul 21, 2024 11:15 am
by Corbeau
Ignatus wrote: Sat Jul 20, 2024 9:50 pm I mean that you have lost actually nothing without nreqs. For example, if a building can be built if the city is on Tundra or on Forest, how can nreqs help you?

Code: Select all

nreqs = {"type", "name", "range", "present"
         "Terrain", "Tundra", "Local", FALSE
         "Terrain", "Forest", "Local", FALSE
}
Or, if there is another way to do it, please let me know.

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Sun Jul 21, 2024 12:24 pm
by Ignatus
Corbeau wrote: Sun Jul 21, 2024 11:15 am

Code: Select all

nreqs = {"type", "name", "range", "present"
         "Terrain", "Tundra", "Local", FALSE
         "Terrain", "Forest", "Local", FALSE
}
Won't work. On Forest, the 1st nreq fires, on Tundra, the 2nd. To get ORed reqs, you need either a positive OR-vector or a negative AND-vector. nreqs is a negative OR-vector, thus it does basically the same operation as reqs. You can't fight Boolean arithmetics.

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Sun Jul 21, 2024 1:16 pm
by Corbeau
Wait, you mean in reqs the relation is AND, while in nreqs the relation is OR? Reqs block is YES only of ALL conditions are satisfied, while the whole nreqs block ends up as YES (turning the whole effect into NO) if ANY condition is satisfied?

Re: OR condition for requirement vectors (was possible with nreqs, but not any more)

Posted: Mon Jul 22, 2024 5:58 am
by Ignatus
Yes. I too once wanted to make OR reqs but looked into the code and understood it won't work.