Page 1 of 1

[Not Implemented] "Or" and "And" option for criteria

Posted: Tue Mar 13, 2018 6:06 pm
by mada7
I saw this mentioned in the previous forum but having an option to have separate groupings of criteria so that if I want to have the same dialogue option or event trigger occur under mutually exclusive circumstances I can. As examples Id want to be able to do stuff like this

{criteria 1 AND 2 AND 3}
or
{criteria 4 AND 5 AND 6}

criteria 1
AND
{criteria 2 OR 3}

This can sorta be done currently but requires a lot of clunk modify value manipulations and duplication of work

Re: [Not Implemented] "Or" and "And" option for criteria

Posted: Wed Mar 14, 2018 4:19 am
by peter980
I concur.
Lack of OR this really makes it difficult to do more complex triggers.

.

One of the workarounds I use is to create event which just checks some conditions (AND) and sets the flag at the end.

And then running that event and then checking for negative version of that flag to run some other action is essentially OR condition. But this is really clunky and I would rather avoid using something like this.

Re: [Not Implemented] "Or" and "And" option for criteria

Posted: Wed Mar 14, 2018 9:59 am
by Erock
That's because in programming computers can't really understand (criteria 1 and 2 and 3). Try doing
( A and B ) and (A and C)

So it is possible. But requires only comparing two things at "once"
The problem could be fixed by operator overloading but that requires source code.
I hope that helps.

Re: [Not Implemented] "Or" and "And" option for criteria

Posted: Thu Mar 15, 2018 8:30 pm
by mada7
Erock wrote: Wed Mar 14, 2018 9:59 am That's because in programming computers can't really understand (criteria 1 and 2 and 3). Try doing
( A and B ) and (A and C)

So it is possible. But requires only comparing two things at "once"
The problem could be fixed by operator overloading but that requires source code.
I hope that helps.
That's not correct at all. I've written programs with if(A == 1 && B == 2 && C == 3) both C# and Javascript (the two scripting languages unity supports) support that kind of condition. It's also already currently supported in the game. You can put as many conditions on a trigger or dialogue option as you want

Re: [Not Implemented] "Or" and "And" option for criteria

Posted: Fri Mar 16, 2018 12:24 am
by Erock
mada7 wrote: Thu Mar 15, 2018 8:30 pm
Erock wrote: Wed Mar 14, 2018 9:59 am That's because in programming computers can't really understand (criteria 1 and 2 and 3). Try doing
( A and B ) and (A and C)

So it is possible. But requires only comparing two things at "once"
The problem could be fixed by operator overloading but that requires source code.
I hope that helps.
That's not correct at all. I've written programs with if(A == 1 && B == 2 && C == 3) both C# and Javascript (the two scripting languages unity supports) support that kind of condition. It's also already currently supported in the game. You can put as many conditions on a trigger or dialogue option as you want
I misinterpreted what you meant. Sure that works. I thought you were comparing "objects".

Re: [Not Implemented] "Or" and "And" option for criteria

Posted: Mon Mar 19, 2018 7:06 pm
by eekdon
We can certainly look into making conditions and criteria more graceful. I believe we already have at least one ticket in for cleaning up and adding to such functionality but I will verify and add to it if necessary :D

Re: [Not Implemented] "Or" and "And" option for criteria

Posted: Wed Mar 21, 2018 8:35 am
by Kevner
mada7 wrote: Tue Mar 13, 2018 6:06 pm I saw this mentioned in the previous forum
I think that was me. I remember blarting a thread's worth of going round in circles thinking out loud about logic gates, trying to get a single choice from a possibility of many. When I'm thinking about this stuff it makes more sense to me in electronics terms rather than programming, but the principle is the same.

Thinking about it now, for the OR function, if the context is simple, all you might need is that seperate event that checks it, with two identical event or dialogue triggers inside but with different criteria

1 > Criteria 1 & 2 & 3
2 > Criteria 4 & 5 & 6

Or for the other example

1 > Criteria 1 & 2
2 > Criteria 1 & 3

Either one, or both, will pass if each criteria is met. If you want it more discerning, it starts to get messy.

Logic gates can be done in many combinations to have the same end result, and all gates can be emulated using just NAND gates (Not AND) but that can get complex. This means that since we can use 'does not equal' and similar negative criteria, theoretically problem solved.
The problem with that solution is that you need to have an event or dialogue trigger line for every combination that's possible. Two binary options means four combinations. Four options means 16 combinations.
The simple AND logic is what we have, just having two or more criteria together. To turn this into a NAND gate to do the rest you need separated criteria for 1 yes and 2 no, and 2 yes 1 no (and maybe even 1 no 2 no, and 1 yes 2 yes) feeding into each one.
It takes 3 NAND gates to build an OR choice. It takes 4 NAND gates to build an exclusive OR choice.

If you want to trigger a different dialogue when criteria 1 and 2 are both met, but criteria 3 is not met, or anything similar, it's best laid out a binary truth table. Each line can be whatever event or dialogue trigger you want, the same or different, and each one has three criteria. Binary 0 is negative criteria (does not equal/has not been shown/not in inventory etc.) and binary 1 is naturally positive (has/had/did)

C1 C2 C3
0 0 0 -no criteria are met
0 0 1
0 1 0 - only criteria 2 is met
0 1 1
1 0 0
1 0 1 - criteria 1 and 3 are met, but not 2
1 1 0
1 1 1 - all criteria have been met

You don't need to use every combination, if not triggering any dialogue doesn't make it seem impolite in game context, but otherwise you'd need to do it for each one. Remember, 4 variables is 16 rows. 5 is 32. Nobody wants to go down that path.

However, if you only need a handfull of combinations from 32 (or more!!) and you want a specific dialogue to trigger for the rest of the possibilities, you could have each success option create a value that records a success (equals 1) and then triggers an event that starts the negative/incomplete dialogue with the condition that the success value does not equal 1.

I'm writing all this for my own future reference too, but I hope it helps some others understand things.