Anuken / Mindustry-Suggestions

Repository for Mindustry suggestions and feedback
130 stars 58 forks source link

MLOG eval instruction #4468

Closed kubikaugustyn closed 1 year ago

kubikaugustyn commented 1 year ago

Describe the content or mechanics you are proposing.

Add eval instruction, which will evaluate single instruction (as if it was just another line of code in the background) from an inputs Example: eval "set a ", eval 6282 and evalflush, in background ran as set a 6282

Describe how you think this content will improve the game. If you're proposing new content, mention how it may add more gameplay options or how it will fill a new niche.

Processors are necessary part of many Mindustry servers and singleplayer games. Addition of the ability to evaluate expression would add new possibilities for MLOG programming. I'd recommend some variable amount cap (like 250), so some bad guys don't spam processor with additional variables --> data --> possibly lag, larger save file

Before making this issue, check the boxes below to confirm that you have acknowledged them.

Erisfiregamer1 commented 1 year ago

This would allow us to make JIT (Just In Time) execution in Mindustry logic, which would let us do a lot more.

I'd add it myself if I knew how :|

kubikaugustyn commented 1 year ago

It would be good for universal multi-bind and things like call stack I'm planning to add in my MPPL project (Mindustry Processor Programming Language), which isn't done yet. It would introduce functions as jumps and returns, not things like subroutines in MLOG+1

Erisfiregamer1 commented 1 year ago

Should I take my Java toolkit out of the trash and try to make this? It would be bad but it might work...

kubikaugustyn commented 1 year ago

I can code it myself. But I don't want it to be part of some mod, but to be in vanilla Mindustry

kubikaugustyn commented 1 year ago

I'm worried what will Anuke do Hopefully it won't be rejected

Erisfiregamer1 commented 1 year ago

I'll take a stab at this during the weekend. Wish me luck.

bend-n commented 1 year ago

in background ran as

isnt this concurrency? youll have to add some synchronization primitives too then, right?

kubikaugustyn commented 1 year ago

Wdym? What synchronization primitives? How hard is it to just add a new instruction?

bend-n commented 1 year ago

well, in the case of

set x 45
eval "set x 25"
evalflush
set x 15

what is x?

Erisfiregamer1 commented 1 year ago

well, in the case of

set x 45
eval "set x 25"
evalflush
set x 15

what is x?

X would become 45, and then 15. evals would run in a sandbox without the same variables as the host- just the same links.

For my variant of eval, it would look like this:

set x 45
eval "set x 25"
set x 15
bend-n commented 1 year ago

oh so its just spawn a new processor?

kubikaugustyn commented 1 year ago

well, in the case of

set x 45
eval "set x 25"
evalflush
set x 15

what is x?

I like more this option containing evalflush, so you can create the commands dynamically. If no, what's the point? After instruction 0, x = 45 After 1, no change After 3, set x 25 is evaluated, so x = 25 After 4, x is set to 15 That repeats indefinitely

kubikaugustyn commented 1 year ago

oh so its just spawn a new processor?

@Erisfiregamer1 , I don't think creating some sort of VM processor would have any point. I need something that just evaluates instruction using evalflush entered by one or more eval <part of instruction>.

Erisfiregamer1 commented 1 year ago

oh so its just spawn a new processor?

@Erisfiregamer1 , I don't think creating some sort of VM processor would have any point. I need something that just evaluates instruction using evalflush entered by one or more eval <part of instruction>.

No, it has the same links. Since we can write our own mlog, we just need some separator... Maybe ;?

bend-n commented 1 year ago

The current mlog separator is \n, just write newlines.

kubikaugustyn commented 1 year ago

I don't want to create a new MLOG separated by ";", I just want to run normal MLOG instructions that are dynamically generated.

For custom commands etc. there are things such as MLOG+1 or MPPL, which bendn knows about and didn't like it. MPPL is my project, that isn't fully working yet. EDIT: Check documentation for functions that are currently available

bend-n commented 1 year ago

what do you mean i didnt like it? ive contributed a little to pyndustric myself

also, where is the conversation on custom commands, i dont see anything.

kubikaugustyn commented 1 year ago

Screenshot.jpg I saw @Erisfiregamer1 talk about ";", you've denied it and said the separator is "\n".

Erisfiregamer1 commented 1 year ago

Hey, I'm going to sit here and talk a little bit on my idea, and the fact that yes I am doing this at some point.

1: ";" is a valid separator in mlog parsing, so you can use that.

  1. You can run code with eval(), it's one time and further execution waits for the eval to finish.
  2. Evaluated code has the same instructions per second and instruction limit as the host processor. It's all linked up :)
  3. End will now have an argument you can pass text or a variable to. Combine this with eval() and you can write a variable with the returned value from eval() (which is by default null until changed).
kubikaugustyn commented 1 year ago

I don't understand what do you want to do I want to run single instruction and you're planning some virtual processor, in which you can have 1000 instructions inside single M-LOG instruction, and have that indefinitely, so from 1000 instructions limit we're going to infinity

github-actions[bot] commented 1 year ago

This suggestion is now stale, and will be automatically closed.

kubikaugustyn commented 1 year ago

It's not completed GitHub!!!!