Wow incredible stuff! keep up the good work!
If you know of any contraption that uses the expression gate that isn't listed here, point me to it and I will add it!
I'm not currently finished with this, but it's currently a working concept as to that it can run outside of GMod.
So what it is?
It's basically your average calculator, takes an expression and outputs the answer. An even better answer would be:
What turns [attachment=66:mess.JPG] into [attachment=67:less.JPG] .
So as you can see, instead of connecting several components, one (or a few) component now does the same thing, so in a sense it makes the current gates obsolete as all functionality provided by them is provided by this, so to create an "add gate" you would simply type "OA = A + B" (specifics will change). And it is furiously fast, current benchmarks on my computer can calculate a pretty large expression more than 100 000 per second (will most likely be more than 1 000 000 per second when complete). So it will also be a valuable tool to minimize lag, and to easily create more advanced setups without making mistakes.
It also incorporates logic, functions and simple constructs for conditionals.
So for instance you could write "A > 3 ? OB = 2" which would set output B to 2 if A is greater than 3 (otherwise unchanged). Further on, this can be expanded to "A > 3 ? OB = 2, OC = ((A > 4 && A < 5) ? 4 : 5)" this would do the same as above, but also set output C to 4 if C is between 4 and 5, otherwise 5. Or it could be just simple calculations "OA = 4 + 5 * A / B - log© ^ 2". You can also assign to arbitrary variables that can be used to clean up expressions and reuse calculations.
The intention is to allow multiple lines, as the CPU, so that expressions can be split up into many rows and allow for advanced calculations, currently 8 inports and 8 outports. So the integrated circuit some has been talking about may very well be this, as it allows to incorporate very advanced functions into a few inports and outports, without lagging the server.
But as you might have understood there is no finished addon yet, but I'm creating this thread in order to hear your thoughts and suggestions on this. Currently it will work pretty much as Luas expressions, +-*/% ... == > < ! ... && || ... and also ?: (conditional), and calling functions of course. I've had thoughts of having internal memory as well so that you could load and store to it, although I'm not quite sure how to best do it at the moment. As earlier said, at the moment it parser parses most expressions and correctly evaluates them. This addon should be available pretty soon.
Note: It does NOT evaluate the expressions using Lua, it uses my own parser. Although it will very certainly convert the expressions into Lua later on and then evaluate it, as it is a factor of ~10-20 faster and it is safe and there is no real drawback.
I will update this post when more information is available.[/b]
Crap i've been working on the same thing. How are you implementing it? Mine parses the equation to turn it from infix to postfix (RPN) notation as the entity is created or re-setup. Then on the trigger input function it parses the postfix equation, replaces the inputs 'A', 'B' etc with their actual values, solves the equation and writes the outputs.
I started trying to do it without postfix but it seemed like it would be much harder to implement new functions, and would be inherently much slower.
What method are you using to parse things like this "A > 3 ? OB = 2" in realtime?
"And it is furiously fast, current benchmarks on my computer can calculate a pretty large expression more than 100 000 per second" if u've been testing stuff in C other compiled language, it will be much much faster than lua in GMod as you have source engine using most of the resources, and lua is interpreted, not compiled.
How far into yours are you?
-----------------------------------------------
gmod addon reviews:
[url="http://gmodreviews.googlepages.com/"]http://gmodreviews.googlepages.com/[/url]
I'm using a recursive descent parser for mine (similar to compilers), works quite well, and it also allows me to extend it beyond mathematical terms if I would wish to, e.g. to make a language out of it (as the constructs you saw). So I'm using BNF grammars to parse it all, which are now complete too...Crap i've been working on the same thing. How are you implementing it? Mine parses the equation to turn it from infix to postfix (RPN) notation as the entity is created or re-setup. Then on the trigger input function it parses the postfix equation, replaces the inputs 'A', 'B' etc with their actual values, solves the equation and writes the outputs.
I started trying to do it without postfix but it seemed like it would be much harder to implement new functions, and would be inherently much slower.
What method are you using to parse things like this "A > 3 ? OB = 2" in realtime?
"And it is furiously fast, current benchmarks on my computer can calculate a pretty large expression more than 100 000 per second" if u've been testing stuff in C other compiled language, it will be much much faster than lua in GMod as you have source engine using most of the resources, and lua is interpreted, not compiled.
How far into yours are you?[/b]
What I'm doing is basically parsing it all (very quickly) and then create an internal representation (as compilers do), {add, {num, 1}, {num, 1}} kinda like that, and then it is extremely simple and fast to calculate it over and over again.
I'm basically finished now, it parses and calculates everything correctly, I'm just working on a final construct allowing for something that works likes nested if-statements. What's needs to be done is proper error handling and of course integration into the game which might take a while since I've never done it before.
And I didn't mean that I was testing it in another language, I'm runnnig my code in lua, but in their "lua interpreter" and not inside the game, but they are basically the same. Just that this can be run outside of the game.
EDIT: the special construct is done now, so it now allows you to write:
A > 2 -> B -> C = 1, D = 2;, E = 3; (it's more intuitive on multiple rows)
Which translates into
if( A>2 ) { if( B ) { C=1; D = 2 } E = 3}
Ok your further ahead than me so i'lle leave it to you. I just wanted to check that you knew what you were doing, which you do, as the pre conversion bit is essential for speed.I'm using a recursive descent parser for mine (similar to compilers), works quite well, and it also allows me to extend it beyond mathematical terms if I would wish to, e.g. to make a language out of it (as the constructs you saw). So I'm using BNF grammars to parse it all, which are now complete too...
What I'm doing is basically parsing it all (very quickly) and then create an internal representation (as compilers do), {add, {num, 1}, {num, 1}} kinda like that, and then it is extremely simple and fast to calculate it over and over again.
I'm basically finished now, it parses and calculates everything correctly, I'm just working on a final construct allowing for something that works likes nested if-statements. What's needs to be done is proper error handling and of course integration into the game which might take a while since I've never done it before.
And I didn't mean that I was testing it in another language, I'm runnnig my code in lua, but in their "lua interpreter" and not inside the game, but they are basically the same. Just that this can be run outside of the game.[/b]
If you need and help implementing it into wire give me a shout, i've been working on some template wire scripts but theyre not quite finished yet. i'd be happy to set up all the wire stuff and put in places where you can insert your code, but if you would prefer to do it yourself thats cool.
Did you use stacks for your parser? I couldnt find any native lua support so i wrote a small stack library using tables.
-----------------------------------------------
gmod addon reviews:
[url="http://gmodreviews.googlepages.com/"]http://gmodreviews.googlepages.com/[/url]
Nope, no stacks (except for those introduced internally by recursion of course), that's a neat thing about the recursive descent parser.Ok your further ahead than me so i'lle leave it to you. I just wanted to check that you knew what you were doing, which you do, as the pre conversion bit is essential for speed.
If you need and help implementing it into wire give me a shout, i've been working on some template wire scripts but theyre not quite finished yet. i'd be happy to set up all the wire stuff and put in places where you can insert your code, but if you would prefer to do it yourself thats cool.
Did you use stacks for your parser? I couldnt find any native lua support so i wrote a small stack library using tables.[/b]
Regarding the help, it's greatly appreciated and I'll keep it in mind.
If you guys get this to work, it should solve a lot of problems.
How are you going to handle what the inputs and outputs of the compacted circuit will be? We could add special gates like Identity for that.
"Our death ray doesn't seem to be working. I'm standing right in it, and I'm not dead yet." - Jamie Hyneman
"Yes, managing the anonymous activity of the entire Internet is a challenge. Shoving the entire universe into a mason jar for use as a personal flashlight would also be a pesky bother." - Karl, BBR
WIREMOD WILL NOT WORK ON YOUR FACE! BUT IT DOES ON YOUR MOM
TAD you probably misunderstood what he is doing. From what I understand this is another programmable gate so you can write a program for it for example OA = A + B (output a = input a + input b (??)). Actually this won't give us that much of flexibility as current CPU Gate, but for simpler tasks this can be helpful anyway (some tasks won't require writing a complicated assembler code).If you guys get this to work, it should solve a lot of problems.
How are you going to handle what the inputs and outputs of the compacted circuit will be? We could add special gates like Identity for that.[/b]
Am I right Syranide?
That's correct, basically this adds nothing more than what is already possible. So this is NOT the circuit board discussed in other topics, although it is rougly the same idea (I think) this one is all mathematical. So, all this can do is calculate expressions, such as "OA = B + C" and handle simple conditionals.TAD you probably misunderstood what he is doing. From what I understand this is another programmable gate so you can write a program for it for example OA = A + B (output a = input a + input b (??)). Actually this won't give us that much of flexibility as current CPU Gate, but for simpler tasks this can be helpful anyway (some tasks won't require writing a complicated assembler code).
Am I right Syranide?[/b]
So it does NOT add any new possibilities as everything this can do could previously be done by a pletora of gates (with a small difference, but that's the main idea), with two main ideas, reduce lag and simplify wiring of gates (as instead of wiring different operators to form expressions, you can now just type the expression instead). And then I extended it a little, introduced "if-statements" and allowed multiple out-ports and arbitrary variables (internally), so you can write many expressions for one component (ANG = A / C ... OB = ANG * 2 ... OD = rad2deg(ANG)).
And yes, the CPU can do exactly what this can do and much more, but this offers much more simplicity when there is only need for calculations (and many will likely never learn to use the CPU).
TAD2020, I'm not sure if this is what you thought of or if you though of something else, but please explain what your idea/thought was if possible.
Bookmarks