# SOLVEDIs there a operation that checks multiple variables for an output?

#### Boom

##### Member
To further explain, I want to create a tree of options that checks multiple variables. For example, it checks 3 boolean variables named, a, b, and c.
(true, true, true) would output a number
(true, true, false) would output another number
(true, false, true) would output another different number
(true, false, false) would output another different new number
etc...
Dictionaries, if statements, and switch statements are options but using those it would take exponentially more time to add another variable to check.
So is there an operation that streamlines this?

#### kburkhart84

##### Firehammer Games
The closest I can think of is using binary, and having each one of those be bits of a binary number. So false, false, false would be 000 in binary, 0 in decimal. false, false, true would be 001, 1 in decimal. false, true, false would be 010, 2 in decimal. false, true, true would be 011, 3 in decimal. You can then mask each of those off. Even with this, you are going to still need some branching in order to determine which value it ends up being altogether, but if al lthe different combinations result in different actions, then it could make sense to do it this way instead of doing a bunch of AND stuff to check what the values are. In this manner, you would only have 8 different possible results with 3 values being bit-masked together.

Instead of doing real masking, you could do the same thing by simply adding the right amounts to a variable, where the first true adds 4, the second adds 2, and the third adds one, and then you still check the 8 possible values in a switch.

#### Nidoking

##### Member
If you're going to go as far as converting the booleans to binary, why not go the whole hog and put the options in an array or map, then just use that as an index?

#### kburkhart84

##### Firehammer Games
This is also true, you could use script_execute() and store a few scripts and then just access them that way instead of using a switch statement, and you could still put the thing in binary, even without masking it directly, rather just adding 1, 2, or 4 to the variable, as that's easier sometimes to understand than bit-masking operations.

#### Yal

##### 🐧 *penguin noises*
GMC Elder
Just for the record, GM switch statements are O(1), so you wouldn't lose any performance using a switch statement.

#### Boom

##### Member
If you're going to go as far as converting the booleans to binary, why not go the whole hog and put the options in an array or map, then just use that as an index?
Unless I'm missing something, don't arrays and maps only accept 2 values at a time?

#### Nidoking

##### Member
Unless I'm missing something, don't arrays and maps only accept 2 values at a time?
You're missing something, but I can't identify what it is from the question. Arrays can have any number of values, with a maximum index that would only apply if you were using 15 or more different variables, and there's a maximum number of entries in a map, but it's much higher than two and much, much higher than any system like this is likely to use.