Good vs. Evil

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
43 I made a simplistic brainfuck optimizer compiler in rust in about 1 and a half hour.

It goes over the code in 2 passes. The first (which is done in parallel) turns the brainfuck "script" into tokens that are easier to work with. It also filters out everything that is not an instruction.

The second pass, combines instructions that are next to each other. Meaning that +++ becomes Add(3). It also "links" the start and end of every loop. Meaning it can simply become a jump instruction.

There are more optimizations possible like [-] which can become a single instruction to set the current cell to zero and [>]/ [<] which simply move the pointer left/right until it hits an cell containing 0.

But before I start doing any of that I first need to fix the bug that causes the last instruction to not be part of the program and make it so it can actually execute the code. After that I should probably also dig up my old lua version of it to compare the two. I suspect the lua version is slower HOWEVER that only needs 1 pass to optimize it, so it will be interesting to see how that changes things.

I probably should also keep the rust version that isn't multi threaded because that doesn't need to temporary make a Vec after the first pass and thus should be optimized into a single pass, just like my lua code.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
44 yep, another fun thing is when a teacher says that the school he teaches at is insane.

And.... I can't say I disagree with him.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
44 managed to work more on arena keeper. The wall and bed are now both defined using json files and thus in theory more items can be added simply by using them. I also fixed the rendering logic so tile features (like the wall and bed) can have transparency.

Next thing is to change the buttons that allow you to select what to build so that that isn't hard coded any more. After that it should be ready for a new push to master (meaning an automatic new web build)
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
44 those suck.

meanwhile, I got the buttons working so they aren't hard coded any more. Right now, an automatic build is running to update the online version :)

edit: And... it used the wrong file in the /bin folder, meaning that although the build succeeded, the wasm file is broken. Hopefully, I got that fixed now though (still waiting on a new build and deploy)
 
Last edited: