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…
Please help!
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.
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?
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
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
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.
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:
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.
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…
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?
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.