# This is to discuss how to make a boolean expression interpreter.

A boolean expression is an expression that operates on true/false values using AND, OR, and NOT operations. This would be useful because we could program the game to do more dynamic things and to change its own code, leading to a better play experience. It would also be the first step for parametric 3D rendering.

We would first need something for true recursion, in which you use functions, and the arguments for the functions are saved. In addition, each call must wait until the next call is finished.

To do this, we could have a set of properties to store the arguments, but this would make a cap for the amount of recursive calls allowedâ€¦

# EDIT: I should probably clarify that I want to handle any possible boolean expression, and that it needs to be interpreted from a string of text.

10 Likes

Wait what? I though GKC had boolean expressions. . . Wait is this to make the AND/OR stuff or something more complex?

Well, you canâ€™t account for EVERY boolean expression possible without some sort of recursive system.

Wait canâ€™t you make AND with
if (condition) {
(tab) if(condition) {action}
}
and OR with
if(condition) {action}
if(condition) {same action as before}
and NOT by reversing the condition?

1 Like

Iâ€™m talking about combined stuff like:

(x AND y) OR (d OR NOT e)

Ok. I have absolutely no idea of what recursion is. . . gotta read the guide

Hmmâ€¦ let me try a chain of ifs to do that

``````if (x) {
(tab here) if (y) {action}
}
if (d) {action}
if (!e (e but reversed)) {action}
``````

So let me explain:
the program checks for x first, and if x is true it will then check for y. If y is true, it must mean that both x and y is true so the AND is done.
If either d or NOT e (which we can get by reversing the condition) is true: that would make the (d OR NOT e) statement true, which makes the entire statement true. This means we can get rid of the parenthesis.

The thing is the action might be run more than once so yeah we kinda need the operators

1 Like

Ooh wait we could make it so that when the action is run it skips everything else by making the booleans false. . .
idk how to do that though

I should probably clarify that I want to handle any possible boolean expression, and that it needs to be interpreted from a string of text.

Ok, then Iâ€™m not advanced enough in gkc to do that

I can help! I just need a better idea on what exactly you need us to figure out
sorry if you already explained it started doing larger coding projects recently need to learn these words

1 Like

Basically, weâ€™re trying to make a system that can interpret boolean expressions coded into text. Iâ€™m trying to make a true recursive system to do this.

1 Like

I think a good first step is to implement basic order of operations, where parentheses are identified and then each parentheses group is computed in the proper order.

As an example:

5 > 7 || ((3 == 3) && (5 <= 7))
Gets broken down into the following steps:

1. (3 == 3)
2. (5 <= 7)
3. (true && true)
4. (5 > 7)
5. false || true
6. true
4 Likes

If we had true recursion, we wouldnâ€™t need order of operations. We would just need to decompile by each side of the operation until we get to the base case where both sides are simple values rather than expressions.

1 Like

sorry if this is stupid, but what what if we made an equation that was constantly â€śtrueâ€ť or â€śfalseâ€ť?
I donâ€™t really know about this, and I just read the title and descâ€¦ so I am probably wrongâ€¦

1 Like

What do you mean by that?

set a variable to a number, then:
If this variable is greater than (any number greater than the number)
do â€ścertain actionâ€ť
this action could work?

2 Likes

I donâ€™t get where this would lead to.

2 Likes

tbh, I thought maybe it would be used as the time between recursionâ€¦

1 Like

Welllâ€¦ itâ€™s not useful if we canâ€™t use parentheses so specify order of operations. Heck, I even used parentheses today in some Boolean operations when I was working on librekit earlier.

My idea though was to recursively find the order to do each operation, make a tree that shows the order to do operations (since some operations have to be computed before others) then just write the code to compute a singular Boolean operation.

1 Like